Go to the documentation of this file.
38 #include <google/protobuf/stubs/casts.h>
39 #include <google/protobuf/descriptor.pb.h>
40 #include <google/protobuf/extension_set_inl.h>
41 #include <google/protobuf/parse_context.h>
42 #include <google/protobuf/io/coded_stream.h>
43 #include <google/protobuf/arena.h>
44 #include <google/protobuf/descriptor.h>
45 #include <google/protobuf/extension_set.h>
46 #include <google/protobuf/message.h>
47 #include <google/protobuf/message_lite.h>
48 #include <google/protobuf/repeated_field.h>
49 #include <google/protobuf/unknown_field_set.h>
50 #include <google/protobuf/wire_format.h>
51 #include <google/protobuf/wire_format_lite.h>
54 #include <google/protobuf/port_def.inc>
61 class MessageSetFieldSkipper :
public UnknownFieldSetFieldSkipper {
86 class DescriptorPoolExtensionFinder :
public ExtensionFinder {
104 std::vector<const FieldDescriptor*>*
output)
const {
107 if (
ext.is_repeated) {
108 has = ext.GetSize() > 0;
110 has = !ext.is_cleared;
119 if (
ext.descriptor ==
nullptr) {
120 output->push_back(pool->FindExtensionByNumber(containing_type, number));
122 output->push_back(ext.descriptor);
143 #define GOOGLE_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE) \
144 GOOGLE_DCHECK_EQ((EXTENSION).is_repeated ? FieldDescriptor::LABEL_REPEATED \
145 : FieldDescriptor::LABEL_OPTIONAL, \
146 FieldDescriptor::LABEL_##LABEL); \
147 GOOGLE_DCHECK_EQ(cpp_type((EXTENSION).type), FieldDescriptor::CPPTYPE_##CPPTYPE)
151 MessageFactory* factory)
const {
159 return extension->lazymessage_value->GetMessage(
168 MessageFactory* factory) {
176 factory->GetPrototype(
descriptor->message_type());
185 return extension->lazymessage_value->MutableMessage(
194 MessageFactory* factory) {
231 ret =
extension->lazymessage_value->UnsafeArenaReleaseMessage(
252 Arena::CreateMessage<RepeatedPtrField<MessageLite> >(
arena_);
260 MessageFactory* factory) {
266 reinterpret_cast<internal::RepeatedPtrFieldBase*
>(
268 ->AddFromCleared<GenericTypeHandler<MessageLite> >();
271 if (
extension->repeated_message_value->empty()) {
272 prototype = factory->GetPrototype(
descriptor->message_type());
275 prototype = &
extension->repeated_message_value->Get(0);
287 extension->repeated_message_value->AddAllocated(new_entry);
294 extension->repeated_message_value->UnsafeArenaAddAllocated(new_entry);
313 output->message_info.prototype =
316 <<
"Extension factory's GetPrototype() returned nullptr; extension: "
330 const internal::ParseContext*
ctx,
332 bool* was_packed_on_wire) {
333 if (
ctx->data().pool ==
nullptr) {
336 was_packed_on_wire)) {
340 DescriptorPoolExtensionFinder finder(
ctx->data().pool,
ctx->data().factory,
343 was_packed_on_wire)) {
355 bool was_packed_on_wire;
358 &was_packed_on_wire)) {
362 return ParseFieldWithExtensionInfo<UnknownFieldSet>(
383 if (
input->GetExtensionPool() ==
nullptr) {
387 DescriptorPoolExtensionFinder finder(
input->GetExtensionPool(),
388 input->GetExtensionFactory(),
397 MessageSetFieldSkipper skipper(unknown_fields);
398 if (
input->GetExtensionPool() ==
nullptr) {
402 DescriptorPoolExtensionFinder finder(
input->GetExtensionPool(),
403 input->GetExtensionFactory(),
414 size_t total_size =
Size() *
sizeof(KeyValue);
415 ForEach([&total_size](
int ,
const Extension&
ext) {
416 total_size +=
ext.SpaceUsedExcludingSelfLong();
422 RepeatedPtrFieldBase*
field) {
423 return field->SpaceUsedExcludingSelfLong<GenericTypeHandler<Message> >();
427 size_t total_size = 0;
430 #define HANDLE_TYPE(UPPERCASE, LOWERCASE) \
431 case FieldDescriptor::CPPTYPE_##UPPERCASE: \
432 total_size += sizeof(*repeated_##LOWERCASE##_value) + \
433 repeated_##LOWERCASE##_value->SpaceUsedExcludingSelfLong(); \
452 total_size +=
sizeof(*repeated_message_value) +
454 reinterpret_cast<internal::RepeatedPtrFieldBase*
>(
461 total_size +=
sizeof(*string_value) +
468 total_size += down_cast<Message*>(
message_value)->SpaceUsedLong();
494 input, extension_finder, field_skipper);
498 ExtensionFinder* extension_finder,
499 MessageSetFieldSkipper* field_skipper) {
520 ExtensionFinder* extension_finder,
521 MessageSetFieldSkipper* field_skipper) {
524 return me->ParseFieldMaybeLazily(
526 extension_finder, field_skipper);
530 return field_skipper->SkipField(
input,
tag);
534 ExtensionFinder* extension_finder;
535 MessageSetFieldSkipper* field_skipper;
539 MSFull{
this, extension_finder, field_skipper});
546 #include <google/protobuf/port_undef.inc>
bool Find(int number, ExtensionInfo *output) override
bool MaybeNewExtension(int number, const FieldDescriptor *descriptor, Extension **result)
static const char MESSAGE[]
const EnumDescriptor * type() const
const EnumValueOptions & options() const
const Descriptor::ReservedRange const EnumValueDescriptor const MethodDescriptor extension
MessageLite * message_value
size_t SpaceUsedExcludingSelfLong() const
FieldDescriptor::Type real_type(FieldType type)
static bool IsDefaultSerializationDeterministic()
const char * UnknownFieldParse(uint32 tag, std::string *unknown, const char *ptr, ParseContext *ctx)
const Extension * FindOrNull(int key) const
virtual const Message * GetPrototype(const Descriptor *type)=0
size_t FromIntSize(int size)
#define GOOGLE_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE)
MessageLite * ReleaseMessage(int number, const MessageLite &prototype)
HANDLE_TYPE(int32, FieldDescriptor::CPPTYPE_INT32, -1)
static PyObject * UnknownFieldSet(CMessage *self)
const Descriptor * containing_type_
virtual bool SkipMessageSetField(io::CodedInputStream *input, int field_number)
MessageFactory * factory_
int SpaceUsedExcludingSelf() const
LazyMessageExtension * lazymessage_value
const char * ParseMessageSet(const char *ptr, const Msg *containing_type, Metadata *metadata, internal::ParseContext *ctx)
static bool ValidateEnumUsingDescriptor(const void *arg, int number)
uint8 * SerializeMessageSetWithCachedSizesToArray(uint8 *target) const
void AppendToList(const Descriptor *containing_type, const DescriptorPool *pool, std::vector< const FieldDescriptor * > *output) const
static void * tag(intptr_t t)
RepeatedPtrField< MessageLite > * repeated_message_value
WireFormatLite::FieldType field_type(FieldType type)
MessageLite * MutableMessage(int number, FieldType type, const MessageLite &prototype, desc)
static KeyValueFunctor ForEach(Iterator begin, Iterator end, KeyValueFunctor func)
GRPC_CUSTOM_MESSAGELITE MessageLite
unsigned __int64 uint64_t
bool ParseMessageSetItemImpl(io::CodedInputStream *input, MS ms)
size_t StringSpaceUsedExcludingSelfLong(const std::string &str)
GRPC_CUSTOM_CODEDINPUTSTREAM CodedInputStream
bool FindExtension(int wire_type, uint32 field, const MessageLite *containing_type, const internal::ParseContext *ctx, ExtensionInfo *extension, bool *was_packed_on_wire)
MessageSetFieldSkipper(UnknownFieldSet *unknown_fields)
void AddAllocatedMessage(const FieldDescriptor *descriptor, MessageLite *new_entry)
void AddLengthDelimited(int number, const std::string &value)
static size_t RepeatedMessage_SpaceUsedExcludingSelfLong(RepeatedPtrFieldBase *field)
uint8 * InternalSerializeMessageSetWithCachedSizesToArray(uint8 *target, io::EpsCopyOutputStream *stream) const
virtual size_t SpaceUsedLong() const =0
const FieldDescriptor * FindExtensionByNumber(const Descriptor *extendee, int number) const
std::string * string_value
const FieldDescriptor * field
const DescriptorPool * pool_
UniquePtr< SSL_SESSION > ret
~MessageSetFieldSkipper() override
size_t SpaceUsedExcludingSelfLong() const
bool ParseFieldMaybeLazily(int wire_type, int field_number, io::CodedInputStream *input, ExtensionFinder *extension_finder, MessageSetFieldSkipper *field_skipper)
const MessageLite & GetMessage(int number, const MessageLite &default_value) const
#define GOOGLE_CHECK(EXPRESSION)
UnknownFieldSet * unknown_fields_
DescriptorPoolExtensionFinder(const DescriptorPool *pool, MessageFactory *factory, const Descriptor *containing_type)
InternalDescriptorPool * pool
const std::string & full_name() const
MessageLite * UnsafeArenaReleaseMessage(int number, const MessageLite &prototype)
Extension * MaybeNewRepeatedExtension(const FieldDescriptor *descriptor)
bool FindExtensionInfoFromFieldNumber(int wire_type, int field_number, ExtensionFinder *extension_finder, ExtensionInfo *extension, bool *was_packed_on_wire)
MessageLite * AddMessage(int number, FieldType type, const MessageLite &prototype, desc)
static CppType TypeToCppType(Type type)
void UnsafeArenaAddAllocatedMessage(const FieldDescriptor *descriptor, MessageLite *new_entry)
size_t MessageSetByteSize() const
static const char descriptor[1336]
if(p->owned &&p->wrapped !=NULL)
bool ParseMessageSetItem(io::CodedInputStream *input, ExtensionFinder *extension_finder, MessageSetFieldSkipper *field_skipper)
bool ParseField(uint32 tag, io::CodedInputStream *input, ExtensionFinder *extension_finder, FieldSkipper *field_skipper)
FieldDescriptor::CppType cpp_type(FieldType type)
~DescriptorPoolExtensionFinder() override
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:21