You can check Node::Type()
and handle accordingly:
void WalkNode(YAML::Node node) {
switch (node.Type()) {
case YAML::NodeType::Null:
HandleNull();
break;
case YAML::NodeType::Scalar:
HandleScalar(node.Scalar());
break;
case YAML::NodeType::Sequence:
for (auto it = node.begin(); it != node.end(); ++it) {
WalkNode(*it);
}
break;
case YAML::NodeType::Map:
for (auto it = node.begin(); it != node.end(); ++it) {
WalkNode(it->first);
WalkNode(it->second);
}
break;
case YAML::NodeType::Undefined:
throw std::runtime_exception("undefined node!");
}
}