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_MESSAGE_H__
0009 #define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MESSAGE_H__
0010 
0011 #include <cstddef>
0012 #include <memory>
0013 #include <string>
0014 #include <vector>
0015 
0016 #include "absl/container/btree_set.h"
0017 #include "absl/container/flat_hash_set.h"
0018 #include "google/protobuf/compiler/objectivec/field.h"
0019 #include "google/protobuf/compiler/objectivec/oneof.h"
0020 #include "google/protobuf/compiler/objectivec/options.h"
0021 #include "google/protobuf/descriptor.h"
0022 #include "google/protobuf/io/printer.h"
0023 
0024 namespace google {
0025 namespace protobuf {
0026 namespace compiler {
0027 namespace objectivec {
0028 
0029 class ExtensionGenerator;
0030 
0031 class MessageGenerator {
0032  public:
0033   MessageGenerator(const std::string& file_description_name,
0034                    const Descriptor* descriptor,
0035                    const GenerationOptions& generation_options);
0036   ~MessageGenerator() = default;
0037 
0038   MessageGenerator(const MessageGenerator&) = delete;
0039   MessageGenerator& operator=(const MessageGenerator&) = delete;
0040 
0041   void AddExtensionGenerators(
0042       std::vector<std::unique_ptr<ExtensionGenerator>>* extension_generators);
0043 
0044   void GenerateMessageHeader(io::Printer* printer) const;
0045   void GenerateSource(io::Printer* printer) const;
0046   void DetermineObjectiveCClassDefinitions(
0047       absl::btree_set<std::string>* fwd_decls) const;
0048   void DetermineForwardDeclarations(absl::btree_set<std::string>* fwd_decls,
0049                                     bool include_external_types) const;
0050   void DetermineNeededFiles(
0051       absl::flat_hash_set<const FileDescriptor*>* deps) const;
0052 
0053   // Checks if the message or a nested message includes a oneof definition.
0054   bool IncludesOneOfDefinition() const { return !oneof_generators_.empty(); }
0055 
0056  private:
0057   const std::string file_description_name_;
0058   const Descriptor* descriptor_;
0059   const GenerationOptions& generation_options_;
0060   FieldGeneratorMap field_generators_;
0061   const std::string class_name_;
0062   const std::string deprecated_attribute_;
0063   std::vector<const ExtensionGenerator*> extension_generators_;
0064   std::vector<std::unique_ptr<OneofGenerator>> oneof_generators_;
0065   size_t sizeof_has_storage_;
0066 };
0067 
0068 }  // namespace objectivec
0069 }  // namespace compiler
0070 }  // namespace protobuf
0071 }  // namespace google
0072 
0073 #endif  // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MESSAGE_H__