| 3964 | } |
| 3965 | |
| 3966 | void FastWriter::writeValue(const Value& value) { |
| 3967 | switch (value.type()) { |
| 3968 | case nullValue: |
| 3969 | document_ += "null"; |
| 3970 | break; |
| 3971 | case intValue: |
| 3972 | document_ += valueToString(value.asLargestInt()); |
| 3973 | break; |
| 3974 | case uintValue: |
| 3975 | document_ += valueToString(value.asLargestUInt()); |
| 3976 | break; |
| 3977 | case realValue: |
| 3978 | document_ += valueToString(value.asDouble()); |
| 3979 | break; |
| 3980 | case stringValue: { |
| 3981 | // Is NULL possible for value.string_? |
| 3982 | char const* str; |
| 3983 | char const* end; |
| 3984 | bool ok = value.getString(&str, &end); |
| 3985 | if (ok) document_ += valueToQuotedStringN(str, static_cast<unsigned>(end - str)); |
| 3986 | break; |
| 3987 | } |
| 3988 | case booleanValue: |
| 3989 | document_ += valueToString(value.asBool()); |
| 3990 | break; |
| 3991 | case arrayValue: { |
| 3992 | document_ += '['; |
| 3993 | int size = value.size(); |
| 3994 | for (int index = 0; index < size; ++index) { |
| 3995 | if (index > 0) |
| 3996 | document_ += ','; |
| 3997 | writeValue(value[index]); |
| 3998 | } |
| 3999 | document_ += ']'; |
| 4000 | } break; |
| 4001 | case objectValue: { |
| 4002 | Value::Members members(value.getMemberNames()); |
| 4003 | document_ += '{'; |
| 4004 | for (Value::Members::iterator it = members.begin(); it != members.end(); |
| 4005 | ++it) { |
| 4006 | const std::string& name = *it; |
| 4007 | if (it != members.begin()) |
| 4008 | document_ += ','; |
| 4009 | document_ += valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length())); |
| 4010 | document_ += yamlCompatiblityEnabled_ ? ": " : ":"; |
| 4011 | writeValue(value[name]); |
| 4012 | } |
| 4013 | document_ += '}'; |
| 4014 | } break; |
| 4015 | } |
| 4016 | } |
| 4017 | |
| 4018 | // Class StyledWriter |
| 4019 | // ////////////////////////////////////////////////////////////////// |
nothing calls this directly
no test coverage detected