|
|
|
@ -196,13 +196,6 @@ namespace internal { |
|
|
|
|
#define PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(t, expected) |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// `typedef` instead of `using` for SWIG
|
|
|
|
|
#if defined(PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE) |
|
|
|
|
typedef absl::string_view DescriptorStringView; |
|
|
|
|
#else |
|
|
|
|
typedef const std::string& DescriptorStringView; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
class FlatAllocator; |
|
|
|
|
|
|
|
|
|
class PROTOBUF_EXPORT LazyDescriptor { |
|
|
|
@ -320,14 +313,14 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase { |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// The name of the message type, not including its scope.
|
|
|
|
|
internal::DescriptorStringView name() const; |
|
|
|
|
absl::string_view name() const; |
|
|
|
|
|
|
|
|
|
// The fully-qualified name of the message type, scope delimited by
|
|
|
|
|
// periods. For example, message type "Foo" which is declared in package
|
|
|
|
|
// "bar" has full name "bar.Foo". If a type "Baz" is nested within
|
|
|
|
|
// Foo, Baz's full_name is "bar.Foo.Baz". To get only the part that
|
|
|
|
|
// comes after the last '.', use name().
|
|
|
|
|
internal::DescriptorStringView full_name() const; |
|
|
|
|
absl::string_view full_name() const; |
|
|
|
|
|
|
|
|
|
// Index of this descriptor within the file or containing type's message
|
|
|
|
|
// type array.
|
|
|
|
@ -507,12 +500,10 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase { |
|
|
|
|
const ExtensionRangeOptions& options() const { return *options_; } |
|
|
|
|
|
|
|
|
|
// Returns the name of the containing type.
|
|
|
|
|
internal::DescriptorStringView name() const { |
|
|
|
|
return containing_type_->name(); |
|
|
|
|
} |
|
|
|
|
absl::string_view name() const { return containing_type_->name(); } |
|
|
|
|
|
|
|
|
|
// Returns the full name of the containing type.
|
|
|
|
|
internal::DescriptorStringView full_name() const { |
|
|
|
|
absl::string_view full_name() const { |
|
|
|
|
return containing_type_->full_name(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -631,7 +622,7 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase { |
|
|
|
|
int reserved_name_count() const; |
|
|
|
|
|
|
|
|
|
// Gets a reserved name by index, where 0 <= index < reserved_name_count().
|
|
|
|
|
internal::DescriptorStringView reserved_name(int index) const; |
|
|
|
|
absl::string_view reserved_name(int index) const; |
|
|
|
|
|
|
|
|
|
// Returns true if the field name is reserved.
|
|
|
|
|
bool IsReservedName(absl::string_view name) const; |
|
|
|
@ -844,11 +835,11 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase, |
|
|
|
|
static const int kLastReservedNumber = 19999; |
|
|
|
|
|
|
|
|
|
// Name of this field within the message.
|
|
|
|
|
internal::DescriptorStringView name() const; |
|
|
|
|
absl::string_view name() const; |
|
|
|
|
// Fully-qualified name of the field.
|
|
|
|
|
internal::DescriptorStringView full_name() const; |
|
|
|
|
absl::string_view full_name() const; |
|
|
|
|
// JSON name of this field.
|
|
|
|
|
internal::DescriptorStringView json_name() const; |
|
|
|
|
absl::string_view json_name() const; |
|
|
|
|
|
|
|
|
|
const FileDescriptor* file() const; // File in which this field was defined.
|
|
|
|
|
bool is_extension() const; // Is this an extension field?
|
|
|
|
@ -860,7 +851,7 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase, |
|
|
|
|
// field names should be lowercased anyway according to the protobuf style
|
|
|
|
|
// guide, so this only makes a difference when dealing with old .proto files
|
|
|
|
|
// which do not follow the guide.)
|
|
|
|
|
internal::DescriptorStringView lowercase_name() const; |
|
|
|
|
absl::string_view lowercase_name() const; |
|
|
|
|
|
|
|
|
|
// Same as name() except converted to camel-case. In this conversion, any
|
|
|
|
|
// time an underscore appears in the name, it is removed and the next
|
|
|
|
@ -871,7 +862,7 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase, |
|
|
|
|
// fooBar -> fooBar
|
|
|
|
|
// This (and especially the FindFieldByCamelcaseName() method) can be useful
|
|
|
|
|
// when parsing formats which prefer to use camel-case naming style.
|
|
|
|
|
internal::DescriptorStringView camelcase_name() const; |
|
|
|
|
absl::string_view camelcase_name() const; |
|
|
|
|
|
|
|
|
|
Type type() const; // Declared type of this field.
|
|
|
|
|
// Name of the declared type.
|
|
|
|
@ -973,7 +964,7 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase, |
|
|
|
|
const EnumValueDescriptor* default_value_enum() const; |
|
|
|
|
// Get the field default value if cpp_type() == CPPTYPE_STRING. If no
|
|
|
|
|
// explicit default was defined, the default is the empty string.
|
|
|
|
|
internal::DescriptorStringView default_value_string() const; |
|
|
|
|
absl::string_view default_value_string() const; |
|
|
|
|
|
|
|
|
|
// The Descriptor for the message of which this is a field. For extensions,
|
|
|
|
|
// this is the extended type. Never nullptr.
|
|
|
|
@ -1051,7 +1042,7 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase, |
|
|
|
|
// its printable name) can be accomplished with
|
|
|
|
|
// message->file()->pool()->FindExtensionByPrintableName(message, name)
|
|
|
|
|
// where the extension extends "message".
|
|
|
|
|
internal::DescriptorStringView PrintableNameForExtension() const; |
|
|
|
|
absl::string_view PrintableNameForExtension() const; |
|
|
|
|
|
|
|
|
|
// Source Location ---------------------------------------------------
|
|
|
|
|
|
|
|
|
@ -1217,9 +1208,9 @@ class PROTOBUF_EXPORT OneofDescriptor : private internal::SymbolBase { |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// Name of this oneof.
|
|
|
|
|
internal::DescriptorStringView name() const; |
|
|
|
|
absl::string_view name() const; |
|
|
|
|
// Fully-qualified name of the oneof.
|
|
|
|
|
internal::DescriptorStringView full_name() const; |
|
|
|
|
absl::string_view full_name() const; |
|
|
|
|
|
|
|
|
|
// Index of this oneof within the message's oneof array.
|
|
|
|
|
int index() const; |
|
|
|
@ -1324,10 +1315,10 @@ class PROTOBUF_EXPORT EnumDescriptor : private internal::SymbolBase { |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// The name of this enum type in the containing scope.
|
|
|
|
|
internal::DescriptorStringView name() const; |
|
|
|
|
absl::string_view name() const; |
|
|
|
|
|
|
|
|
|
// The fully-qualified name of the enum type, scope delimited by periods.
|
|
|
|
|
internal::DescriptorStringView full_name() const; |
|
|
|
|
absl::string_view full_name() const; |
|
|
|
|
|
|
|
|
|
// Index of this enum within the file or containing message's enum array.
|
|
|
|
|
int index() const; |
|
|
|
@ -1424,7 +1415,7 @@ class PROTOBUF_EXPORT EnumDescriptor : private internal::SymbolBase { |
|
|
|
|
int reserved_name_count() const; |
|
|
|
|
|
|
|
|
|
// Gets a reserved name by index, where 0 <= index < reserved_name_count().
|
|
|
|
|
internal::DescriptorStringView reserved_name(int index) const; |
|
|
|
|
absl::string_view reserved_name(int index) const; |
|
|
|
|
|
|
|
|
|
// Returns true if the field name is reserved.
|
|
|
|
|
bool IsReservedName(absl::string_view name) const; |
|
|
|
@ -1537,7 +1528,7 @@ class PROTOBUF_EXPORT EnumValueDescriptor : private internal::SymbolBaseN<0>, |
|
|
|
|
EnumValueDescriptor& operator=(const EnumValueDescriptor&) = delete; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
internal::DescriptorStringView name() const; // Name of this enum constant.
|
|
|
|
|
absl::string_view name() const; // Name of this enum constant.
|
|
|
|
|
int index() const; // Index within the enums's Descriptor.
|
|
|
|
|
int number() const; // Numeric value of this enum constant.
|
|
|
|
|
|
|
|
|
@ -1546,7 +1537,7 @@ class PROTOBUF_EXPORT EnumValueDescriptor : private internal::SymbolBaseN<0>, |
|
|
|
|
// "google.protobuf.FieldDescriptorProto.TYPE_INT32", NOT
|
|
|
|
|
// "google.protobuf.FieldDescriptorProto.Type.TYPE_INT32". This is to conform
|
|
|
|
|
// with C++ scoping rules for enums.
|
|
|
|
|
internal::DescriptorStringView full_name() const; |
|
|
|
|
absl::string_view full_name() const; |
|
|
|
|
|
|
|
|
|
// The .proto file in which this value was defined. Never nullptr.
|
|
|
|
|
const FileDescriptor* file() const; |
|
|
|
@ -1640,9 +1631,9 @@ class PROTOBUF_EXPORT ServiceDescriptor : private internal::SymbolBase { |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// The name of the service, not including its containing scope.
|
|
|
|
|
internal::DescriptorStringView name() const; |
|
|
|
|
absl::string_view name() const; |
|
|
|
|
// The fully-qualified name of the service, scope delimited by periods.
|
|
|
|
|
internal::DescriptorStringView full_name() const; |
|
|
|
|
absl::string_view full_name() const; |
|
|
|
|
// Index of this service within the file's services array.
|
|
|
|
|
int index() const; |
|
|
|
|
|
|
|
|
@ -1744,9 +1735,9 @@ class PROTOBUF_EXPORT MethodDescriptor : private internal::SymbolBase { |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// Name of this method, not including containing scope.
|
|
|
|
|
internal::DescriptorStringView name() const; |
|
|
|
|
absl::string_view name() const; |
|
|
|
|
// The fully-qualified name of the method, scope delimited by periods.
|
|
|
|
|
internal::DescriptorStringView full_name() const; |
|
|
|
|
absl::string_view full_name() const; |
|
|
|
|
// Index within the service's Descriptor.
|
|
|
|
|
int index() const; |
|
|
|
|
|
|
|
|
@ -1852,10 +1843,10 @@ class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase { |
|
|
|
|
|
|
|
|
|
// The filename, relative to the source tree.
|
|
|
|
|
// e.g. "foo/bar/baz.proto"
|
|
|
|
|
internal::DescriptorStringView name() const; |
|
|
|
|
absl::string_view name() const; |
|
|
|
|
|
|
|
|
|
// The package, e.g. "google.protobuf.compiler".
|
|
|
|
|
internal::DescriptorStringView package() const; |
|
|
|
|
absl::string_view package() const; |
|
|
|
|
|
|
|
|
|
// The DescriptorPool in which this FileDescriptor and all its contents were
|
|
|
|
|
// allocated. Never nullptr.
|
|
|
|
@ -2613,19 +2604,13 @@ class PROTOBUF_EXPORT DescriptorPool { |
|
|
|
|
inline TYPE CLASS::FIELD() const { return FIELD##_; } |
|
|
|
|
|
|
|
|
|
// Strings fields are stored as pointers but returned as const references.
|
|
|
|
|
#define PROTOBUF_DEFINE_STRING_ACCESSOR(CLASS, FIELD) \ |
|
|
|
|
inline internal::DescriptorStringView CLASS::FIELD() const { \
|
|
|
|
|
return *FIELD##_; \
|
|
|
|
|
} |
|
|
|
|
#define PROTOBUF_DEFINE_STRING_ACCESSOR(CLASS, FIELD) \ |
|
|
|
|
inline absl::string_view CLASS::FIELD() const { return *FIELD##_; } |
|
|
|
|
|
|
|
|
|
// Name and full name are stored in a single array to save space.
|
|
|
|
|
#define PROTOBUF_DEFINE_NAME_ACCESSOR(CLASS) \ |
|
|
|
|
inline internal::DescriptorStringView CLASS::name() const { \
|
|
|
|
|
return all_names_[0]; \
|
|
|
|
|
} \
|
|
|
|
|
inline internal::DescriptorStringView CLASS::full_name() const { \
|
|
|
|
|
return all_names_[1]; \
|
|
|
|
|
} |
|
|
|
|
#define PROTOBUF_DEFINE_NAME_ACCESSOR(CLASS) \ |
|
|
|
|
inline absl::string_view CLASS::name() const { return all_names_[0]; } \
|
|
|
|
|
inline absl::string_view CLASS::full_name() const { return all_names_[1]; } |
|
|
|
|
|
|
|
|
|
// Arrays take an index parameter, obviously.
|
|
|
|
|
#define PROTOBUF_DEFINE_ARRAY_ACCESSOR(CLASS, FIELD, TYPE) \ |
|
|
|
@ -2774,8 +2759,7 @@ inline bool Descriptor::IsReservedName(absl::string_view name) const { |
|
|
|
|
|
|
|
|
|
// Can't use PROTOBUF_DEFINE_ARRAY_ACCESSOR because reserved_names_ is actually
|
|
|
|
|
// an array of pointers rather than the usual array of objects.
|
|
|
|
|
inline internal::DescriptorStringView Descriptor::reserved_name( |
|
|
|
|
int index) const { |
|
|
|
|
inline absl::string_view Descriptor::reserved_name(int index) const { |
|
|
|
|
return *reserved_names_[index]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2794,20 +2778,19 @@ inline bool EnumDescriptor::IsReservedName(absl::string_view name) const { |
|
|
|
|
|
|
|
|
|
// Can't use PROTOBUF_DEFINE_ARRAY_ACCESSOR because reserved_names_ is actually
|
|
|
|
|
// an array of pointers rather than the usual array of objects.
|
|
|
|
|
inline internal::DescriptorStringView EnumDescriptor::reserved_name( |
|
|
|
|
int index) const { |
|
|
|
|
inline absl::string_view EnumDescriptor::reserved_name(int index) const { |
|
|
|
|
return *reserved_names_[index]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline internal::DescriptorStringView FieldDescriptor::lowercase_name() const { |
|
|
|
|
inline absl::string_view FieldDescriptor::lowercase_name() const { |
|
|
|
|
return all_names_[lowercase_name_index_]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline internal::DescriptorStringView FieldDescriptor::camelcase_name() const { |
|
|
|
|
inline absl::string_view FieldDescriptor::camelcase_name() const { |
|
|
|
|
return all_names_[camelcase_name_index_]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline internal::DescriptorStringView FieldDescriptor::json_name() const { |
|
|
|
|
inline absl::string_view FieldDescriptor::json_name() const { |
|
|
|
|
return all_names_[json_name_index_]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|