How do I get this code to parse ""
as a string (or recognize it is not an acceptable string)? I am using this YAML-cpp library which I verified treats this as a NodeType::value()
and not a NodeType::Null
.
std::string getFilepath() {
YAML::Node nodeValue = node["filepath"];
if(nodeValue.Type() == YAML::NodeType::value()){
return nodeValue.as<std::string>(); //Breaks here
}
return "";
}
In the .yaml file, the entry is listed as filepath: ""
YAML::NodeType
does not include more specific variable types than value()
and Null
.
Here's the specific error:
terminate called after throwing an instance of
'YAML::TypedBadConversion<std::string>'
what(): bad conversion
The only work-around I have figured out so far is a try-catch block.