|
| xdgjson (const string &filename, const string &subdir="") |
| Checks if subdir is present, creates it if necessary. More...
|
|
const bool | read () |
| Read the file. More...
|
|
const bool | write () |
| Write the file. More...
|
|
Json::Value & | get_json () |
| Returns a reference to the config as Json::Value. More...
|
|
const fs::path | get_filepath () const |
| Returns the complete filepath.
|
|
◆ xdgjson()
xdgjson::xdgjson |
( |
const string & |
filename, |
|
|
const string & |
subdir = "" |
|
) |
| |
|
explicit |
Checks if subdir is present, creates it if necessary.
Example:
xdgjson config(
"test.json",
"subdirectory");
- Parameters
-
filename | The name of the file, including extension |
subdir | The subdir (optional) |
15 _filepath = xdgConfigHome(&xdg);
22 if (!fs::exists(_filepath))
24 fs::create_directories(_filepath);
26 _filepath /= filename;
◆ get_json()
Json::Value & xdgjson::get_json |
( |
| ) |
|
Returns a reference to the config as Json::Value.
Example:
Json::Value &json = config.get_json();
- Examples:
- example.cpp.
◆ read()
const bool xdgjson::read |
( |
| ) |
|
Read the file.
- Returns
true
on success
- Examples:
- example.cpp.
31 std::ifstream file(_filepath);
34 std::stringstream config;
35 config << file.rdbuf();
◆ write()
const bool xdgjson::write |
( |
| ) |
|
Write the file.
- Returns
true
on success
- Examples:
- example.cpp.
49 std::ofstream file(_filepath);
52 const string config = _json.toStyledString();
53 file.write(config.c_str(), config.length());
The documentation for this class was generated from the following files: