diff --git a/helpers.cpp b/helpers.cpp index fe84b72..01d08b4 100644 --- a/helpers.cpp +++ b/helpers.cpp @@ -10,28 +10,28 @@ using std::istream; using std::ostream; using std::string; -bool read_config_json(json& cfg, const string& filename, ostream* log) +bool read_file_json(json& j, const string& filename, ostream* log) { - ifstream cfg_file(filename); + ifstream file(filename); - if (!cfg_file.is_open()) + if (!file.is_open()) { if (nullptr != log) { - *log << "Could not open config file" << endl; + *log << "Could not open file" << endl; } return false; } - return read_config_json(cfg, cfg_file, log); + return read_stream_json(j, file, log); } -bool read_config_json(json& cfg, istream& in, ostream* log) +bool read_stream_json(json& j, istream& in, ostream* log) { // Parse with comments try { - cfg = json::parse(in, nullptr, true, true); + j = json::parse(in, nullptr, true, true); } catch (const std::exception &e) { diff --git a/helpers.h b/helpers.h index 3255214..cc1fca1 100644 --- a/helpers.h +++ b/helpers.h @@ -9,19 +9,19 @@ #include "json.hpp" -// Reads configuration json from supplied filename -// cfg - output json +// Reads json from supplied filename +// j - output json // filename - filepath from which to read json // log - ostream to log human readable errors to - can be nullptr // Returns - true if read and parse is successful -bool read_config_json(nlohmann::json& cfg, const std::string& filename, std::ostream* log); +bool read_file_json(nlohmann::json& j, const std::string& filename, std::ostream* log); // Reads configuration json from supplied istream -// cfg - output json +// j - output json // in - istream from which to read json // log - ostream to log human readable errors to - can be nullptr // Returns - true if read and parse is successful -bool read_config_json(nlohmann::json& cfg, std::istream& in, std::ostream* log); +bool read_stream_json(nlohmann::json& j, std::istream& in, std::ostream* log); // JSON Extraction Helpers // out value is modified only if an extraction happened