hyperrealm / libconfig

C/C++ library for processing configuration files
https://hyperrealm.github.io/libconfig/
GNU Lesser General Public License v2.1
1.1k stars 359 forks source link

how to identify list's setting and group's setting? #203

Closed nickhuangxinyu closed 2 years ago

nickhuangxinyu commented 2 years ago

I think list's element setting and group's element setting are different.

for example:

list = (1,2,3);
group = {
 a = "asd";
 b = 1;
};
libconfig::Setting& list = cfg.lookup("list");
libconfig::Setting& group = cfg.lookup("group");

for (int i = 0; i < list.getLength(); ++i) {
  libconfig::Setting& s = list[i];
  cout << s.getName();  // list's element dont have getName()
}

for (int i = 0; i < group.getLength(); ++i) {
  libconfig::Setting& s = group[i];
  cout << s.getName();  // group's element have Name.
}

I found many function, isScalar and ...

is there any is function to identify list and group's element?

hyperrealm commented 2 years ago

element.getParent().getType()