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_RETENTION_H__ 9 #define GOOGLE_PROTOBUF_COMPILER_RETENTION_H__ 10 11 #include "google/protobuf/descriptor.h" 12 #include "google/protobuf/descriptor.pb.h" 13 14 // Must appear last 15 #include "google/protobuf/port_def.inc" 16 17 namespace google { 18 namespace protobuf { 19 namespace compiler { 20 21 // Returns a FileDescriptorProto for this file, with all RETENTION_SOURCE 22 // options stripped out. If include_source_code_info is true, this function 23 // will also populate the source code info but strip out the parts of it 24 // corresponding to source-retention options. 25 PROTOC_EXPORT FileDescriptorProto StripSourceRetentionOptions( 26 const FileDescriptor& file, bool include_source_code_info = false); 27 PROTOC_EXPORT void StripSourceRetentionOptions(const DescriptorPool& pool, 28 FileDescriptorProto& file_proto); 29 PROTOC_EXPORT DescriptorProto 30 StripSourceRetentionOptions(const Descriptor& message); 31 PROTOC_EXPORT DescriptorProto::ExtensionRange StripSourceRetentionOptions( 32 const Descriptor& message, const Descriptor::ExtensionRange& range); 33 PROTOC_EXPORT EnumDescriptorProto 34 StripSourceRetentionOptions(const EnumDescriptor& enm); 35 PROTOC_EXPORT FieldDescriptorProto 36 StripSourceRetentionOptions(const FieldDescriptor& field); 37 PROTOC_EXPORT OneofDescriptorProto 38 StripSourceRetentionOptions(const OneofDescriptor& oneof); 39 40 // The following functions take a descriptor and strip all source-retention 41 // options from just the local entity (e.g. message, enum, field). Most code 42 // generators should not need these functions, but they are sometimes useful if 43 // you need to strip the options on a single entity rather than handling the 44 // entire file at once. 45 PROTOC_EXPORT EnumOptions 46 StripLocalSourceRetentionOptions(const EnumDescriptor& descriptor); 47 PROTOC_EXPORT EnumValueOptions 48 StripLocalSourceRetentionOptions(const EnumValueDescriptor& descriptor); 49 PROTOC_EXPORT FieldOptions 50 StripLocalSourceRetentionOptions(const FieldDescriptor& descriptor); 51 PROTOC_EXPORT FileOptions 52 StripLocalSourceRetentionOptions(const FileDescriptor& descriptor); 53 PROTOC_EXPORT MessageOptions 54 StripLocalSourceRetentionOptions(const Descriptor& descriptor); 55 PROTOC_EXPORT ExtensionRangeOptions StripLocalSourceRetentionOptions( 56 const Descriptor& descriptor, const Descriptor::ExtensionRange& range); 57 PROTOC_EXPORT MethodOptions 58 StripLocalSourceRetentionOptions(const MethodDescriptor& descriptor); 59 PROTOC_EXPORT OneofOptions 60 StripLocalSourceRetentionOptions(const OneofDescriptor& descriptor); 61 PROTOC_EXPORT ServiceOptions 62 StripLocalSourceRetentionOptions(const ServiceDescriptor& descriptor); 63 64 } // namespace compiler 65 } // namespace protobuf 66 } // namespace google 67 68 #include "google/protobuf/port_undef.inc" 69 70 #endif // GOOGLE_PROTOBUF_COMPILER_RETENTION_H__ 71