diff options
author | Adam Cozzette <acozzette@google.com> | 2018-03-13 16:54:31 -0700 |
---|---|---|
committer | Adam Cozzette <acozzette@google.com> | 2018-03-13 16:54:31 -0700 |
commit | afe96b6d4235b9d9fbfce2465f5c6d82c2611f48 (patch) | |
tree | d509cb3cc3f2b25b58a75563758d2092103ca19a /src/google/protobuf/util/internal/datapiece.cc | |
parent | 0400cca3236de1ca303af38bf81eab332d042b7c (diff) | |
parent | 89b5333ad0f10058d5af62701c5ebea0db376c5b (diff) | |
download | protobuf-afe96b6d4235b9d9fbfce2465f5c6d82c2611f48.tar.gz protobuf-afe96b6d4235b9d9fbfce2465f5c6d82c2611f48.tar.bz2 protobuf-afe96b6d4235b9d9fbfce2465f5c6d82c2611f48.zip |
Merge branch 'master' into down-integrate
Diffstat (limited to 'src/google/protobuf/util/internal/datapiece.cc')
-rw-r--r-- | src/google/protobuf/util/internal/datapiece.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/google/protobuf/util/internal/datapiece.cc b/src/google/protobuf/util/internal/datapiece.cc index 2f4242d5..59bc28ae 100644 --- a/src/google/protobuf/util/internal/datapiece.cc +++ b/src/google/protobuf/util/internal/datapiece.cc @@ -272,7 +272,8 @@ StatusOr<string> DataPiece::ToBytes() const { } StatusOr<int> DataPiece::ToEnum(const google::protobuf::Enum* enum_type, - bool use_lower_camel_for_enums) const { + bool use_lower_camel_for_enums, + bool ignore_unknown_enum_values) const { if (type_ == TYPE_NULL) return google::protobuf::NULL_VALUE; if (type_ == TYPE_STRING) { @@ -305,6 +306,10 @@ StatusOr<int> DataPiece::ToEnum(const google::protobuf::Enum* enum_type, value = FindEnumValueByNameWithoutUnderscoreOrNull(enum_type, enum_name); if (value != nullptr) return value->number(); } + + // If ignore_unknown_enum_values is true an unknown enum value is treated + // as the default + if (ignore_unknown_enum_values) return enum_type->enumvalue(0).number(); } else { // We don't need to check whether the value is actually declared in the // enum because we preserve unknown enum values as well. |