Warning, file /include/google/protobuf/compiler/cpp/generator.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__
0015 #define GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__
0016
0017 #include <cstdint>
0018 #include <string>
0019 #include <utility>
0020 #include <vector>
0021
0022 #include "absl/status/status.h"
0023 #include "absl/strings/string_view.h"
0024 #include "google/protobuf/compiler/code_generator.h"
0025 #include "google/protobuf/cpp_features.pb.h"
0026 #include "google/protobuf/descriptor.pb.h"
0027 #include "google/protobuf/port.h"
0028
0029
0030 #include "google/protobuf/port_def.inc"
0031
0032 namespace google {
0033 namespace protobuf {
0034 namespace compiler {
0035 namespace cpp {
0036
0037 struct Options;
0038
0039
0040
0041
0042
0043 class PROTOC_EXPORT CppGenerator final : public CodeGenerator {
0044 public:
0045 CppGenerator() = default;
0046 CppGenerator(const CppGenerator&) = delete;
0047 CppGenerator& operator=(const CppGenerator&) = delete;
0048 ~CppGenerator() override = default;
0049
0050 enum class Runtime {
0051 kGoogle3,
0052 kOpensource,
0053
0054
0055
0056
0057 kOpensourceGoogle3
0058 };
0059
0060 void set_opensource_runtime(bool opensource) {
0061 opensource_runtime_ = opensource;
0062 }
0063
0064
0065
0066
0067
0068
0069 void set_runtime_include_base(std::string base) {
0070 runtime_include_base_ = std::move(base);
0071 }
0072
0073 bool Generate(const FileDescriptor* file, const std::string& parameter,
0074 GeneratorContext* generator_context,
0075 std::string* error) const override;
0076
0077 bool GenerateAll(const std::vector<const FileDescriptor*>& files,
0078 const std::string& parameter,
0079 GeneratorContext* generator_context,
0080 std::string* error) const override;
0081
0082 uint64_t GetSupportedFeatures() const override {
0083 return FEATURE_PROTO3_OPTIONAL | FEATURE_SUPPORTS_EDITIONS;
0084 }
0085
0086 Edition GetMinimumEdition() const override { return Edition::EDITION_PROTO2; }
0087 Edition GetMaximumEdition() const override {
0088 return Edition::EDITION_2024;
0089 }
0090
0091 std::vector<const FieldDescriptor*> GetFeatureExtensions() const override {
0092 return {GetExtensionReflection(pb::cpp)};
0093 }
0094
0095 using CodeGenerator::GetEdition;
0096 using CodeGenerator::GetResolvedSourceFeatures;
0097
0098 private:
0099 bool GenerateImpl(const FileDescriptor* file, const std::string& parameter,
0100 GeneratorContext* generator_context, std::string* error,
0101 const Options& file_options) const;
0102 bool opensource_runtime_ = google::protobuf::internal::IsOss();
0103 std::string runtime_include_base_;
0104
0105 absl::Status ValidateFeatures(const FileDescriptor* file) const;
0106 };
0107 }
0108 }
0109 }
0110 }
0111
0112 #include "google/protobuf/port_undef.inc"
0113
0114 #endif