• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_MESSAGE_FIELD_H__
9 #define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MESSAGE_FIELD_H__
10 
11 #include <string>
12 
13 #include "absl/container/btree_set.h"
14 #include "absl/container/flat_hash_set.h"
15 #include "google/protobuf/compiler/objectivec/field.h"
16 #include "google/protobuf/compiler/objectivec/options.h"
17 #include "google/protobuf/descriptor.h"
18 
19 namespace google {
20 namespace protobuf {
21 namespace compiler {
22 namespace objectivec {
23 
24 class MessageFieldGenerator : public ObjCObjFieldGenerator {
25   friend FieldGenerator* FieldGenerator::Make(
26       const FieldDescriptor* field,
27       const GenerationOptions& generation_options);
28 
29  protected:
30   MessageFieldGenerator(const FieldDescriptor* descriptor,
31                         const GenerationOptions& generation_options);
32   ~MessageFieldGenerator() override = default;
33 
34   MessageFieldGenerator(const MessageFieldGenerator&) = delete;
35   MessageFieldGenerator& operator=(const MessageFieldGenerator&) = delete;
36 
37  public:
38   void DetermineForwardDeclarations(absl::btree_set<std::string>* fwd_decls,
39                                     bool include_external_types) const override;
40   void DetermineObjectiveCClassDefinitions(
41       absl::btree_set<std::string>* fwd_decls) const override;
42   void DetermineNeededFiles(
43       absl::flat_hash_set<const FileDescriptor*>* deps) const override;
44 };
45 
46 class RepeatedMessageFieldGenerator : public RepeatedFieldGenerator {
47   friend FieldGenerator* FieldGenerator::Make(
48       const FieldDescriptor* field,
49       const GenerationOptions& generation_options);
50 
51  protected:
52   RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor,
53                                 const GenerationOptions& generation_options);
54   ~RepeatedMessageFieldGenerator() override = default;
55 
56   RepeatedMessageFieldGenerator(const RepeatedMessageFieldGenerator&) = delete;
57   RepeatedMessageFieldGenerator operator=(
58       const RepeatedMessageFieldGenerator&) = delete;
59 
60  public:
61   void DetermineForwardDeclarations(absl::btree_set<std::string>* fwd_decls,
62                                     bool include_external_types) const override;
63   void DetermineObjectiveCClassDefinitions(
64       absl::btree_set<std::string>* fwd_decls) const override;
65   void DetermineNeededFiles(
66       absl::flat_hash_set<const FileDescriptor*>* deps) const override;
67 };
68 
69 }  // namespace objectivec
70 }  // namespace compiler
71 }  // namespace protobuf
72 }  // namespace google
73 
74 #endif  // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MESSAGE_FIELD_H__
75