Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 yaml-cpp 中,除了在 YAML 源中使用应用程序定义的标签时,该函数YAML::Node::Tag()似乎只返回任何内容。"?"当然它应该返回 (例如)"!!map"或"!!int"其他内置标签。这是理想的行为吗?例如,我如何确定标量节点的特定类型标记,例如 null、boolean、integer、float、string 等?我能看到的唯一方法是尝试YAML::Node::as<T>()每种类型,直到不引发异常。
YAML::Node::Tag()
"?"
"!!map"
"!!int"
YAML::Node::as<T>()
要获取节点的类型,请调用YAML::Node::Type(). 返回值是以下之一:
YAML::Node::Type()
YAML::NodeType::Undefined YAML::NodeType::Null YAML::NodeType::Scalar YAML::NodeType::Sequence YAML::NodeType::Map
yaml-cpp 不做更具体的自动标签检测,例如,它不会验证!!int与!!float.
!!int
!!float