1 // Protocol Buffers - Google's data interchange format 2 // Copyright 2008 Google Inc. All rights reserved. 3 // 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file or at 6 // https://developers.google.com/open-source/licenses/bsd 7 8 #ifndef GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_GENERATORS_GENERATORS_H__ 9 #define GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_GENERATORS_GENERATORS_H__ 10 11 #include <memory> 12 13 #include "google/protobuf/compiler/cpp/field.h" 14 #include "google/protobuf/compiler/cpp/helpers.h" 15 #include "google/protobuf/compiler/cpp/options.h" 16 #include "google/protobuf/descriptor.h" 17 18 // The functions in this file construct FieldGeneratorBase objects for 19 // generating different "codegen types" of fields. The logic for selecting the 20 // correct choice of generator lives in compiler/cpp/field.cc; this is merely 21 // the API that file uses for constructing generators. 22 // 23 // Functions are of the form `Make<card><kind>Generator()`, where <card> is 24 // `Singular`, `Repeated`, or `Oneof`, and <kind> is the field type, plus 25 // `MakeMapGenerator()`, since map fields are always repeated message fields. 26 // 27 // The returned pointers are never null. 28 29 namespace google { 30 namespace protobuf { 31 namespace compiler { 32 namespace cpp { 33 std::unique_ptr<FieldGeneratorBase> MakeSinguarPrimitiveGenerator( 34 const FieldDescriptor* desc, const Options& options, 35 MessageSCCAnalyzer* scc); 36 37 std::unique_ptr<FieldGeneratorBase> MakeRepeatedPrimitiveGenerator( 38 const FieldDescriptor* desc, const Options& options, 39 MessageSCCAnalyzer* scc); 40 41 std::unique_ptr<FieldGeneratorBase> MakeSinguarEnumGenerator( 42 const FieldDescriptor* desc, const Options& options, 43 MessageSCCAnalyzer* scc); 44 45 std::unique_ptr<FieldGeneratorBase> MakeRepeatedEnumGenerator( 46 const FieldDescriptor* desc, const Options& options, 47 MessageSCCAnalyzer* scc); 48 49 std::unique_ptr<FieldGeneratorBase> MakeSinguarStringGenerator( 50 const FieldDescriptor* desc, const Options& options, 51 MessageSCCAnalyzer* scc); 52 53 std::unique_ptr<FieldGeneratorBase> MakeRepeatedStringGenerator( 54 const FieldDescriptor* desc, const Options& options, 55 MessageSCCAnalyzer* scc); 56 57 std::unique_ptr<FieldGeneratorBase> MakeSingularStringViewGenerator( 58 const FieldDescriptor* desc, const Options& options, 59 MessageSCCAnalyzer* scc); 60 61 std::unique_ptr<FieldGeneratorBase> MakeRepeatedStringViewGenerator( 62 const FieldDescriptor* desc, const Options& options, 63 MessageSCCAnalyzer* scc); 64 65 std::unique_ptr<FieldGeneratorBase> MakeSinguarMessageGenerator( 66 const FieldDescriptor* desc, const Options& options, 67 MessageSCCAnalyzer* scc); 68 69 std::unique_ptr<FieldGeneratorBase> MakeRepeatedMessageGenerator( 70 const FieldDescriptor* desc, const Options& options, 71 MessageSCCAnalyzer* scc); 72 73 std::unique_ptr<FieldGeneratorBase> MakeOneofMessageGenerator( 74 const FieldDescriptor* desc, const Options& options, 75 MessageSCCAnalyzer* scc); 76 77 std::unique_ptr<FieldGeneratorBase> MakeMapGenerator( 78 const FieldDescriptor* desc, const Options& options, 79 MessageSCCAnalyzer* scc); 80 81 std::unique_ptr<FieldGeneratorBase> MakeSingularCordGenerator( 82 const FieldDescriptor* desc, const Options& options, 83 MessageSCCAnalyzer* scc); 84 85 std::unique_ptr<FieldGeneratorBase> MakeOneofCordGenerator( 86 const FieldDescriptor* desc, const Options& options, 87 MessageSCCAnalyzer* scc); 88 89 } // namespace cpp 90 } // namespace compiler 91 } // namespace protobuf 92 } // namespace google 93 94 #endif // GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_GENERATORS_GENERATORS_H__ 95