mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 20:51:16 +00:00
Map iterator works\!
This commit is contained in:
@@ -3,13 +3,22 @@
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
YAML::Value value(YAML::ValueType::Sequence);
|
YAML::Value value;
|
||||||
|
value["seq"] = YAML::Value(YAML::ValueType::Sequence);
|
||||||
for(int i=0;i<5;i++)
|
for(int i=0;i<5;i++)
|
||||||
value.append(i);
|
value["seq"].append(i);
|
||||||
|
value["map"]["one"] = "I";
|
||||||
|
value["map"]["two"] = "II";
|
||||||
|
value["map"]["three"] = "III";
|
||||||
|
value["map"]["four"] = "IV";
|
||||||
|
|
||||||
for(YAML::const_iterator it=value.begin();it!=value.end();++it) {
|
for(YAML::const_iterator it=value["seq"].begin();it!=value["seq"].end();++it) {
|
||||||
std::cout << it->as<int>() << "\n";
|
std::cout << it->as<int>() << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(YAML::const_iterator it=value["map"].begin();it!=value["map"].end();++it) {
|
||||||
|
std::cout << it->first.as<std::string>() << " -> " << it->second.as<std::string>() << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user