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_PRIMITIVE_FIELD_LITE_H__
0013 #define GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_LITE_H__
0014
0015 #include <cstdint>
0016 #include <string>
0017 #include <vector>
0018
0019 #include "absl/container/flat_hash_map.h"
0020 #include "absl/strings/string_view.h"
0021 #include "google/protobuf/compiler/java/lite/field_generator.h"
0022 #include "google/protobuf/descriptor.h"
0023
0024 namespace google {
0025 namespace protobuf {
0026 namespace compiler {
0027 namespace java {
0028 class Context;
0029 class ClassNameResolver;
0030 }
0031 }
0032 }
0033 }
0034
0035 namespace google {
0036 namespace protobuf {
0037 namespace compiler {
0038 namespace java {
0039
0040 class ImmutablePrimitiveFieldLiteGenerator
0041 : public ImmutableFieldLiteGenerator {
0042 public:
0043 explicit ImmutablePrimitiveFieldLiteGenerator(
0044 const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
0045 ImmutablePrimitiveFieldLiteGenerator(
0046 const ImmutablePrimitiveFieldLiteGenerator&) = delete;
0047 ImmutablePrimitiveFieldLiteGenerator& operator=(
0048 const ImmutablePrimitiveFieldLiteGenerator&) = delete;
0049 ~ImmutablePrimitiveFieldLiteGenerator() override;
0050
0051
0052
0053 int GetNumBitsForMessage() 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 GenerateFieldInfo(io::Printer* printer,
0059 std::vector<uint16_t>* output) const override;
0060 void GenerateKotlinDslMembers(io::Printer* printer) const override;
0061
0062 std::string GetBoxedType() const override;
0063
0064 protected:
0065 const FieldDescriptor* descriptor_;
0066 absl::flat_hash_map<absl::string_view, std::string> variables_;
0067 const int messageBitIndex_;
0068 Context* context_;
0069 ClassNameResolver* name_resolver_;
0070 };
0071
0072 class ImmutablePrimitiveOneofFieldLiteGenerator
0073 : public ImmutablePrimitiveFieldLiteGenerator {
0074 public:
0075 ImmutablePrimitiveOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
0076 int messageBitIndex,
0077 Context* context);
0078 ImmutablePrimitiveOneofFieldLiteGenerator(
0079 const ImmutablePrimitiveOneofFieldLiteGenerator&) = delete;
0080 ImmutablePrimitiveOneofFieldLiteGenerator& operator=(
0081 const ImmutablePrimitiveOneofFieldLiteGenerator&) = delete;
0082 ~ImmutablePrimitiveOneofFieldLiteGenerator() override;
0083
0084 void GenerateMembers(io::Printer* printer) const override;
0085 void GenerateBuilderMembers(io::Printer* printer) const override;
0086
0087 void GenerateFieldInfo(io::Printer* printer,
0088 std::vector<uint16_t>* output) const override;
0089 };
0090
0091 class RepeatedImmutablePrimitiveFieldLiteGenerator
0092 : public ImmutableFieldLiteGenerator {
0093 public:
0094 explicit RepeatedImmutablePrimitiveFieldLiteGenerator(
0095 const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
0096 RepeatedImmutablePrimitiveFieldLiteGenerator(
0097 const RepeatedImmutablePrimitiveFieldLiteGenerator&) = delete;
0098 RepeatedImmutablePrimitiveFieldLiteGenerator& operator=(
0099 const RepeatedImmutablePrimitiveFieldLiteGenerator&) = delete;
0100 ~RepeatedImmutablePrimitiveFieldLiteGenerator() override;
0101
0102
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 }
0122 }
0123 }
0124 }
0125
0126 #endif