Added ability to supply JSON from standard input

This commit is contained in:
2026-03-30 17:28:36 +03:00
parent a80e23614d
commit 6b22d8465e
4 changed files with 40 additions and 6 deletions

View File

@@ -90,6 +90,12 @@ SDL_Rect surface_align(const SDL_Surface* base, const SDL_Surface* applied,
// log - output errors to this ostream, silent if NULL
bool read_config_json(nlohmann::json& cfg, const std::string& filename, std::ostream* log = &std::cout);
// Reads the stream and tries to parse JSON from it with comments
// cfg - output json struct
// in - input stream to read
// log - output errors to this ostream, silent if NULL
bool read_config_json(nlohmann::json& cfg, std::istream& in, std::ostream* log = &std::cout);
// JSON Extractors - They do not override already set values if key is not present
void json_extract(const nlohmann::json& j, const std::string& key, std::string& out);