|
| 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 string | 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) |
29 _filepath = xdgConfigHome(&xdg);
34 _filepath +=
'/' + subdir;
35 if (!fs::exists(_filepath))
37 fs::create_directory(_filepath);
40 _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.
47 _cfg.readFile(_filepath.c_str());
49 catch (
const libconfig::FileIOException &e)
53 cerr <<
"I/O error while reading " << _filepath
54 <<
" - " << e.what() << endl;
58 catch (
const libconfig::ParseException &e)
62 cerr <<
"Parse error at " << e.getFile() <<
":" << e.getLine()
63 <<
" - " << e.getError() << endl;
◆ write()
const bool xdgcfg::write |
( |
| ) |
|
Write the file.
- Returns
true
on success
- Examples:
- example.cpp.
75 _cfg.writeFile(_filepath.c_str());
77 catch (
const libconfig::FileIOException &e)
81 cerr <<
"I/O error while writing " << _filepath
82 <<
" - " << e.what() << endl;
The documentation for this class was generated from the following files: