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_PHP_GENERATOR_H__ 9 #define GOOGLE_PROTOBUF_COMPILER_PHP_GENERATOR_H__ 10 11 #include <cstdint> 12 #include <string> 13 14 #include "google/protobuf/compiler/code_generator.h" 15 #include "google/protobuf/compiler/php/names.h" 16 #include "google/protobuf/descriptor.h" 17 #include "google/protobuf/port_def.inc" 18 19 namespace google { 20 namespace protobuf { 21 namespace compiler { 22 namespace php { 23 24 struct Options; 25 26 class PROTOC_EXPORT Generator : public CodeGenerator { 27 public: 28 virtual bool Generate( 29 const FileDescriptor* file, 30 const std::string& parameter, 31 GeneratorContext* generator_context, 32 std::string* error) const override; 33 34 bool GenerateAll(const std::vector<const FileDescriptor*>& files, 35 const std::string& parameter, 36 GeneratorContext* generator_context, 37 std::string* error) const override; 38 GetSupportedFeatures()39 uint64_t GetSupportedFeatures() const override { 40 return Feature::FEATURE_PROTO3_OPTIONAL; 41 } 42 GetMinimumEdition()43 Edition GetMinimumEdition() const override { return Edition::EDITION_PROTO2; } GetMaximumEdition()44 Edition GetMaximumEdition() const override { return Edition::EDITION_2023; } GetFeatureExtensions()45 std::vector<const FieldDescriptor*> GetFeatureExtensions() const override { 46 return {}; 47 } 48 49 private: 50 bool Generate( 51 const FileDescriptor* file, 52 const Options& options, 53 GeneratorContext* generator_context, 54 std::string* error) const; 55 }; 56 IsWrapperType(const FieldDescriptor * descriptor)57inline bool IsWrapperType(const FieldDescriptor* descriptor) { 58 return descriptor->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && 59 descriptor->message_type()->file()->name() == "google/protobuf/wrappers.proto"; 60 } 61 62 } // namespace php 63 } // namespace compiler 64 } // namespace protobuf 65 } // namespace google 66 67 #include "google/protobuf/port_undef.inc" 68 69 #endif // GOOGLE_PROTOBUF_COMPILER_PHP_GENERATOR_H__ 70