Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions 3rdparty/stout/include/stout/protobuf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ Try<T> deserialize(const std::string& value)
value.data(),
static_cast<int>(value.size()));
if (!t.ParseFromZeroCopyStream(&stream)) {
return Error("Failed to deserialize " + t.GetDescriptor()->full_name());
return Error("Failed to deserialize " + std::string(t.GetDescriptor()->full_name()));
}
return t;
}
Expand All @@ -233,7 +233,7 @@ Try<std::string> serialize(const T& t)

std::string value;
if (!t.SerializeToString(&value)) {
return Error("Failed to serialize " + t.GetDescriptor()->full_name());
return Error("Failed to serialize " + std::string(t.GetDescriptor()->full_name()));
}
return value;
}
Expand Down Expand Up @@ -483,7 +483,7 @@ struct Parser : boost::static_visitor<Try<Nothing>>
break;
default:
return Error("Not expecting a JSON object for field '" +
field->name() + "'");
std::string(field->name()) + "'");
}
return Nothing();
}
Expand All @@ -502,7 +502,7 @@ struct Parser : boost::static_visitor<Try<Nothing>>
Try<std::string> decode = base64::decode(string.value);
if (decode.isError()) {
return Error("Failed to base64 decode bytes field"
" '" + field->name() + "': " + decode.error());
" '" + std::string(field->name()) + "': " + decode.error());
}

if (field->is_repeated()) {
Expand Down Expand Up @@ -552,7 +552,7 @@ struct Parser : boost::static_visitor<Try<Nothing>>
if (number.isError()) {
return Error(
"Failed to parse '" + string.value + "' as a JSON number "
"for field '" + field->name() + "': " + number.error());
"for field '" + std::string(field->name()) + "': " + number.error());
}

return operator()(number.get());
Expand All @@ -572,7 +572,7 @@ struct Parser : boost::static_visitor<Try<Nothing>>
if (number.isError()) {
return Error(
"Failed to parse '" + string.value + "' as a JSON number "
"for field '" + field->name() + "': " + number.error());
"for field '" + std::string(field->name()) + "': " + number.error());
}

return operator()(number.get());
Expand All @@ -582,14 +582,14 @@ struct Parser : boost::static_visitor<Try<Nothing>>
if (boolean.isError()) {
return Error(
"Failed to parse '" + string.value + "' as a JSON boolean "
"for field '" + field->name() + "': " + boolean.error());
"for field '" + std::string(field->name()) + "': " + boolean.error());
}

return operator()(boolean.get());
}
default:
return Error("Not expecting a JSON string for field '" +
field->name() + "'");
std::string(field->name()) + "'");
}
return Nothing();
}
Expand Down Expand Up @@ -647,7 +647,7 @@ struct Parser : boost::static_visitor<Try<Nothing>>
break;
default:
return Error("Not expecting a JSON number for field '" +
field->name() + "'");
std::string(field->name()) + "'");
}
return Nothing();
}
Expand All @@ -656,7 +656,7 @@ struct Parser : boost::static_visitor<Try<Nothing>>
{
if (!field->is_repeated()) {
return Error("Not expecting a JSON array for field '" +
field->name() + "'");
std::string(field->name()) + "'");
}

foreach (const JSON::Value& value, array.values) {
Expand All @@ -683,7 +683,7 @@ struct Parser : boost::static_visitor<Try<Nothing>>
break;
default:
return Error("Not expecting a JSON boolean for field '" +
field->name() + "'");
std::string(field->name()) + "'");
}
return Nothing();
}
Expand Down Expand Up @@ -864,7 +864,7 @@ inline void json(ObjectWriter* writer, const Protobuf& protobuf)
foreach (const FieldDescriptor* field, fields) {
if (field->is_repeated() && !field->is_map()) {
writer->field(
field->name(),
std::string(field->name()),
[&field, &reflection, &message](JSON::ArrayWriter* writer) {
int fieldSize = reflection->FieldSize(message, field);
for (int i = 0; i < fieldSize; ++i) {
Expand Down Expand Up @@ -966,11 +966,11 @@ inline void json(ObjectWriter* writer, const Protobuf& protobuf)
};

if (!field->is_repeated()) { // Singular field.
writeField(field->name(), reflection, message, field);
writeField(std::string(field->name()), reflection, message, field);
} else { // Map field.
CHECK(field->is_map());
writer->field(
field->name(),
std::string(field->name()),
[&field, &reflection, &message, &writeField](
JSON::ObjectWriter* writer) {
foreach (
Expand Down Expand Up @@ -1176,7 +1176,7 @@ inline Object protobuf(const google::protobuf::Message& message)

map.values[name] = value_for_field(entry, value_field);
}
object.values[field->name()] = map;
object.values[std::string(field->name())] = map;
} else if (field->is_repeated()) {
JSON::Array array;
int fieldSize = reflection->FieldSize(message, field);
Expand Down Expand Up @@ -1243,9 +1243,9 @@ inline Object protobuf(const google::protobuf::Message& message)
stringify(field->type()));
}
}
object.values[field->name()] = array;
object.values[std::string(field->name())] = array;
} else {
object.values[field->name()] = value_for_field(message, field);
object.values[std::string(field->name())] = value_for_field(message, field);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/common/protobuf_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ Option<Error> UnionValidator::validate(
reflection->HasField(message, fieldDescriptor)) {
const auto* descr = typeDescriptor_->FindValueByNumber(messageTypeNumber);
return Error(
"Protobuf union `" + message.GetDescriptor()->full_name() +
"Protobuf union `" + string(message.GetDescriptor()->full_name()) +
"` with `Type == " +
(descr == nullptr ? string("<UNKNOWN>") : descr->name()) +
(descr == nullptr ? string("<UNKNOWN>") : string(descr->name())) +
"` should not have the field `" +
fieldDescriptor->name() + "` set.");
string(fieldDescriptor->name()) + "` set.");
}
}
return None();
Expand Down