mirror of
https://github.com/rad4day/Waybar.git
synced 2025-07-13 22:52:30 +02:00
refactor: format code
This commit is contained in:
@ -5,30 +5,24 @@
|
||||
namespace waybar::util {
|
||||
|
||||
struct JsonParser {
|
||||
JsonParser() : reader_(builder_.newCharReader()) {}
|
||||
|
||||
JsonParser()
|
||||
: reader_(builder_.newCharReader())
|
||||
{}
|
||||
|
||||
const Json::Value parse(const std::string& data) const
|
||||
{
|
||||
const Json::Value parse(const std::string& data) const {
|
||||
Json::Value root;
|
||||
std::string err;
|
||||
if (data.empty()) {
|
||||
return root;
|
||||
}
|
||||
bool res =
|
||||
reader_->parse(data.c_str(), data.c_str() + data.size(), &root, &err);
|
||||
if (!res)
|
||||
throw std::runtime_error(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() = default;
|
||||
|
||||
private:
|
||||
Json::CharReaderBuilder builder_;
|
||||
private:
|
||||
Json::CharReaderBuilder builder_;
|
||||
std::unique_ptr<Json::CharReader> const reader_;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace waybar::util
|
||||
|
Reference in New Issue
Block a user