MCPcopy Create free account
hub / github.com/apache/brpc / string_append_value

Function string_append_value

src/json2pb/json_to_pb.cpp:87–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85};
86
87static void string_append_value(const BUTIL_RAPIDJSON_NAMESPACE::Value& value,
88 std::string* output) {
89 if (value.IsNull()) {
90 output->append("null");
91 } else if (value.IsBool()) {
92 output->append(value.GetBool() ? "true" : "false");
93 } else if (value.IsInt()) {
94 butil::string_appendf(output, "%d", value.GetInt());
95 } else if (value.IsUint()) {
96 butil::string_appendf(output, "%u", value.GetUint());
97 } else if (value.IsInt64()) {
98 butil::string_appendf(output, "%" PRId64, value.GetInt64());
99 } else if (value.IsUint64()) {
100 butil::string_appendf(output, "%" PRIu64, value.GetUint64());
101 } else if (value.IsDouble()) {
102 butil::string_appendf(output, "%f", value.GetDouble());
103 } else if (value.IsString()) {
104 output->push_back('"');
105 output->append(value.GetString(), value.GetStringLength());
106 output->push_back('"');
107 } else if (value.IsArray()) {
108 output->append("array");
109 } else if (value.IsObject()) {
110 output->append("object");
111 }
112}
113
114//It will be called when type mismatch occurs, fg: convert string to uint,
115//and will also be called when invalid value appears, fg: invalid enum name,

Callers 1

value_invalidFunction · 0.85

Calls 8

string_appendfFunction · 0.85
IsBoolMethod · 0.80
IsStringMethod · 0.80
GetStringMethod · 0.80
IsArrayMethod · 0.80
IsObjectMethod · 0.80
appendMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected