how to use libconfig to read several config files in one object?

176 views Asked by At

Assume I have a libconfig::config object, can i readFile for several times like this:

libconfig::Config cfg;
cfg.readFiles("./a.cfg");
cfg.readFiles("./b.cfg");

and what will happen if a.cfg and b.cfg have same key?

If this doesnt work, is there any methods can let me merge two config files' setting into one object?

1

There are 1 answers

2
Afshin On

At first, it seems that method is readFile() not readFiles() unless I'm checking incorrect library.

Second, everytime readFile() is called, values in config will be reset. So after cfg.readFiles("./b.cfg"); you will not have a.cfg configuration anymore.