This repository has been archived on 2020-05-16. You can view files and clone it, but cannot push or open issues or pull requests.
xdgjson/src/xdgjson.hpp

75 lines
1.4 KiB
C++

/* Public Domain / CC-0
* Author: tastytea <tastytea@tastytea.de>
*/
#ifndef XDGJSON_HPP
#define XDGJSON_HPP
#include <string>
#include <jsoncpp/json/json.h>
using std::string;
class xdgjson
{
public:
/*!
* @brief Checks if subdir is present, creates it if necessary
*
* Example:
* @code
* xdgjson config("test.json", "subdirectory");
* @endcode
*
* @param filename The name of the file, including extension
* @param subdir The subdir (optional)
*/
explicit xdgjson(const string &filename, const string &subdir = "");
/*!
* @brief Read the file
*
* @return `true` on success
*/
const bool read();
/*!
* @brief Write the file
*
* @return `true` on success
*/
const bool write();
/*!
* @brief Returns a reference to the config as Json::Value
*
* Example:
* @code
* Json::Value &json = config.get_json();
* @endcode
*/
Json::Value &get_json();
/*!
* @brief Returns the complete filepath
*/
const string get_filepath() const;
private:
/*!
* Holds the contents of the JSON file
*/
Json::Value _json;
/*!
* Complete filepath
*/
string _filepath;
};
/*!
* @example example.cpp
*/
#endif // XDGJSON_HPP