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.
2018-08-10 02:22:06 +02:00
|
|
|
#include <iostream>
|
|
|
|
#include <libconfig.h++>
|
|
|
|
#include "xdgcfg.hpp"
|
|
|
|
|
2018-12-29 04:10:17 +01:00
|
|
|
int main()
|
2018-08-10 02:22:06 +02:00
|
|
|
{
|
|
|
|
xdgcfg config("test.cfg", "xdgcfg");
|
|
|
|
config.set_verbose(true);
|
|
|
|
if (config.read() != 0)
|
|
|
|
{
|
|
|
|
config.write();
|
|
|
|
}
|
|
|
|
libconfig::Config &cfg = config.get_cfg();
|
|
|
|
libconfig::Setting &root = cfg.getRoot();
|
|
|
|
if (!root.exists("Hello"))
|
|
|
|
{
|
|
|
|
root.add("Hello", libconfig::Setting::TypeString) = "World";
|
|
|
|
}
|
|
|
|
config.write();
|
|
|
|
|
|
|
|
std::cout << "Hello: " << root["Hello"].c_str() << std::endl;
|
|
|
|
}
|