xdgjson  0.2.2
xdgjson.hpp
1 /* Public Domain / CC-0
2  * Author: tastytea <tastytea@tastytea.de>
3  */
4 
5 #ifndef XDGJSON_HPP
6 #define XDGJSON_HPP
7 
8 #if __cplusplus >= 201703L
9  #include <filesystem>
10 #else
11  #include <experimental/filesystem>
12 #endif
13 #include <string>
14 #include <jsoncpp/json/json.h>
15 
16 #if __cplusplus >= 201703L
17  namespace fs = std::filesystem;
18 #else
19  namespace fs = std::experimental::filesystem;
20 #endif
21 using std::string;
22 
23 class xdgjson
24 {
25 public:
37  explicit xdgjson(const string &filename, const string &subdir = "");
38 
44  const bool read();
45 
51  const bool write();
52 
61  Json::Value &get_json();
62 
66  const fs::path get_filepath() const;
67 
68 private:
72  Json::Value _json;
73 
77  fs::path _filepath;
78 };
79 
84 #endif // XDGJSON_HPP
const bool read()
Read the file.
Definition: xdgjson.cpp:29
xdgjson(const string &filename, const string &subdir="")
Checks if subdir is present, creates it if necessary.
Definition: xdgjson.cpp:10
const bool write()
Write the file.
Definition: xdgjson.cpp:47
const fs::path get_filepath() const
Returns the complete filepath.
Definition: xdgjson.cpp:69
Json::Value & get_json()
Returns a reference to the config as Json::Value.
Definition: xdgjson.cpp:64
Definition: xdgjson.hpp:23