OLD | NEW |
1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 class Printer; // printer.h | 51 class Printer; // printer.h |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 namespace protobuf { | 55 namespace protobuf { |
56 namespace compiler { | 56 namespace compiler { |
57 namespace java { | 57 namespace java { |
58 | 58 |
59 class EnumLiteGenerator { | 59 class EnumLiteGenerator { |
60 public: | 60 public: |
61 explicit EnumLiteGenerator(const EnumDescriptor* descriptor, | 61 EnumLiteGenerator(const EnumDescriptor* descriptor, bool immutable_api, |
62 bool immutable_api, | 62 Context* context); |
63 Context* context); | |
64 ~EnumLiteGenerator(); | 63 ~EnumLiteGenerator(); |
65 | 64 |
66 void Generate(io::Printer* printer); | 65 void Generate(io::Printer* printer); |
67 | 66 |
68 private: | 67 private: |
69 const EnumDescriptor* descriptor_; | 68 const EnumDescriptor* descriptor_; |
70 | 69 |
71 // The proto language allows multiple enum constants to have the same numeric | 70 // The proto language allows multiple enum constants to have the same numeric |
72 // value. Java, however, does not allow multiple enum constants to be | 71 // value. Java, however, does not allow multiple enum constants to be |
73 // considered equivalent. We treat the first defined constant for any | 72 // considered equivalent. We treat the first defined constant for any |
74 // given numeric value as "canonical" and the rest as aliases of that | 73 // given numeric value as "canonical" and the rest as aliases of that |
75 // canonical value. | 74 // canonical value. |
76 vector<const EnumValueDescriptor*> canonical_values_; | 75 std::vector<const EnumValueDescriptor*> canonical_values_; |
77 | 76 |
78 struct Alias { | 77 struct Alias { |
79 const EnumValueDescriptor* value; | 78 const EnumValueDescriptor* value; |
80 const EnumValueDescriptor* canonical_value; | 79 const EnumValueDescriptor* canonical_value; |
81 }; | 80 }; |
82 vector<Alias> aliases_; | 81 std::vector<Alias> aliases_; |
83 | 82 |
84 bool immutable_api_; | 83 bool immutable_api_; |
85 | 84 |
86 Context* context_; | 85 Context* context_; |
87 ClassNameResolver* name_resolver_; | 86 ClassNameResolver* name_resolver_; |
88 | 87 |
89 bool CanUseEnumValues(); | 88 bool CanUseEnumValues(); |
90 | 89 |
91 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumLiteGenerator); | 90 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumLiteGenerator); |
92 }; | 91 }; |
93 | 92 |
94 } // namespace java | 93 } // namespace java |
95 } // namespace compiler | 94 } // namespace compiler |
96 } // namespace protobuf | 95 } // namespace protobuf |
97 | 96 |
98 } // namespace google | 97 } // namespace google |
99 #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_LITE_H__ | 98 #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_LITE_H__ |
OLD | NEW |