diff options
author | Chris Conroy <cconroy@squareup.com> | 2013-10-25 16:43:29 -0400 |
---|---|---|
committer | Chris Conroy <cconroy@squareup.com> | 2015-03-16 18:42:26 -0400 |
commit | 0d77c824e7015190a9174052fc5290c23f2b85d0 (patch) | |
tree | 2a20e7258f86b13b710a2916e61682ff4944c19c /src/google/protobuf/compiler/cpp/cpp_helpers.cc | |
parent | e4a9ace5415477feaefd70a2af2d0e93e83213a3 (diff) | |
download | protobuf-0d77c824e7015190a9174052fc5290c23f2b85d0.tar.gz protobuf-0d77c824e7015190a9174052fc5290c23f2b85d0.tar.bz2 protobuf-0d77c824e7015190a9174052fc5290c23f2b85d0.zip |
Sanitize Enum names from collisions with reserved words.
Diffstat (limited to 'src/google/protobuf/compiler/cpp/cpp_helpers.cc')
-rw-r--r-- | src/google/protobuf/compiler/cpp/cpp_helpers.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc index 237278db..4e7155c3 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -176,6 +176,14 @@ string FieldName(const FieldDescriptor* field) { return result; } +string EnumValueName(const EnumValueDescriptor* enum_value) { + string result = enum_value->name(); + if (kKeywords.count(result) > 0) { + result.append("_"); + } + return result; +} + string FieldConstantName(const FieldDescriptor *field) { string field_name = UnderscoresToCamelCase(field->name(), true); string result = "k" + field_name + "FieldNumber"; |