File indexing completed on 2025-01-31 10:11:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_LITE_H__
0013 #define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_LITE_H__
0014
0015 #include <cstdint>
0016 #include <string>
0017
0018 #include "absl/container/flat_hash_map.h"
0019 #include "google/protobuf/compiler/java/lite/field_generator.h"
0020 #include "google/protobuf/descriptor.h"
0021
0022 namespace google {
0023 namespace protobuf {
0024 namespace compiler {
0025 namespace java {
0026 class Context;
0027 class ClassNameResolver;
0028 }
0029 }
0030 }
0031 }
0032
0033 namespace google {
0034 namespace protobuf {
0035 namespace compiler {
0036 namespace java {
0037
0038 class ImmutableEnumFieldLiteGenerator : public ImmutableFieldLiteGenerator {
0039 public:
0040 explicit ImmutableEnumFieldLiteGenerator(const FieldDescriptor* descriptor,
0041 int messageBitIndex,
0042 Context* context);
0043 ImmutableEnumFieldLiteGenerator(const ImmutableEnumFieldLiteGenerator&) =
0044 delete;
0045 ImmutableEnumFieldLiteGenerator& operator=(
0046 const ImmutableEnumFieldLiteGenerator&) = delete;
0047 ~ImmutableEnumFieldLiteGenerator() override;
0048
0049
0050
0051 int GetNumBitsForMessage() const override;
0052 void GenerateInterfaceMembers(io::Printer* printer) const override;
0053 void GenerateMembers(io::Printer* printer) const override;
0054 void GenerateBuilderMembers(io::Printer* printer) const override;
0055 void GenerateInitializationCode(io::Printer* printer) const override;
0056 void GenerateFieldInfo(io::Printer* printer,
0057 std::vector<uint16_t>* output) const override;
0058 void GenerateKotlinDslMembers(io::Printer* printer) const override;
0059
0060 std::string GetBoxedType() const override;
0061
0062 protected:
0063 const FieldDescriptor* descriptor_;
0064 absl::flat_hash_map<absl::string_view, std::string> variables_;
0065 const int messageBitIndex_;
0066 Context* context_;
0067 ClassNameResolver* name_resolver_;
0068 };
0069
0070 class ImmutableEnumOneofFieldLiteGenerator
0071 : public ImmutableEnumFieldLiteGenerator {
0072 public:
0073 ImmutableEnumOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
0074 int messageBitIndex, Context* context);
0075 ImmutableEnumOneofFieldLiteGenerator(
0076 const ImmutableEnumOneofFieldLiteGenerator&) = delete;
0077 ImmutableEnumOneofFieldLiteGenerator& operator=(
0078 const ImmutableEnumOneofFieldLiteGenerator&) = delete;
0079 ~ImmutableEnumOneofFieldLiteGenerator() override;
0080
0081 void GenerateMembers(io::Printer* printer) const override;
0082 void GenerateBuilderMembers(io::Printer* printer) const override;
0083 void GenerateFieldInfo(io::Printer* printer,
0084 std::vector<uint16_t>* output) const override;
0085 };
0086
0087 class RepeatedImmutableEnumFieldLiteGenerator
0088 : public ImmutableFieldLiteGenerator {
0089 public:
0090 explicit RepeatedImmutableEnumFieldLiteGenerator(
0091 const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
0092 RepeatedImmutableEnumFieldLiteGenerator(
0093 const RepeatedImmutableEnumFieldLiteGenerator&) = delete;
0094 RepeatedImmutableEnumFieldLiteGenerator& operator=(
0095 const RepeatedImmutableEnumFieldLiteGenerator&) = delete;
0096 ~RepeatedImmutableEnumFieldLiteGenerator() override;
0097
0098
0099 int GetNumBitsForMessage() const override;
0100 void GenerateInterfaceMembers(io::Printer* printer) const override;
0101 void GenerateMembers(io::Printer* printer) const override;
0102 void GenerateBuilderMembers(io::Printer* printer) const override;
0103 void GenerateInitializationCode(io::Printer* printer) const override;
0104 void GenerateFieldInfo(io::Printer* printer,
0105 std::vector<uint16_t>* output) const override;
0106 void GenerateKotlinDslMembers(io::Printer* printer) const override;
0107
0108 std::string GetBoxedType() const override;
0109
0110 private:
0111 const FieldDescriptor* descriptor_;
0112 absl::flat_hash_map<absl::string_view, std::string> variables_;
0113 Context* context_;
0114 ClassNameResolver* name_resolver_;
0115 };
0116
0117 }
0118 }
0119 }
0120 }
0121
0122 #endif