Back to home page

EIC code displayed by LXR

 
 

    


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

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 // Author: kenton@google.com (Kenton Varda)
0009 //  Based on original Protocol Buffers design by
0010 //  Sanjay Ghemawat, Jeff Dean, and others.
0011 //
0012 // Generates Java code for a given .proto file.
0013 
0014 #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__
0015 #define GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__
0016 
0017 #include <cstdint>
0018 #include <string>
0019 #include <vector>
0020 
0021 #include "google/protobuf/compiler/java/java_features.pb.h"
0022 #include "google/protobuf/compiler/code_generator.h"
0023 #include "google/protobuf/descriptor.pb.h"
0024 #include "google/protobuf/port.h"
0025 
0026 // Must be included last.
0027 #include "google/protobuf/port_def.inc"
0028 
0029 namespace google {
0030 namespace protobuf {
0031 namespace compiler {
0032 namespace java {
0033 
0034 // CodeGenerator implementation which generates Java code.  If you create your
0035 // own protocol compiler binary and you want it to support Java output, you
0036 // can do so by registering an instance of this CodeGenerator with the
0037 // CommandLineInterface in your main() function.
0038 class PROTOC_EXPORT JavaGenerator : public CodeGenerator {
0039  public:
0040   JavaGenerator();
0041   JavaGenerator(const JavaGenerator&) = delete;
0042   JavaGenerator& operator=(const JavaGenerator&) = delete;
0043   ~JavaGenerator() override;
0044 
0045   // implements CodeGenerator ----------------------------------------
0046   bool Generate(const FileDescriptor* file, const std::string& parameter,
0047                 GeneratorContext* context, std::string* error) const override;
0048 
0049   uint64_t GetSupportedFeatures() const override;
0050 
0051   Edition GetMinimumEdition() const override { return Edition::EDITION_PROTO2; }
0052   Edition GetMaximumEdition() const override { return Edition::EDITION_2023; }
0053 
0054   std::vector<const FieldDescriptor*> GetFeatureExtensions() const override {
0055     return {GetExtensionReflection(pb::java)};
0056   }
0057 
0058   void set_opensource_runtime(bool opensource) {
0059     opensource_runtime_ = opensource;
0060   }
0061 
0062   using CodeGenerator::GetEdition;
0063   using CodeGenerator::GetResolvedSourceFeatures;
0064 
0065  private:
0066   bool opensource_runtime_ = google::protobuf::internal::IsOss();
0067 };
0068 
0069 }  // namespace java
0070 }  // namespace compiler
0071 }  // namespace protobuf
0072 }  // namespace google
0073 
0074 #include "google/protobuf/port_undef.inc"
0075 
0076 #endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__