| 39 | |
| 40 | namespace YAML { |
| 41 | bool convert<bool>::decode(const Node& node, bool& rhs) { |
| 42 | if (!node.IsScalar()) |
| 43 | return false; |
| 44 | |
| 45 | // we can't use iostream bool extraction operators as they don't |
| 46 | // recognize all possible values in the table below (taken from |
| 47 | // http://yaml.org/type/bool.html) |
| 48 | static const struct { |
| 49 | std::string truename, falsename; |
| 50 | } names[] = { |
| 51 | {"y", "n"}, |
| 52 | {"yes", "no"}, |
| 53 | {"true", "false"}, |
| 54 | {"on", "off"}, |
| 55 | }; |
| 56 | |
| 57 | if (!IsFlexibleCase(node.Scalar())) |
| 58 | return false; |
| 59 | |
| 60 | for (const auto& name : names) { |
| 61 | if (name.truename == tolower(node.Scalar())) { |
| 62 | rhs = true; |
| 63 | return true; |
| 64 | } |
| 65 | |
| 66 | if (name.falsename == tolower(node.Scalar())) { |
| 67 | rhs = false; |
| 68 | return true; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | return false; |
| 73 | } |
| 74 | } // namespace YAML |
nothing calls this directly
no test coverage detected