문제

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

// ...
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top