refactor: move command execution into their own file

This commit is contained in:
Alexis
2018-08-18 17:54:20 +02:00
parent b794ca63d1
commit ce50a627be
5 changed files with 124 additions and 120 deletions

View File

@ -4,31 +4,31 @@
namespace waybar::util {
struct JsonParser {
struct JsonParser {
JsonParser()
: _reader(_builder.newCharReader())
{}
JsonParser()
: _reader(_builder.newCharReader())
{}
Json::Value parse(const std::string data)
{
Json::Value root;
std::string err;
bool res =
_reader->parse(data.c_str(), data.c_str() + data.size(), &root, &err);
if (!res)
throw std::runtime_error(err);
return root;
}
Json::Value parse(const std::string data)
{
Json::Value root;
std::string err;
bool res =
_reader->parse(data.c_str(), data.c_str() + data.size(), &root, &err);
if (!res)
throw std::runtime_error(err);
return root;
}
~JsonParser()
{
delete _reader;
}
~JsonParser()
{
delete _reader;
}
private:
Json::CharReaderBuilder _builder;
Json::CharReader *_reader;
};
private:
Json::CharReaderBuilder _builder;
Json::CharReader *_reader;
};
}