/* Public Domain / CC-0
* Author: tastytea <tastytea@tastytea.de>
*/
#ifndef XDGCFG_HPP
#define XDGCFG_HPP
#include <string>
#include <cstdint>
#include <libconfig.h++>
using std::string;
using std::uint_fast8_t;
class xdgcfg
{
public:
/*!
* @brief Checks if subdir is present, creates it if necessary
*
* Example:
* @code
* xdgcfg config("test.cfg", "subdirectory");
* @endcode
* @param filename The name of the file, including extension
* @param subdir The subdir (optional)
explicit xdgcfg(const string &filename, const string &subdir = "");
* @brief Read the file
* @return 0 on success, 1 on I/O error, 2 on parse error.
const uint_fast8_t read();
* @brief Write the file
* @return `true` on success
const bool write();
* @brief Returns a reference to the config as libconfig::Config
* libconfig::Config &cfg = config.get_cfg();
libconfig::Config &get_cfg();
* @brief Returns the complete filepath
const string get_filepath() const;
* @brief Sets verbosity
const void set_verbose(bool verbose);
* @brief Returns verbosity
const bool get_verbose() const;
private:
* Holds the contents of the CFG file
libconfig::Config _cfg;
* Complete filepath
string _filepath;
* Print out error messages if true
bool _verbose;
};
* @example example.cpp
#endif // XDGCFG_HPP