You'll have to parse the datetime yourself. If you have some structure DateTime
, as a skeleton, you could write:
namespace YAML {
template<>
struct convert<DateTime> {
static Node encode(const DateTime& rhs) {
std::string str = YourCodeToConvertToAString(rhs);
return Node(str);
}
static bool decode(const Node& node, DateTime& rhs) {
if(!node.IsScalar())
return false;
std::string str = node.as<std::string>();
// Fill in the DateTime struct.
return true;
}
};
}
If you can find a library (maybe boost) to do that, that'd be easier, but it's possible the YAML format for datetime isn't exactly what some other library expects.
In general, yaml-cpp doesn't support any automatic type detection.