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 // Author: jonp@google.com (Jon Perlow)
0010 //  Based on original Protocol Buffers design by
0011 //  Sanjay Ghemawat, Jeff Dean, and others.
0012 
0013 #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_LITE_H__
0014 #define GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_LITE_H__
0015 
0016 #include <cstdint>
0017 #include <string>
0018 #include <vector>
0019 
0020 #include "absl/container/flat_hash_map.h"
0021 #include "absl/strings/string_view.h"
0022 #include "google/protobuf/compiler/java/lite/field_generator.h"
0023 #include "google/protobuf/descriptor.h"
0024 
0025 namespace google {
0026 namespace protobuf {
0027 namespace compiler {
0028 namespace java {
0029 class Context;            // context.h
0030 class ClassNameResolver;  // name_resolver.h
0031 }  // namespace java
0032 }  // namespace compiler
0033 }  // namespace protobuf
0034 }  // namespace google
0035 
0036 namespace google {
0037 namespace protobuf {
0038 namespace compiler {
0039 namespace java {
0040 
0041 class ImmutableStringFieldLiteGenerator : public ImmutableFieldLiteGenerator {
0042  public:
0043   explicit ImmutableStringFieldLiteGenerator(const FieldDescriptor* descriptor,
0044                                              int messageBitIndex,
0045                                              Context* context);
0046   ImmutableStringFieldLiteGenerator(const ImmutableStringFieldLiteGenerator&) =
0047       delete;
0048   ImmutableStringFieldLiteGenerator& operator=(
0049       const ImmutableStringFieldLiteGenerator&) = delete;
0050   ~ImmutableStringFieldLiteGenerator() override;
0051 
0052   // implements ImmutableFieldLiteGenerator
0053   // ------------------------------------
0054   int GetNumBitsForMessage() const override;
0055   void GenerateInterfaceMembers(io::Printer* printer) const override;
0056   void GenerateMembers(io::Printer* printer) const override;
0057   void GenerateBuilderMembers(io::Printer* printer) const override;
0058   void GenerateInitializationCode(io::Printer* printer) const override;
0059   void GenerateFieldInfo(io::Printer* printer,
0060                          std::vector<uint16_t>* output) const override;
0061   void GenerateKotlinDslMembers(io::Printer* printer) const override;
0062 
0063   std::string GetBoxedType() const override;
0064 
0065  protected:
0066   const FieldDescriptor* descriptor_;
0067   absl::flat_hash_map<absl::string_view, std::string> variables_;
0068   const int messageBitIndex_;
0069   ClassNameResolver* name_resolver_;
0070   Context* context_;
0071 };
0072 
0073 class ImmutableStringOneofFieldLiteGenerator
0074     : public ImmutableStringFieldLiteGenerator {
0075  public:
0076   ImmutableStringOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
0077                                          int messageBitIndex, Context* context);
0078   ImmutableStringOneofFieldLiteGenerator(
0079       const ImmutableStringOneofFieldLiteGenerator&) = delete;
0080   ImmutableStringOneofFieldLiteGenerator& operator=(
0081       const ImmutableStringOneofFieldLiteGenerator&) = delete;
0082   ~ImmutableStringOneofFieldLiteGenerator() override;
0083 
0084  private:
0085   void GenerateMembers(io::Printer* printer) const override;
0086   void GenerateBuilderMembers(io::Printer* printer) const override;
0087   void GenerateFieldInfo(io::Printer* printer,
0088                          std::vector<uint16_t>* output) const override;
0089 };
0090 
0091 class RepeatedImmutableStringFieldLiteGenerator
0092     : public ImmutableFieldLiteGenerator {
0093  public:
0094   explicit RepeatedImmutableStringFieldLiteGenerator(
0095       const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
0096   RepeatedImmutableStringFieldLiteGenerator(
0097       const RepeatedImmutableStringFieldLiteGenerator&) = delete;
0098   RepeatedImmutableStringFieldLiteGenerator& operator=(
0099       const RepeatedImmutableStringFieldLiteGenerator&) = delete;
0100   ~RepeatedImmutableStringFieldLiteGenerator() override;
0101 
0102   // implements ImmutableFieldLiteGenerator ------------------------------------
0103   int GetNumBitsForMessage() const override;
0104   void GenerateInterfaceMembers(io::Printer* printer) const override;
0105   void GenerateMembers(io::Printer* printer) const override;
0106   void GenerateBuilderMembers(io::Printer* printer) const override;
0107   void GenerateInitializationCode(io::Printer* printer) const override;
0108   void GenerateFieldInfo(io::Printer* printer,
0109                          std::vector<uint16_t>* output) const override;
0110   void GenerateKotlinDslMembers(io::Printer* printer) const override;
0111 
0112   std::string GetBoxedType() const override;
0113 
0114  private:
0115   const FieldDescriptor* descriptor_;
0116   absl::flat_hash_map<absl::string_view, std::string> variables_;
0117   Context* context_;
0118   ClassNameResolver* name_resolver_;
0119 };
0120 
0121 }  // namespace java
0122 }  // namespace compiler
0123 }  // namespace protobuf
0124 }  // namespace google
0125 
0126 #endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_LITE_H__