aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/util/internal/protostream_objectsource.cc
diff options
context:
space:
mode:
authorJisi Liu <liujisi@google.com>2017-07-24 14:59:27 -0700
committerGitHub <noreply@github.com>2017-07-24 14:59:27 -0700
commit72cc5a6eb3975bbe3bc8454f053835d9e46dbcb5 (patch)
treec04e02e5fe58c1db617a6b8eb0bf6e2b69f55d96 /src/google/protobuf/util/internal/protostream_objectsource.cc
parent942a29cecd36f2a4b22fdd2179635cd548e6bd27 (diff)
parentdd091aad48423f3a047977e6662f0201194b9bfc (diff)
downloadprotobuf-72cc5a6eb3975bbe3bc8454f053835d9e46dbcb5.tar.gz
protobuf-72cc5a6eb3975bbe3bc8454f053835d9e46dbcb5.tar.bz2
protobuf-72cc5a6eb3975bbe3bc8454f053835d9e46dbcb5.zip
Merge pull request #3393 from pherl/3.4.x
Create 3.4.x branch
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;