Question

it seems I am unable to find any source telling me how to use lists with libconfig.

Let's say my config file looks like this:

Layer1 = {
    Layer2 = {
        SomeOption = "MyValue";
        Options =  (
            {
                Option = "Full Screen";
                Value = "No";
            },
            {
                Option = "Title";
                Value = "Test";
            }
        );
    };
};

How can I read Options with libconfig++ ? I can only find methods for reading single values.

Was it helpful?

Solution

OK, I have found the answer:

using namespace libconfig;

// ...

Config *pConfig = new Config();
// ...
Setting& settings = pConfig->lookup("Layer1.Layer2.Options");
const char* op0 = settings[0]["Option"];

// ...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top