aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/util/internal/protostream_objectsource.cc
diff options
context:
space:
mode:
authorGravatar Jisi Liu <jisi.liu@gmail.com>2017-07-18 15:38:30 -0700
committerGravatar Jisi Liu <jisi.liu@gmail.com>2017-07-18 15:38:30 -0700
commit09354db1434859a31a3c81abebcc4018d42f2715 (patch)
treeb87c7cdc2255e6c8062ab92b4082665cd698d753 /src/google/protobuf/util/internal/protostream_objectsource.cc
parent9053033a5076f82cf18b823c31f352e95e5bfd8d (diff)
Merge from Google internal for 3.4 release
Diffstat (limited to 'src/google/protobuf/util/internal/protostream_objectsource.cc')
-rw-r--r--src/google/protobuf/util/internal/protostream_objectsource.cc19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/google/protobuf/util/internal/protostream_objectsource.cc b/src/google/protobuf/util/internal/protostream_objectsource.cc
index 025fbd40..02360a1a 100644
--- a/src/google/protobuf/util/internal/protostream_objectsource.cc
+++ b/src/google/protobuf/util/internal/protostream_objectsource.cc
@@ -125,6 +125,7 @@ ProtoStreamObjectSource::ProtoStreamObjectSource(
recursion_depth_(0),
max_recursion_depth_(kDefaultMaxRecursionDepth),
render_unknown_fields_(false),
+ render_unknown_enum_values_(true),
add_trailing_zeros_for_timestamp_and_duration_(false) {
GOOGLE_LOG_IF(DFATAL, stream == NULL) << "Input stream is NULL.";
}
@@ -142,6 +143,7 @@ ProtoStreamObjectSource::ProtoStreamObjectSource(
recursion_depth_(0),
max_recursion_depth_(kDefaultMaxRecursionDepth),
render_unknown_fields_(false),
+ render_unknown_enum_values_(true),
add_trailing_zeros_for_timestamp_and_duration_(false) {
GOOGLE_LOG_IF(DFATAL, stream == NULL) << "Input stream is NULL.";
}
@@ -866,12 +868,6 @@ Status ProtoStreamObjectSource::RenderNonMessageField(
break;
}
- // No need to lookup enum type if we need to render int.
- if (use_ints_for_enums_) {
- ow->RenderInt32(field_name, buffer32);
- break;
- }
-
// Get the nested enum type for this field.
// TODO(skarvaje): Avoid string manipulation. Find ways to speed this
// up.
@@ -883,14 +879,17 @@ Status ProtoStreamObjectSource::RenderNonMessageField(
const google::protobuf::EnumValue* enum_value =
FindEnumValueByNumber(*en, buffer32);
if (enum_value != NULL) {
- if (use_lower_camel_for_enums_)
+ if (use_ints_for_enums_) {
+ ow->RenderInt32(field_name, buffer32);
+ } else if (use_lower_camel_for_enums_) {
ow->RenderString(field_name, ToCamelCase(enum_value->name()));
- else
+ } else {
ow->RenderString(field_name, enum_value->name());
- } else {
+ }
+ } else if (render_unknown_enum_values_) {
ow->RenderInt32(field_name, buffer32);
}
- } else {
+ } else if (render_unknown_enum_values_) {
ow->RenderInt32(field_name, buffer32);
}
break;