c++listlibconfig

c++ libconfig and lists


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.


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"];
    
    // ...