• 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 Ruby code for a given .proto file.
9 
10 #ifndef GOOGLE_PROTOBUF_COMPILER_RUBY_GENERATOR_H__
11 #define GOOGLE_PROTOBUF_COMPILER_RUBY_GENERATOR_H__
12 
13 #include <string>
14 
15 #include "google/protobuf/compiler/code_generator.h"
16 #include "google/protobuf/port_def.inc"
17 
18 namespace google {
19 namespace protobuf {
20 namespace compiler {
21 namespace ruby {
22 
23 // CodeGenerator implementation for generated Ruby protocol buffer classes.
24 // If you create your own protocol compiler binary and you want it to support
25 // Ruby output, you can do so by registering an instance of this
26 // CodeGenerator with the CommandLineInterface in your main() function.
27 class PROTOC_EXPORT Generator : public CodeGenerator {
28   bool Generate(const FileDescriptor* file, const std::string& parameter,
29                 GeneratorContext* generator_context,
30                 std::string* error) const override;
GetSupportedFeatures()31   uint64_t GetSupportedFeatures() const override {
32     return Feature::FEATURE_PROTO3_OPTIONAL |
33            Feature::FEATURE_SUPPORTS_EDITIONS;
34   }
GetMinimumEdition()35   Edition GetMinimumEdition() const override { return Edition::EDITION_PROTO2; }
GetMaximumEdition()36   Edition GetMaximumEdition() const override { return Edition::EDITION_2023; }
37 };
38 
39 }  // namespace ruby
40 }  // namespace compiler
41 }  // namespace protobuf
42 }  // namespace google
43 
44 #include "google/protobuf/port_undef.inc"
45 
46 #endif  // GOOGLE_PROTOBUF_COMPILER_RUBY_GENERATOR_H__
47