Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:11:59

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 #ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_IMPORT_WRITER_H__
0009 #define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_IMPORT_WRITER_H__
0010 
0011 #include <string>
0012 #include <vector>
0013 
0014 #include "absl/container/flat_hash_map.h"
0015 #include "google/protobuf/descriptor.h"
0016 
0017 namespace google {
0018 namespace protobuf {
0019 namespace compiler {
0020 namespace objectivec {
0021 
0022 // Helper class for parsing framework import mappings and generating
0023 // import statements.
0024 class ImportWriter {
0025  public:
0026   ImportWriter(const std::string& generate_for_named_framework,
0027                const std::string& named_framework_to_proto_path_mappings_path,
0028                const std::string& runtime_import_prefix,
0029                bool for_bundled_proto);
0030   ~ImportWriter() = default;
0031 
0032   void AddFile(const FileDescriptor* file, const std::string& header_extension);
0033   void AddRuntimeImport(const std::string& header_name);
0034   // This can return an empty string if there is no module for the file. It also
0035   // does not handle bundled proto files.
0036   std::string ModuleForFile(const FileDescriptor* file);
0037 
0038   void PrintFileImports(io::Printer* p) const;
0039   void PrintRuntimeImports(io::Printer* p, bool default_cpp_symbol) const;
0040 
0041  private:
0042   void ParseFrameworkMappings();
0043 
0044   const std::string generate_for_named_framework_;
0045   const std::string named_framework_to_proto_path_mappings_path_;
0046   const std::string runtime_import_prefix_;
0047   absl::flat_hash_map<std::string, std::string> proto_file_to_framework_name_;
0048   bool for_bundled_proto_;
0049   bool need_to_parse_mapping_file_;
0050 
0051   std::vector<std::string> protobuf_imports_;
0052   std::vector<std::string> other_framework_imports_;
0053   std::vector<std::string> other_imports_;
0054 };
0055 
0056 }  // namespace objectivec
0057 }  // namespace compiler
0058 }  // namespace protobuf
0059 }  // namespace google
0060 
0061 #endif  // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_IMPORT_WRITER_H__