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_OBJECTIVEC_EXTENSION_H__ 9 #define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_EXTENSION_H__ 10 11 #include <string> 12 13 #include "absl/container/btree_set.h" 14 #include "absl/container/flat_hash_set.h" 15 #include "absl/strings/string_view.h" 16 #include "google/protobuf/compiler/objectivec/options.h" 17 #include "google/protobuf/descriptor.h" 18 #include "google/protobuf/io/printer.h" 19 20 namespace google { 21 namespace protobuf { 22 namespace compiler { 23 namespace objectivec { 24 25 class ExtensionGenerator { 26 public: 27 ExtensionGenerator(absl::string_view root_or_message_class_name, 28 const FieldDescriptor* descriptor, 29 const GenerationOptions& generation_options); 30 ~ExtensionGenerator() = default; 31 32 ExtensionGenerator(const ExtensionGenerator&) = delete; 33 ExtensionGenerator& operator=(const ExtensionGenerator&) = delete; 34 35 void GenerateMembersHeader(io::Printer* printer) const; 36 void GenerateStaticVariablesInitialization(io::Printer* printer) const; 37 void DetermineObjectiveCClassDefinitions( 38 absl::btree_set<std::string>* fwd_decls) const; 39 void DetermineNeededFiles( 40 absl::flat_hash_set<const FileDescriptor*>* deps) const; 41 42 private: 43 std::string root_or_message_class_name_; 44 std::string method_name_; 45 const FieldDescriptor* descriptor_; 46 const GenerationOptions& generation_options_; 47 }; 48 49 } // namespace objectivec 50 } // namespace compiler 51 } // namespace protobuf 52 } // namespace google 53 54 #endif // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MESSAGE_H__ 55