24 #include <string_view> 38 static constexpr std::string_view nameKey =
"Name"sv;
40 static constexpr std::string_view valueKey =
"Value"sv;
42 static constexpr std::string_view unitKey =
"Unit"sv;
44 static constexpr std::string_view tagsKey =
"Tags"sv;
45 using tagsType = std::map<std::string, std::string>;
46 static constexpr std::string_view computeRateKey =
"ComputeRate"sv;
48 static constexpr std::string_view convertToUnitsPerSecondKey =
"ConvertToUnitsPerSecond"sv;
58 static constexpr std::string_view regexKey =
"Regex"sv;
60 static constexpr std::string_view metricsKey =
"Metrics"sv;
64 std::vector<Config::expression::metric>
metrics;
68 static constexpr std::string_view pathsKey =
"Paths"sv;
70 static constexpr std::string_view expressionsKey =
"Expressions"sv;
78 static constexpr std::string_view programKey =
"Program"sv;
80 static constexpr std::string_view argumentsKey =
"Arguments"sv;
82 static constexpr std::string_view expressionsKey =
"Expressions"sv;
90 static constexpr std::string_view filesKey =
"Files"sv;
92 static constexpr std::string_view commandsKey =
"Commands"sv;
95 std::vector<Config::file>
files;
103 Config(
const std::string& path) noexcept;
126 template<
typename T,
typename K>
127 T
getValue(
const nlohmann::json& j,
const K& key) noexcept {
129 return j[std::string(key)].get<T>();
131 catch(
const std::exception& e) {
132 std::cerr <<
"Error while parsing configuration file: field named \"" << key <<
"\" of required type not found." << std::endl;
133 std::cerr <<
"Internal error: " << e.what() << std::endl;
bool convertToUnitsPerSecondType
std::vector< nlohmann::json > commandsType
std::vector< nlohmann::json > expressionsType
std::vector< Config::command > commands
std::vector< std::string > argumentsType
computeRateType computeRate
Struct used to represent the JSON configuration file.
std::vector< nlohmann::json > filesType
std::vector< nlohmann::json > expressionsType
std::vector< Config::expression > expressions
std::map< std::string, std::string > tagsType
std::vector< Config::file > files
std::vector< std::string > pathsType
void from_json(const nlohmann::json &je, Config::expression &e) noexcept
std::vector< std::string > nameType
std::vector< Config::expression::metric > metrics
std::vector< nlohmann::json > metricsType
std::vector< Config::expression > expressions
convertToUnitsPerSecondType convertToUnitsPerSecond
T getValue(const nlohmann::json &j, const K &key) noexcept
Parse a JSON value of specified type from a JSON dictionary.