xdgcfg  0.2.2
xdgcfg.hpp
1 /* Public Domain / CC-0
2  * Author: tastytea <tastytea@tastytea.de>
3  */
4 
5 #ifndef XDGCFG_HPP
6 #define XDGCFG_HPP
7 
8 #if __cplusplus >= 201703L
9  #include <filesystem>
10 #else
11  #include <experimental/filesystem>
12 #endif
13 #include <string>
14 #include <cstdint>
15 #include <libconfig.h++>
16 
17 #if __cplusplus >= 201703L
18  namespace fs = std::filesystem;
19 #else
20  namespace fs = std::experimental::filesystem;
21 #endif
22 using std::string;
23 using std::uint_fast8_t;
24 
25 class xdgcfg
26 {
27 public:
39  explicit xdgcfg(const string &filename, const string &subdir = "");
40 
46  const uint_fast8_t read();
47 
53  const bool write();
54 
63  libconfig::Config &get_cfg();
64 
68  const fs::path get_filepath() const;
69 
73  const void set_verbose(bool verbose);
74 
78  const bool get_verbose() const;
79 
80 private:
84  libconfig::Config _cfg;
85 
89  fs::path _filepath;
90 
94  bool _verbose;
95 };
96 
101 #endif // XDGCFG_HPP
const bool write()
Write the file.
Definition: xdgcfg.cpp:60
Definition: xdgcfg.hpp:25
const void set_verbose(bool verbose)
Sets verbosity.
Definition: xdgcfg.cpp:89
xdgcfg(const string &filename, const string &subdir="")
Checks if subdir is present, creates it if necessary.
Definition: xdgcfg.cpp:12
libconfig::Config & get_cfg()
Returns a reference to the config as libconfig::Config.
Definition: xdgcfg.cpp:79
const uint_fast8_t read()
Read the file.
Definition: xdgcfg.cpp:32
const fs::path get_filepath() const
Returns the complete filepath.
Definition: xdgcfg.cpp:84
const bool get_verbose() const
Returns verbosity.
Definition: xdgcfg.cpp:94