Go to the documentation of this file.
54 #ifndef GOOGLE_PROTOBUF_DESCRIPTOR_H__
55 #define GOOGLE_PROTOBUF_DESCRIPTOR_H__
64 #include <google/protobuf/stubs/common.h>
65 #include <google/protobuf/stubs/logging.h>
66 #include <google/protobuf/stubs/mutex.h>
67 #include <google/protobuf/stubs/once.h>
68 #include <google/protobuf/port.h>
69 #include <google/protobuf/port_def.inc>
77 #define PROTOBUF_EXPORT
123 class DescriptorBuilder;
124 class FileDescriptorTables;
132 class CommandLineInterface;
139 namespace descriptor_unittest {
140 class DescriptorTest;
164 struct DebugStringOptions {
187 class PROTOBUF_EXPORT LazyDescriptor {
294 bool is_placeholder()
const;
324 WellKnownType well_known_type()
const;
329 int field_count()
const;
354 int oneof_decl_count()
const;
358 int real_oneof_decl_count()
const;
369 int nested_type_count()
const;
381 int enum_type_count()
const;
398 struct ExtensionRange {
413 int extension_range_count()
const;
420 bool IsExtensionNumber(
int number)
const;
449 int extension_count()
const;
477 int reserved_range_count()
const;
484 bool IsReservedNumber(
int number)
const;
487 const ReservedRange* FindReservedRangeContainingNumber(
int number)
const;
490 int reserved_name_count()
const;
535 bool include_opening_clause)
const;
539 void GetLocationPath(std::vector<int>*
output)
const;
542 bool is_placeholder_ : 1;
544 bool is_unqualified_placeholder_ : 1;
575 int oneof_decl_count_;
577 int nested_type_count_;
578 int enum_type_count_;
579 int extension_range_count_;
580 int extension_count_;
581 int reserved_range_count_;
582 int reserved_name_count_;
660 CPPTYPE_MESSAGE = 10,
678 static const int kMaxNumber = (1 << 29) - 1;
682 static const int kFirstReservedNumber = 19000;
685 static const int kLastReservedNumber = 19999;
691 bool is_extension()
const;
716 const char* cpp_type_name()
const;
719 bool is_required()
const;
720 bool is_optional()
const;
721 bool is_repeated()
const;
722 bool is_packable()
const;
724 bool is_packed()
const;
731 bool has_optional_keyword()
const;
740 bool has_presence()
const;
747 bool has_default_value()
const;
751 bool has_json_name()
const;
755 int32_t default_value_int32_t()
const;
759 int64_t default_value_int64_t()
const;
763 uint32_t default_value_uint32_t()
const;
767 uint64_t default_value_uint64_t()
const;
771 float default_value_float()
const;
774 double default_value_double()
const;
777 bool default_value_bool()
const;
800 int index_in_oneof()
const;
833 static CppType TypeToCppType(
Type type);
839 static const char* CppTypeName(CppType
cpp_type);
857 const std::string& PrintableNameForExtension()
const;
885 std::string DefaultValueAsString(
bool quote_string_type)
const;
892 void GetLocationPath(std::vector<int>*
output)
const;
895 bool is_map_message_type()
const;
897 bool has_default_value_ : 1;
901 bool has_json_name_ : 1;
902 bool is_extension_ : 1;
929 void InternalTypeOnceInit()
const;
950 float default_value_float_;
951 double default_value_double_;
952 bool default_value_bool_;
960 static const CppType kTypeToCppTypeMap[MAX_TYPE + 1];
962 static const char*
const kTypeToName[MAX_TYPE + 1];
964 static const char*
const kCppTypeToName[MAX_CPPTYPE + 1];
966 static const char*
const kLabelToName[MAX_LABEL + 1];
991 bool is_synthetic()
const;
999 int field_count()
const;
1036 void GetLocationPath(std::vector<int>*
output)
const;
1060 class PROTOBUF_EXPORT
EnumDescriptor :
private internal::SymbolBase {
1078 int value_count()
const;
1111 bool is_placeholder()
const;
1122 int reserved_range_count()
const;
1129 bool IsReservedNumber(
int number)
const;
1132 const EnumDescriptor::ReservedRange* FindReservedRangeContainingNumber(
1136 int reserved_name_count()
const;
1179 void GetLocationPath(std::vector<int>*
output)
const;
1182 bool is_placeholder_ : 1;
1184 bool is_unqualified_placeholder_ : 1;
1204 int reserved_range_count_;
1205 int reserved_name_count_;
1206 EnumDescriptor::ReservedRange* reserved_ranges_;
1288 void GetLocationPath(std::vector<int>*
output)
const;
1332 int method_count()
const;
1369 void GetLocationPath(std::vector<int>*
output)
const;
1456 void GetLocationPath(std::vector<int>*
output)
const;
1458 bool client_streaming_;
1459 bool server_streaming_;
1497 int dependency_count()
const;
1504 int public_dependency_count()
const;
1512 int weak_dependency_count()
const;
1520 int message_type_count()
const;
1527 int enum_type_count()
const;
1533 int service_count()
const;
1540 int extension_count()
const;
1603 bool is_placeholder()
const;
1614 bool GetSourceLocation(
const std::vector<int>&
path,
1634 void InternalDependenciesOnceInit()
const;
1637 int dependency_count_;
1638 int public_dependency_count_;
1639 int weak_dependency_count_;
1640 int message_type_count_;
1641 int enum_type_count_;
1644 bool is_placeholder_;
1648 bool finished_building_;
1652 int extension_count_;
1655 int* public_dependencies_;
1656 int* weak_dependencies_;
1739 class ErrorCollector;
1741 ErrorCollector* error_collector =
nullptr);
1795 std::vector<const FieldDescriptor*>*
out)
const;
1802 class PROTOBUF_EXPORT ErrorCollector {
1826 virtual void AddError(
1830 ErrorLocation location,
1914 static void InternalAddGeneratedFile(
const void* encoded_file_descriptor,
1935 void InternalDontEnforceDependencies();
1946 lazily_build_dependencies_ =
true;
1949 InternalDontEnforceDependencies();
1954 underlay_ = underlay;
1965 bool is_error =
false);
1966 void ClearUnusedImportTrackFiles();
1976 friend class StreamDescriptor;
1992 int field_number)
const;
2012 bool expecting_enum)
const;
2019 PLACEHOLDER_MESSAGE,
2021 PLACEHOLDER_EXTENDABLE_MESSAGE
2025 PlaceholderType placeholder_type)
const;
2027 PlaceholderType placeholder_type)
const;
2031 internal::WrappedMutex*
mutex_;
2035 ErrorCollector* default_error_collector_;
2041 std::unique_ptr<Tables> tables_;
2043 bool enforce_dependencies_;
2044 bool lazily_build_dependencies_;
2045 bool allow_unknown_;
2047 bool disallow_enforce_utf8_;
2060 #define PROTOBUF_DEFINE_ACCESSOR(CLASS, FIELD, TYPE) \
2061 inline TYPE CLASS::FIELD() const { return FIELD##_; }
2064 #define PROTOBUF_DEFINE_STRING_ACCESSOR(CLASS, FIELD) \
2065 inline const std::string& CLASS::FIELD() const { return *FIELD##_; }
2068 #define PROTOBUF_DEFINE_NAME_ACCESSOR(CLASS) \
2069 inline const std::string& CLASS::name() const { return all_names_[0]; } \
2070 inline const std::string& CLASS::full_name() const { return all_names_[1]; }
2073 #define PROTOBUF_DEFINE_ARRAY_ACCESSOR(CLASS, FIELD, TYPE) \
2074 inline TYPE CLASS::FIELD(int index) const { return FIELD##s_ + index; }
2076 #define PROTOBUF_DEFINE_OPTIONS_ACCESSOR(CLASS, TYPE) \
2077 inline const TYPE& CLASS::options() const { return *options_; }
2097 const Descriptor::ExtensionRange*)
2102 const Descriptor::ReservedRange*)
2141 const EnumDescriptor::ReservedRange*)
2182 #undef PROTOBUF_DEFINE_ACCESSOR
2183 #undef PROTOBUF_DEFINE_STRING_ACCESSOR
2184 #undef PROTOBUF_DEFINE_ARRAY_ACCESSOR
2252 return static_cast<int>(
this -
scope_.containing_oneof->field(0));
2257 return scope_.extension_scope;
2299 return oneof && !oneof->is_synthetic() ? oneof :
nullptr;
2415 #include <google/protobuf/port_undef.inc>
2417 #endif // GOOGLE_PROTOBUF_DESCRIPTOR_H__
@ WELLKNOWNTYPE_INT32VALUE
ServiceDescriptorProto Proto
int * public_dependencies_
std::atomic< const Message * > default_generated_instance_
const char * lazy_type_name
PyObject * FindEnumTypeByName(PyDescriptorPool *self, PyObject *arg)
const Descriptor * Get(const ServiceDescriptor *service)
#define PROTOBUF_DEFINE_NAME_ACCESSOR(CLASS)
PyObject * FindOneofByName(PyDescriptorPool *self, PyObject *arg)
@ WELLKNOWNTYPE_UINT32VALUE
const EnumDescriptor * type() const
const Descriptor::ReservedRange value
const std::string & reserved_name(int index) const
int32_t default_value_int32() const
bool IsExtensionNumber(int number) const
#define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName)
const std::string * all_names_
bool is_synthetic() const
uint32_t default_value_uint32_t_
const FileDescriptor * file_
const Descriptor::ReservedRange const EnumValueDescriptor const MethodDescriptor extension
const grpc_generator::File * file
int index_in_oneof() const
ServiceOptions OptionsType
@ WELLKNOWNTYPE_LISTVALUE
const char * lazy_default_value_enum_name_
static PyObject * FindFileByName(PyObject *self, PyObject *arg)
uint64_t default_value_uint64_t_
uint32_t default_value_uint32() const
const std::string & json_name() const
bool IsReservedNumber(int number) const
#define PROTOBUF_DEFINE_OPTIONS_ACCESSOR(CLASS, TYPE)
const std::string * all_names_
bool has_optional_keyword() const
PROTOBUF_DEFINE_ARRAY_ACCESSOR(Descriptor, extension_range, const Descriptor::ExtensionRange *) PROTOBUF_DEFINE_ARRAY_ACCESSOR(Descriptor
const FileDescriptor * file_
std::map< std::string, bool > unused_import_track_files_
FileDescriptorProto * file_
const Descriptor * message_type
std::string DebugString(const google::protobuf::Message &message)
@ WELLKNOWNTYPE_UNSPECIFIED
const char * type_name() const
void call_once(Args &&... args)
const Descriptor * containing_type() const
MethodDescriptorProto Proto
GRPC_CUSTOM_PRINTER Printer
DescriptorProto_ExtensionRange Proto
const std::string * all_names_
const FileDescriptor * file() const
GRPC_CUSTOM_DESCRIPTORPOOL DescriptorPool
void internal_set_underlay(const DescriptorPool *underlay)
const FileDescriptor * file() const
void EnforceWeakDependencies(bool enforce)
EnumDescriptor * enum_types_
std::string trailing_comments
MessageOptions OptionsType
ExtensionRangeOptions OptionsType
const Descriptor * extension_scope
const std::string * all_names_
void InternalSetLazilyBuildDependencies()
static PyObject * FindServiceByName(PyObject *self, PyObject *arg)
const ServiceDescriptor * service_
const FieldDescriptor * field(int index) const
int16_t sequential_value_limit_
std::string leading_comments
@ WELLKNOWNTYPE_INT64VALUE
EnumValueOptions OptionsType
static PyObject * FindFileContainingSymbol(PyObject *self, PyObject *arg)
EnumDescriptor * enum_types_
bool has_presence() const
static PyObject * FindExtensionByNumber(PyObject *self, PyObject *args)
const char * cpp_type_name() const
@ WELLKNOWNTYPE_TIMESTAMP
EnumDescriptorProto Proto
LazyInitData * dependencies_once_
static PyObject * FindMethodByName(PyBaseDescriptor *self, PyObject *arg)
const std::string & ConstStringParam
const std::string & name() const
const OneofDescriptor * containing_oneof
static void TypeOnceInit(const FieldDescriptor *to_init)
const EnumDescriptor::ReservedRange * FindReservedRangeContainingNumber(int number) const
static const char * TypeName(Type type)
const FileDescriptor * file() const
PyObject * FindFieldByName(PyDescriptorPool *self, PyObject *arg)
PyObject * FindExtensionByName(PyDescriptorPool *self, PyObject *arg)
const std::string * all_names_
@ __WELLKNOWNTYPE__DO_NOT_USE__ADD_DEFAULT_INSTEAD__
OneofDescriptorProto Proto
uint8_t camelcase_name_index_
static bool IsTypePackable(Type field_type)
const FileDescriptor * file() const
void client_streaming(grpc_end2end_test_config config)
GRPC_CUSTOM_METHODDESCRIPTOR MethodDescriptor
unsigned __int64 uint64_t
bool IsReservedName(const std::string &name) const
Descriptor * message_types_
@ WELLKNOWNTYPE_DOUBLEVALUE
const ReservedRange * FindReservedRangeContainingNumber(int number) const
FileDescriptorProto Proto
MethodOptions OptionsType
const ServiceDescriptor * service() const
Descriptor * nested_types_
static const char * CppTypeName(CppType cpp_type)
InternalDescriptorPool * generated_pool
GRPC_CUSTOM_DESCRIPTORDATABASE DescriptorDatabase
const EnumDescriptor * type_
FieldDescriptor * extensions_
EnumValueDescriptor * values_
const FileDescriptor * file() const
uint8_t lowercase_name_index_
internal::once_flag * type_once_
MethodDescriptor * methods_
const std::string & camelcase_name() const
FieldDescriptor * fields_
const FileDescriptor * weak_dependency(int index) const
const EnumDescriptor * enum_type
void AllowUnknownDependencies()
void DisallowEnforceUtf8()
FieldDescriptor * extensions_
uint64_t default_value_uint64() const
union google::protobuf::FieldDescriptor::@481 scope_
int real_oneof_decl_count_
uint16_t sequential_field_limit_
virtual void AddWarning(const std::string &, const std::string &, const Message *, ErrorLocation, const std::string &)
const FieldDescriptor * field
const std::string * all_names_
const char ** dependencies_names
const std::string ** reserved_names_
DebugStringOptions options_
int reserved_name_count() const
std::vector< std::string > leading_detached_comments
int32_t default_value_int32_t_
@ WELLKNOWNTYPE_BOOLVALUE
@ WELLKNOWNTYPE_FIELDMASK
const FileDescriptor * dependency(int index) const
static const char *const kTypeToName[MAX_TYPE+1]
OneofDescriptor * oneof_decls_
const OneofDescriptor * real_containing_oneof() const
zend_class_entry * field_type
const std::string & name() const
const FileDescriptor * file() const
#define GOOGLE_CHECK(EXPRESSION)
static PyObject * FindAllExtensions(PyObject *self, PyObject *arg)
bool IsReservedName(const std::string &name) const
const FileDescriptor * file_
EnumValueDescriptorProto Proto
void server_streaming(grpc_end2end_test_config config)
const std::string & reserved_name(int index) const
int reserved_name_count() const
WellKnownType well_known_type() const
@ WELLKNOWNTYPE_UINT64VALUE
ServiceDescriptor * services_
int64_t default_value_int64_t_
InternalDescriptorPool * pool
const std::string * all_names_
GRPC_CUSTOM_SOURCELOCATION SourceLocation
const Descriptor * containing_type_
FieldDescriptorProto Proto
std::vector< const FieldDescriptor * > fields_
bool is_map_message_type() const
int64_t default_value_int64() const
bool IsReservedNumber(int number) const
internal::WrappedMutex mutex_
const FieldDescriptor * fields_
@ WELLKNOWNTYPE_FLOATVALUE
const Descriptor::ReservedRange * PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, containing_oneof, const OneofDescriptor *) PROTOBUF_DEFINE_ARRAY_ACCESSOR(EnumDescriptor
const Descriptor * containing_type_
const FileDescriptor * file() const
static CppType TypeToCppType(Type type)
const std::string & lowercase_name() const
const FileDescriptor * public_dependency(int index) const
const std::string ** reserved_names_
static const char descriptor[1336]
const Descriptor * containing_type() const
#define PROTOBUF_DEFINE_STRING_ACCESSOR(CLASS, FIELD)
GRPC_CUSTOM_SERVICEDESCRIPTOR ServiceDescriptor
const ExtensionRange * FindExtensionRangeContainingNumber(int number) const
static const CppType kTypeToCppTypeMap[MAX_TYPE+1]
static const char *const kCppTypeToName[MAX_CPPTYPE+1]
const Descriptor::ReservedRange const EnumValueDescriptor method
FieldDescriptor::CppType cpp_type(FieldType type)
const FileDescriptor * file_
const Descriptor * containing_type_
static const char * type_name(int type)
std::unique_ptr< grpc::testing::TestServiceImpl > service_
@ WELLKNOWNTYPE_BYTESVALUE
const Descriptor::ReservedRange const EnumDescriptor::ReservedRange service
@ WELLKNOWNTYPE_STRINGVALUE
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:11