Back to home page

EIC code displayed by LXR

 
 

    


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

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_FIELD_H__
0013 #define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__
0014 
0015 #include <string>
0016 
0017 #include "absl/container/flat_hash_map.h"
0018 #include "google/protobuf/compiler/java/full/field_generator.h"
0019 #include "google/protobuf/descriptor.h"
0020 #include "google/protobuf/io/printer.h"
0021 
0022 namespace google {
0023 namespace protobuf {
0024 namespace compiler {
0025 namespace java {
0026 class Context;            // context.h
0027 class ClassNameResolver;  // name_resolver.h
0028 }  // namespace java
0029 }  // namespace compiler
0030 }  // namespace protobuf
0031 }  // namespace google
0032 
0033 namespace google {
0034 namespace protobuf {
0035 namespace compiler {
0036 namespace java {
0037 
0038 class ImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
0039  public:
0040   explicit ImmutableEnumFieldGenerator(const FieldDescriptor* descriptor,
0041                                        int messageBitIndex, int builderBitIndex,
0042                                        Context* context);
0043   ImmutableEnumFieldGenerator(const ImmutableEnumFieldGenerator&) = delete;
0044   ImmutableEnumFieldGenerator& operator=(const ImmutableEnumFieldGenerator&) =
0045       delete;
0046   ~ImmutableEnumFieldGenerator() override;
0047 
0048   // implements ImmutableFieldGenerator
0049   // ---------------------------------------
0050   int GetMessageBitIndex() const override;
0051   int GetBuilderBitIndex() const override;
0052   int GetNumBitsForMessage() const override;
0053   int GetNumBitsForBuilder() const override;
0054   void GenerateInterfaceMembers(io::Printer* printer) const override;
0055   void GenerateMembers(io::Printer* printer) const override;
0056   void GenerateBuilderMembers(io::Printer* printer) const override;
0057   void GenerateInitializationCode(io::Printer* printer) const override;
0058   void GenerateBuilderClearCode(io::Printer* printer) const override;
0059   void GenerateBuilderParsingCode(io::Printer* printer) const override;
0060   void GenerateMergingCode(io::Printer* printer) const override;
0061   void GenerateBuildingCode(io::Printer* printer) const override;
0062   void GenerateSerializationCode(io::Printer* printer) const override;
0063   void GenerateSerializedSizeCode(io::Printer* printer) const override;
0064   void GenerateFieldBuilderInitializationCode(
0065       io::Printer* printer) const override;
0066   void GenerateEqualsCode(io::Printer* printer) const override;
0067   void GenerateHashCode(io::Printer* printer) const override;
0068   void GenerateKotlinDslMembers(io::Printer* printer) const override;
0069 
0070   std::string GetBoxedType() const override;
0071 
0072  protected:
0073   const FieldDescriptor* descriptor_;
0074   int message_bit_index_;
0075   int builder_bit_index_;
0076   absl::flat_hash_map<absl::string_view, std::string> variables_;
0077   Context* context_;
0078   ClassNameResolver* name_resolver_;
0079 };
0080 
0081 class ImmutableEnumOneofFieldGenerator : public ImmutableEnumFieldGenerator {
0082  public:
0083   ImmutableEnumOneofFieldGenerator(const FieldDescriptor* descriptor,
0084                                    int messageBitIndex, int builderBitIndex,
0085                                    Context* context);
0086   ImmutableEnumOneofFieldGenerator(const ImmutableEnumOneofFieldGenerator&) =
0087       delete;
0088   ImmutableEnumOneofFieldGenerator& operator=(
0089       const ImmutableEnumOneofFieldGenerator&) = delete;
0090   ~ImmutableEnumOneofFieldGenerator() override;
0091 
0092   void GenerateMembers(io::Printer* printer) const override;
0093   void GenerateBuilderMembers(io::Printer* printer) const override;
0094   void GenerateBuilderClearCode(io::Printer* printer) const override;
0095   void GenerateMergingCode(io::Printer* printer) const override;
0096   void GenerateBuildingCode(io::Printer* printer) const override;
0097   void GenerateBuilderParsingCode(io::Printer* printer) const override;
0098   void GenerateSerializationCode(io::Printer* printer) const override;
0099   void GenerateSerializedSizeCode(io::Printer* printer) const override;
0100   void GenerateEqualsCode(io::Printer* printer) const override;
0101   void GenerateHashCode(io::Printer* printer) const override;
0102 };
0103 
0104 class RepeatedImmutableEnumFieldGenerator : public ImmutableEnumFieldGenerator {
0105  public:
0106   explicit RepeatedImmutableEnumFieldGenerator(
0107       const FieldDescriptor* descriptor, int messageBitIndex,
0108       int builderBitIndex, Context* context);
0109   RepeatedImmutableEnumFieldGenerator(
0110       const RepeatedImmutableEnumFieldGenerator&) = delete;
0111   RepeatedImmutableEnumFieldGenerator& operator=(
0112       const RepeatedImmutableEnumFieldGenerator&) = delete;
0113   ~RepeatedImmutableEnumFieldGenerator() override;
0114 
0115   // implements ImmutableFieldGenerator ---------------------------------------
0116   int GetNumBitsForMessage() const override;
0117   int GetNumBitsForBuilder() const override;
0118   void GenerateInterfaceMembers(io::Printer* printer) const override;
0119   void GenerateMembers(io::Printer* printer) const override;
0120   void GenerateBuilderMembers(io::Printer* printer) const override;
0121   void GenerateInitializationCode(io::Printer* printer) const override;
0122   void GenerateBuilderClearCode(io::Printer* printer) const override;
0123   void GenerateMergingCode(io::Printer* printer) const override;
0124   void GenerateBuildingCode(io::Printer* printer) const override;
0125   void GenerateBuilderParsingCode(io::Printer* printer) const override;
0126   void GenerateBuilderParsingCodeFromPacked(
0127       io::Printer* printer) const override;
0128   void GenerateSerializationCode(io::Printer* printer) const override;
0129   void GenerateSerializedSizeCode(io::Printer* printer) const override;
0130   void GenerateFieldBuilderInitializationCode(
0131       io::Printer* printer) const override;
0132   void GenerateEqualsCode(io::Printer* printer) const override;
0133   void GenerateHashCode(io::Printer* printer) const override;
0134   void GenerateKotlinDslMembers(io::Printer* printer) const override;
0135 
0136   std::string GetBoxedType() const override;
0137 };
0138 
0139 }  // namespace java
0140 }  // namespace compiler
0141 }  // namespace protobuf
0142 }  // namespace google
0143 
0144 #endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__