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_PRIMITIVE_FIELD_H__
0013 #define GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_H__
0014 
0015 #include <string>
0016 
0017 #include "google/protobuf/compiler/java/full/field_generator.h"
0018 #include "google/protobuf/descriptor.h"
0019 
0020 namespace google {
0021 namespace protobuf {
0022 namespace compiler {
0023 namespace java {
0024 class Context;            // context.h
0025 class ClassNameResolver;  // name_resolver.h
0026 }  // namespace java
0027 }  // namespace compiler
0028 }  // namespace protobuf
0029 }  // namespace google
0030 
0031 namespace google {
0032 namespace protobuf {
0033 namespace compiler {
0034 namespace java {
0035 
0036 class ImmutablePrimitiveFieldGenerator : public ImmutableFieldGenerator {
0037  public:
0038   explicit ImmutablePrimitiveFieldGenerator(const FieldDescriptor* descriptor,
0039                                             int messageBitIndex,
0040                                             int builderBitIndex,
0041                                             Context* context);
0042   ImmutablePrimitiveFieldGenerator(const ImmutablePrimitiveFieldGenerator&) =
0043       delete;
0044   ImmutablePrimitiveFieldGenerator& operator=(
0045       const ImmutablePrimitiveFieldGenerator&) = delete;
0046   ~ImmutablePrimitiveFieldGenerator() 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 GenerateMergingCode(io::Printer* printer) const override;
0060   void GenerateBuildingCode(io::Printer* printer) const override;
0061   void GenerateBuilderParsingCode(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 ImmutablePrimitiveOneofFieldGenerator
0082     : public ImmutablePrimitiveFieldGenerator {
0083  public:
0084   ImmutablePrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor,
0085                                         int messageBitIndex,
0086                                         int builderBitIndex, Context* context);
0087   ImmutablePrimitiveOneofFieldGenerator(
0088       const ImmutablePrimitiveOneofFieldGenerator&) = delete;
0089   ImmutablePrimitiveOneofFieldGenerator& operator=(
0090       const ImmutablePrimitiveOneofFieldGenerator&) = delete;
0091   ~ImmutablePrimitiveOneofFieldGenerator() override;
0092 
0093   void GenerateMembers(io::Printer* printer) const override;
0094   void GenerateBuilderMembers(io::Printer* printer) const override;
0095   void GenerateBuilderClearCode(io::Printer* printer) const override;
0096   void GenerateBuildingCode(io::Printer* printer) const override;
0097   void GenerateMergingCode(io::Printer* printer) const override;
0098   void GenerateBuilderParsingCode(io::Printer* printer) const override;
0099   void GenerateSerializationCode(io::Printer* printer) const override;
0100   void GenerateSerializedSizeCode(io::Printer* printer) const override;
0101 };
0102 
0103 class RepeatedImmutablePrimitiveFieldGenerator
0104     : public ImmutablePrimitiveFieldGenerator {
0105  public:
0106   explicit RepeatedImmutablePrimitiveFieldGenerator(
0107       const FieldDescriptor* descriptor, int messageBitIndex,
0108       int builderBitIndex, Context* context);
0109   RepeatedImmutablePrimitiveFieldGenerator(
0110       const RepeatedImmutablePrimitiveFieldGenerator&) = delete;
0111   RepeatedImmutablePrimitiveFieldGenerator& operator=(
0112       const RepeatedImmutablePrimitiveFieldGenerator&) = delete;
0113   ~RepeatedImmutablePrimitiveFieldGenerator() 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_PRIMITIVE_FIELD_H__