Merge pull request #1 from toep/u8_parse_fix
Fixed parsing of u8 (unsigned char)
This commit is contained in:
commit
0e0788d764
@ -68,6 +68,21 @@ struct convert<std::string> {
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct convert<unsigned char> {
|
||||
static Node encode(const unsigned char& rhs) { Node n; n = rhs; return n; }
|
||||
|
||||
static bool decode(const Node& node, unsigned char& rhs) {
|
||||
if (node.Type() != NodeType::Scalar) {
|
||||
return false;
|
||||
}
|
||||
int t = stoi(node.Scalar());
|
||||
if(t < 0 || t > 255) return false;
|
||||
rhs = (unsigned char)t;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// C-strings can only be encoded
|
||||
template <>
|
||||
struct convert<const char*> {
|
||||
@ -146,7 +161,7 @@ YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned long long);
|
||||
|
||||
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(char);
|
||||
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(signed char);
|
||||
YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned char);
|
||||
//YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned char);
|
||||
|
||||
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(float);
|
||||
YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(double);
|
||||
|
||||
@ -116,6 +116,7 @@ struct as_if<std::string, S> {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct as_if<T, void> {
|
||||
explicit as_if(const Node& node_) : node(node_) {}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user