Fix helper naming a bit
This commit is contained in:
14
helpers.cpp
14
helpers.cpp
@@ -10,28 +10,28 @@ using std::istream;
|
|||||||
using std::ostream;
|
using std::ostream;
|
||||||
using std::string;
|
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)
|
if (nullptr != log)
|
||||||
{
|
{
|
||||||
*log << "Could not open config file" << endl;
|
*log << "Could not open file" << endl;
|
||||||
}
|
}
|
||||||
return false;
|
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
|
// Parse with comments
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
cfg = json::parse(in, nullptr, true, true);
|
j = json::parse(in, nullptr, true, true);
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
|
|||||||
10
helpers.h
10
helpers.h
@@ -9,19 +9,19 @@
|
|||||||
#include "json.hpp"
|
#include "json.hpp"
|
||||||
|
|
||||||
|
|
||||||
// Reads configuration json from supplied filename
|
// Reads json from supplied filename
|
||||||
// cfg - output json
|
// j - output json
|
||||||
// filename - filepath from which to read json
|
// filename - filepath from which to read json
|
||||||
// log - ostream to log human readable errors to - can be nullptr
|
// log - ostream to log human readable errors to - can be nullptr
|
||||||
// Returns - true if read and parse is successful
|
// 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
|
// Reads configuration json from supplied istream
|
||||||
// cfg - output json
|
// j - output json
|
||||||
// in - istream from which to read json
|
// in - istream from which to read json
|
||||||
// log - ostream to log human readable errors to - can be nullptr
|
// log - ostream to log human readable errors to - can be nullptr
|
||||||
// Returns - true if read and parse is successful
|
// 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
|
// JSON Extraction Helpers
|
||||||
// out value is modified only if an extraction happened
|
// out value is modified only if an extraction happened
|
||||||
|
|||||||
Reference in New Issue
Block a user