Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:11:58

0001 // Protocol Buffers - Google's data interchange format
0002 // Copyright 2008 Google Inc.  All rights reserved.
0003 //
0004 // Use of this source code is governed by a BSD-style
0005 // license that can be found in the LICENSE file or at
0006 // https://developers.google.com/open-source/licenses/bsd
0007 
0008 // Author: kenton@google.com (Kenton Varda)
0009 //  Based on original Protocol Buffers design by
0010 //  Sanjay Ghemawat, Jeff Dean, and others.
0011 
0012 #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_LITE_H__
0013 #define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_LITE_H__
0014 
0015 #include <string>
0016 #include <vector>
0017 
0018 #include "google/protobuf/compiler/java/generator_factory.h"
0019 #include "google/protobuf/descriptor.h"
0020 
0021 namespace google {
0022 namespace protobuf {
0023 namespace compiler {
0024 namespace java {
0025 class Context;            // context.h
0026 class ClassNameResolver;  // name_resolver.h
0027 }  // namespace java
0028 }  // namespace compiler
0029 namespace io {
0030 class Printer;  // printer.h
0031 }
0032 }  // namespace protobuf
0033 }  // namespace google
0034 
0035 namespace google {
0036 namespace protobuf {
0037 namespace compiler {
0038 namespace java {
0039 
0040 class EnumLiteGenerator : public EnumGenerator {
0041  public:
0042   EnumLiteGenerator(const EnumDescriptor* descriptor, bool immutable_api,
0043                     Context* context);
0044   EnumLiteGenerator(const EnumLiteGenerator&) = delete;
0045   EnumLiteGenerator& operator=(const EnumLiteGenerator&) = delete;
0046   ~EnumLiteGenerator();
0047 
0048   void Generate(io::Printer* printer) override;
0049 
0050  private:
0051   const EnumDescriptor* descriptor_;
0052 
0053   // The proto language allows multiple enum constants to have the same
0054   // numeric value.  Java, however, does not allow multiple enum constants to
0055   // be considered equivalent.  We treat the first defined constant for any
0056   // given numeric value as "canonical" and the rest as aliases of that
0057   // canonical value.
0058   std::vector<const EnumValueDescriptor*> canonical_values_;
0059 
0060   struct Alias {
0061     const EnumValueDescriptor* value;
0062     const EnumValueDescriptor* canonical_value;
0063   };
0064   std::vector<Alias> aliases_;
0065 
0066   bool immutable_api_;
0067 
0068   Context* context_;
0069   ClassNameResolver* name_resolver_;
0070 };
0071 
0072 }  // namespace java
0073 }  // namespace compiler
0074 }  // namespace protobuf
0075 }  // namespace google
0076 
0077 #endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_LITE_H__