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: dweis@google.com (Daniel Weis)
0009 //  Based on original Protocol Buffers design by
0010 //  Sanjay Ghemawat, Jeff Dean, and others.
0011 
0012 #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_H__
0013 #define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_H__
0014 
0015 #include <memory>
0016 #include <string>
0017 #include <vector>
0018 
0019 #include "absl/container/btree_map.h"
0020 #include "google/protobuf/compiler/java/full/field_generator.h"
0021 #include "google/protobuf/descriptor.h"
0022 
0023 namespace google {
0024 namespace protobuf {
0025 namespace compiler {
0026 namespace java {
0027 class Context;            // context.h
0028 class ClassNameResolver;  // name_resolver.h
0029 }  // namespace java
0030 }  // namespace compiler
0031 namespace io {
0032 class Printer;  // printer.h
0033 }
0034 }  // namespace protobuf
0035 }  // namespace google
0036 
0037 namespace google {
0038 namespace protobuf {
0039 namespace compiler {
0040 namespace java {
0041 
0042 class MessageBuilderGenerator {
0043  public:
0044   explicit MessageBuilderGenerator(const Descriptor* descriptor,
0045                                    Context* context);
0046   MessageBuilderGenerator(const MessageBuilderGenerator&) = delete;
0047   MessageBuilderGenerator& operator=(const MessageBuilderGenerator&) = delete;
0048   virtual ~MessageBuilderGenerator();
0049 
0050   virtual void Generate(io::Printer* printer);
0051 
0052  private:
0053   void GenerateCommonBuilderMethods(io::Printer* printer);
0054   void GenerateBuildPartial(io::Printer* printer);
0055   int GenerateBuildPartialPiece(io::Printer* printer, int piece,
0056                                 int first_field);
0057   int GenerateBuildPartialPieceWithoutPresence(io::Printer* printer, int piece,
0058                                                int first_field);
0059   void GenerateDescriptorMethods(io::Printer* printer);
0060   void GenerateBuilderParsingMethods(io::Printer* printer);
0061   void GenerateBuilderFieldParsingCases(io::Printer* printer);
0062   void GenerateBuilderFieldParsingCase(io::Printer* printer,
0063                                        const FieldDescriptor* field);
0064   void GenerateBuilderPackedFieldParsingCase(io::Printer* printer,
0065                                              const FieldDescriptor* field);
0066   void GenerateIsInitialized(io::Printer* printer);
0067 
0068   const Descriptor* descriptor_;
0069   Context* context_;
0070   ClassNameResolver* name_resolver_;
0071   FieldGeneratorMap<ImmutableFieldGenerator> field_generators_;
0072   absl::btree_map<int, const OneofDescriptor*> oneofs_;
0073 };
0074 
0075 }  // namespace java
0076 }  // namespace compiler
0077 }  // namespace protobuf
0078 }  // namespace google
0079 
0080 #endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_H__