简体   繁体   中英

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.

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

// ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM