23 lines
510 B
C++
23 lines
510 B
C++
#include <iostream>
|
|
#include <libconfig.h++>
|
|
#include "xdgcfg.hpp"
|
|
|
|
int main()
|
|
{
|
|
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;
|
|
}
|