◆ 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) |
14 _filepath = xdgConfigHome(&xdg);
21 if (!fs::exists(_filepath))
23 fs::create_directories(_filepath);
25 _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.
◆ get_filepath()
const fs::path xdgcfg::get_filepath |
( |
| ) |
const |
Returns the complete filepath.
◆ get_verbose()
bool xdgcfg::get_verbose |
( |
| ) |
const |
◆ read()
uint_fast8_t xdgcfg::read |
( |
| ) |
|
Read the file.
- Returns
- 0 on success, 1 on I/O error, 2 on parse error.
- Examples:
- example.cpp.
32 _cfg.readFile(_filepath.c_str());
34 catch (
const libconfig::FileIOException &e)
38 cerr <<
"I/O error while reading " << _filepath
39 <<
" - " << e.what() << endl;
43 catch (
const libconfig::ParseException &e)
47 cerr <<
"Parse error at " << e.getFile() <<
":" << e.getLine()
48 <<
" - " << e.getError() << endl;
◆ set_verbose()
void xdgcfg::set_verbose |
( |
bool |
verbose | ) |
|
◆ write()
Write the file.
- Returns
true
on success
- Examples:
- example.cpp.
60 _cfg.writeFile(_filepath.c_str());
62 catch (
const libconfig::FileIOException &e)
66 cerr <<
"I/O error while writing " << _filepath
67 <<
" - " << e.what() << endl;
The documentation for this class was generated from the following files: