1 // Protocol Buffers - Google's data interchange format 2 // Copyright 2015 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_MAP_FIELD_H__ 9 #define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MAP_FIELD_H__ 10 11 #include <memory> 12 #include <string> 13 14 #include "absl/container/btree_set.h" 15 #include "absl/container/flat_hash_set.h" 16 #include "google/protobuf/compiler/objectivec/field.h" 17 #include "google/protobuf/compiler/objectivec/options.h" 18 #include "google/protobuf/descriptor.h" 19 20 namespace google { 21 namespace protobuf { 22 namespace compiler { 23 namespace objectivec { 24 25 class MapFieldGenerator : public RepeatedFieldGenerator { 26 friend FieldGenerator* FieldGenerator::Make( 27 const FieldDescriptor* field, 28 const GenerationOptions& generation_options); 29 30 public: 31 void EmitArrayComment(io::Printer* printer) const override; 32 33 MapFieldGenerator(const MapFieldGenerator&) = delete; 34 MapFieldGenerator& operator=(const MapFieldGenerator&) = delete; 35 36 protected: 37 MapFieldGenerator(const FieldDescriptor* descriptor, 38 const GenerationOptions& generation_options); 39 ~MapFieldGenerator() override = default; 40 41 void DetermineObjectiveCClassDefinitions( 42 absl::btree_set<std::string>* fwd_decls) const override; 43 void DetermineForwardDeclarations(absl::btree_set<std::string>* fwd_decls, 44 bool include_external_types) const override; 45 void DetermineNeededFiles( 46 absl::flat_hash_set<const FileDescriptor*>* deps) const override; 47 48 private: 49 std::unique_ptr<FieldGenerator> value_field_generator_; 50 }; 51 52 } // namespace objectivec 53 } // namespace compiler 54 } // namespace protobuf 55 } // namespace google 56 57 #endif // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MAP_FIELD_H__ 58