aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/text_format.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/text_format.cc')
-rw-r--r--src/google/protobuf/text_format.cc22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc
index 5192eca9..e3d908ec 100644
--- a/src/google/protobuf/text_format.cc
+++ b/src/google/protobuf/text_format.cc
@@ -154,7 +154,7 @@ TextFormat::ParseInfoTree* TextFormat::ParseInfoTree::CreateNested(
const FieldDescriptor* field) {
// Owned by us in the map.
TextFormat::ParseInfoTree* instance = new TextFormat::ParseInfoTree();
- vector<TextFormat::ParseInfoTree*>* trees = &nested_[field];
+ std::vector<TextFormat::ParseInfoTree*>* trees = &nested_[field];
GOOGLE_CHECK(trees);
trees->push_back(instance);
return instance;
@@ -177,7 +177,7 @@ TextFormat::ParseLocation TextFormat::ParseInfoTree::GetLocation(
CheckFieldIndex(field, index);
if (index == -1) { index = 0; }
- const vector<TextFormat::ParseLocation>* locations =
+ const std::vector<TextFormat::ParseLocation>* locations =
FindOrNull(locations_, field);
if (locations == NULL || index >= locations->size()) {
return TextFormat::ParseLocation();
@@ -191,7 +191,8 @@ TextFormat::ParseInfoTree* TextFormat::ParseInfoTree::GetTreeForNested(
CheckFieldIndex(field, index);
if (index == -1) { index = 0; }
- const vector<TextFormat::ParseInfoTree*>* trees = FindOrNull(nested_, field);
+ const std::vector<TextFormat::ParseInfoTree*>* trees =
+ FindOrNull(nested_, field);
if (trees == NULL || index >= trees->size()) {
return NULL;
}
@@ -518,7 +519,14 @@ class TextFormat::Parser::ParserImpl {
// Perform special handling for embedded message types.
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
// ':' is optional here.
- TryConsume(":");
+ bool consumed_semicolon = TryConsume(":");
+ if (consumed_semicolon && field->options().weak() && LookingAtType(io::Tokenizer::TYPE_STRING)) {
+ // we are getting a bytes string for a weak field.
+ string tmp;
+ DO(ConsumeString(&tmp));
+ reflection->MutableMessage(message, field)->ParseFromString(tmp);
+ goto label_skip_parsing;
+ }
} else {
// ':' is required here.
DO(Consume(":"));
@@ -546,7 +554,7 @@ class TextFormat::Parser::ParserImpl {
} else {
DO(ConsumeFieldValue(message, reflection, field));
}
-
+label_skip_parsing:
// For historical reasons, fields may optionally be separated by commas or
// semicolons.
TryConsume(";") || TryConsume(",");
@@ -1336,7 +1344,7 @@ bool TextFormat::Parser::MergeUsingImpl(io::ZeroCopyInputStream* /* input */,
ParserImpl* parser_impl) {
if (!parser_impl->Parse(output)) return false;
if (!allow_partial_ && !output->IsInitialized()) {
- vector<string> missing_fields;
+ std::vector<string> missing_fields;
output->FindInitializationErrors(&missing_fields);
parser_impl->ReportError(-1, 0, "Message missing required fields: " +
Join(missing_fields, ", "));
@@ -1610,7 +1618,7 @@ void TextFormat::Printer::Print(const Message& message,
PrintAny(message, generator)) {
return;
}
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
reflection->ListFields(message, &fields);
if (print_message_fields_in_index_order_) {
std::sort(fields.begin(), fields.end(), FieldIndexSorter());