|
| xdgcfg (const string &filename, const string &subdir="") |
| Checks if subdir is present, creates it if necessary. More...
|
|
uint_fast8_t | read () |
| Read the file. More...
|
|
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.
|
|
void | set_verbose (bool verbose) |
| Sets verbosity.
|
|
bool | get_verbose () const |
| Returns verbosity.
|
|
◆ xdgcfg()
xdgcfg::xdgcfg |
( |
const string & |
filename, |
|
|
const string & |
subdir = "" |
|
) |
| |
|
inlineexplicit |
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) |
49 _filepath = xdgConfigHome(&xdg);
56 if (!fs::exists(_filepath))
58 fs::create_directories(_filepath);
60 _filepath /= filename;
◆ get_cfg()
libconfig::Config& xdgcfg::get_cfg |
( |
| ) |
|
|
inline |
Returns a reference to the config as libconfig::Config.
Example:
libconfig::Config &cfg = config.get_cfg();
- Examples:
- example.cpp.
◆ read()
uint_fast8_t xdgcfg::read |
( |
| ) |
|
|
inline |
Read the file.
- Returns
- 0 on success, 1 on I/O error, 2 on parse error.
- Examples:
- example.cpp.
72 _cfg.readFile(_filepath.c_str());
74 catch (
const libconfig::FileIOException &e)
78 cerr <<
"I/O error while reading " << _filepath
79 <<
" - " << e.what() << endl;
83 catch (
const libconfig::ParseException &e)
87 cerr <<
"Parse error at " << e.getFile() <<
":" << e.getLine()
88 <<
" - " << e.getError() << endl;
◆ write()
Write the file.
- Returns
true
on success
- Examples:
- example.cpp.
105 _cfg.writeFile(_filepath.c_str());
107 catch (
const libconfig::FileIOException &e)
111 cerr <<
"I/O error while writing " << _filepath
112 <<
" - " << e.what() << endl;
The documentation for this class was generated from the following file: