#include <icy/json/configuration.h>Inherits:
Configuration
JSON configuration file
See base Configuration for all accessors
| Return | Name | Description |
|---|---|---|
json::Value | root |
json::Value root| Return | Name | Description |
|---|---|---|
Configuration | ||
~Configuration virtual | Destroys the Configuration. | |
void | load virtual | Sets the file path and loads the configuration. |
void | load virtual | Reloads the configuration from the previously set path. Silently ignores parse errors (e.g. empty file). |
void | save virtual | Writes the current JSON root to the file at the stored path. |
bool | remove virtual | Removes the top-level key key from the JSON root. |
void | removeAll virtual | Removes all top-level keys whose names contain baseKey as a substring. |
void | replace virtual | Performs a global string substitution on the serialized JSON, replacing all occurrences of from with to, then re-parses. |
void | keys virtual | Populates keys with all top-level key names containing baseKey as a substring. |
void | print virtual | Writes the pretty-printed JSON to ost with 4-space indentation. |
std::string | path virtual | Returns the file path that was passed to load(). |
bool | loaded virtual | Returns true if load() has been called at least once. |
Configuration()virtual
virtual ~Configuration()Destroys the Configuration.
virtual
virtual void load(const std::string & path, bool create)Sets the file path and loads the configuration.
path Absolute or relative path to the JSON file.
create Reserved for future use (currently unused).
std::runtime_error if the path is empty.virtual
virtual void load(bool create)Reloads the configuration from the previously set path. Silently ignores parse errors (e.g. empty file).
create Reserved for future use (currently unused).std::runtime_error if the path has not been set.virtual
virtual void save()Writes the current JSON root to the file at the stored path.
std::runtime_error if the path is empty or the file cannot be written.virtual
virtual bool remove(const std::string & key)Removes the top-level key key from the JSON root.
key Key to remove.true if the key existed and was removed.
virtual
virtual void removeAll(const std::string & baseKey)Removes all top-level keys whose names contain baseKey as a substring.
baseKey Substring to match against key names.virtual
virtual void replace(const std::string & from, const std::string & to)Performs a global string substitution on the serialized JSON, replacing all occurrences of from with to, then re-parses.
from Substring to find.
to Replacement string.
virtual
virtual void keys(std::vector< std::string > & keys, const std::string & baseKey)Populates keys with all top-level key names containing baseKey as a substring.
keys Output vector to append matching key names to.
baseKey Filter substring; empty string matches all keys.
virtual
virtual void print(std::ostream & ost)Writes the pretty-printed JSON to ost with 4-space indentation.
ost Output stream.virtual
virtual std::string path()Returns the file path that was passed to load().
virtual
virtual bool loaded()Returns true if load() has been called at least once.
bool _loadedstd::string _pathstd::mutex _mutex| Return | Name | Description |
|---|---|---|
bool | getRaw virtual const | Retrieves the string value for key from the JSON root. |
void | setRaw virtual | Stores value under key in the JSON root and emits PropertyChanged. |
virtual const
virtual bool getRaw(const std::string & key, std::string & value) constRetrieves the string value for key from the JSON root.
key Top-level JSON key.
value Set to the string value if the key exists.
true if the key was found, false otherwise.
virtual
virtual void setRaw(const std::string & key, const std::string & value)Stores value under key in the JSON root and emits PropertyChanged.
key Top-level JSON key.
value String value to store.