#include <iostream>
#include <yaml.h>
using namespace std;
int main() {
YAML::Node config = YAML::LoadFile("/home/tang/tmp/yaml-cpp/config.yaml");
for (auto it = config["defaults"].begin(); it != config["defaults"].end(); it++)
cout << it->first.as<string>() << " " << it->second.as<string>() << endl;
YAML::Node development = config["development"];
for (auto it = development.begin(); it != development.end(); it++) {
// cout << it->first.as<string>() << " " << it->second.as<string>() << endl;
// the below work
if (it->first.as<string>() == "<<"){
for (auto iter : it->second){
cout << iter.first.as<string>() << ": " << iter.second.as<string>() << endl;
}
}else {
cout << it->first.as<string>() << " " << it->second.as<string>() << endl;
}
}
return 0;
}
when I'm using cout << it->first.as<string>() << " " << it->second.as<string>() << endl; , wil be Abandoned (core dumped)
Could you help me, thanks a lot
why can't use the iterator to access the alias and anchor?
config.yaml
and my yaml_test.cpp
when I'm using
cout << it->first.as<string>() << " " << it->second.as<string>() << endl;
, wil be Abandoned (core dumped) Could you help me, thanks a lot