• 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 // Generates ObjectiveC code for a given .proto file.
9 
10 #ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_GENERATOR_H__
11 #define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_GENERATOR_H__
12 
13 #include <cstdint>
14 #include <string>
15 #include <vector>
16 
17 #include "google/protobuf/compiler/code_generator.h"
18 #include "google/protobuf/descriptor.h"
19 #include "google/protobuf/descriptor.pb.h"
20 
21 // Must be included last
22 #include "google/protobuf/port_def.inc"
23 
24 namespace google {
25 namespace protobuf {
26 namespace compiler {
27 namespace objectivec {
28 
29 // CodeGenerator implementation which generates a ObjectiveC source file and
30 // header.  If you create your own protocol compiler binary and you want it to
31 // support ObjectiveC output, you can do so by registering an instance of this
32 // CodeGenerator with the CommandLineInterface in your main() function.
33 class PROTOC_EXPORT ObjectiveCGenerator : public CodeGenerator {
34  public:
35   ObjectiveCGenerator() = default;
36   ~ObjectiveCGenerator() override = default;
37 
38   ObjectiveCGenerator(const ObjectiveCGenerator&) = delete;
39   ObjectiveCGenerator& operator=(const ObjectiveCGenerator&) = delete;
40 
41   // implements CodeGenerator ----------------------------------------
42   bool HasGenerateAll() const override;
43   bool Generate(const FileDescriptor* file, const std::string& parameter,
44                 GeneratorContext* context, std::string* error) const override;
45   bool GenerateAll(const std::vector<const FileDescriptor*>& files,
46                    const std::string& parameter, GeneratorContext* context,
47                    std::string* error) const override;
48 
GetSupportedFeatures()49   uint64_t GetSupportedFeatures() const override {
50     return (FEATURE_PROTO3_OPTIONAL | FEATURE_SUPPORTS_EDITIONS);
51   }
GetMinimumEdition()52   Edition GetMinimumEdition() const override { return Edition::EDITION_PROTO2; }
GetMaximumEdition()53   Edition GetMaximumEdition() const override { return Edition::EDITION_2023; }
54 };
55 
56 }  // namespace objectivec
57 }  // namespace compiler
58 }  // namespace protobuf
59 }  // namespace google
60 
61 #include "google/protobuf/port_undef.inc"
62 
63 #endif  // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_GENERATOR_H__
64