yaml-cpp/util/value.cpp

25 lines
618 B
C++
Raw Normal View History

#include "yaml-cpp/value.h"
#include <map>
int main()
{
2011-09-10 04:25:11 +04:00
YAML::Value value;
value["seq"] = YAML::Value(YAML::ValueType::Sequence);
2011-09-10 04:22:17 +04:00
for(int i=0;i<5;i++)
2011-09-10 04:25:11 +04:00
value["seq"].append(i);
value["map"]["one"] = "I";
value["map"]["two"] = "II";
value["map"]["three"] = "III";
value["map"]["four"] = "IV";
2011-09-10 04:25:11 +04:00
for(YAML::const_iterator it=value["seq"].begin();it!=value["seq"].end();++it) {
2011-09-10 04:22:17 +04:00
std::cout << it->as<int>() << "\n";
}
2011-09-10 04:25:11 +04:00
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;
}