|
| xdgcfg (const string &filename, const string &subdir="") |
| Checks if subdir is present, creates it if necessary. More...
|
|
const uint_fast8_t | read () |
| Read the file. More...
|
|
const bool | write () |
| Write the file. More...
|
|
libconfig::Config & | get_cfg () |
| Returns a reference to the config as libconfig::Config. More...
|
|
const fs::path | get_filepath () const |
| Returns the complete filepath.
|
|
const void | set_verbose (bool verbose) |
| Sets verbosity.
|
|
const bool | get_verbose () const |
| Returns verbosity.
|
|
◆ xdgcfg()
xdgcfg::xdgcfg |
( |
const string & |
filename, |
|
|
const string & |
subdir = "" |
|
) |
| |
|
explicit |
Checks if subdir is present, creates it if necessary.
Example:
xdgcfg config(
"test.cfg",
"subdirectory");
- Parameters
-
filename | The name of the file, including extension |
subdir | The subdir (optional) |
18 _filepath = xdgConfigHome(&xdg);
25 if (!fs::exists(_filepath))
27 fs::create_directories(_filepath);
29 _filepath /= filename;
◆ get_cfg()
libconfig::Config & xdgcfg::get_cfg |
( |
| ) |
|
Returns a reference to the config as libconfig::Config.
Example:
libconfig::Config &cfg = config.get_cfg();
- Examples:
- example.cpp.
◆ read()
const uint_fast8_t xdgcfg::read |
( |
| ) |
|
Read the file.
- Returns
- 0 on success, 1 on I/O error, 2 on parse error.
- Examples:
- example.cpp.
36 _cfg.readFile(_filepath.c_str());
38 catch (
const libconfig::FileIOException &e)
42 cerr <<
"I/O error while reading " << _filepath
43 <<
" - " << e.what() << endl;
47 catch (
const libconfig::ParseException &e)
51 cerr <<
"Parse error at " << e.getFile() <<
":" << e.getLine()
52 <<
" - " << e.getError() << endl;
◆ write()
const bool xdgcfg::write |
( |
| ) |
|
Write the file.
- Returns
true
on success
- Examples:
- example.cpp.
64 _cfg.writeFile(_filepath.c_str());
66 catch (
const libconfig::FileIOException &e)
70 cerr <<
"I/O error while writing " << _filepath
71 <<
" - " << e.what() << endl;
The documentation for this class was generated from the following files: