class ExtensionSet

Defined at line 257 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h

This is an internal helper class intended for use within the protocol buffer

library and generated classes. Clients should not use it directly. Instead,

use the generated accessors such as GetExtension() of the class being

extended.

This class manages extensions for a protocol message object. The

message's HasExtension(), GetExtension(), MutableExtension(), and

ClearExtension() methods are just thin wrappers around the embedded

ExtensionSet. When parsing, if a tag number is encountered which is

inside one of the message type's extension ranges, the tag is passed

off to the ExtensionSet for parsing. Etc.

Public Methods

void AppendToList (const Descriptor * extendee, const DescriptorPool * pool, std::vector<const FieldDescriptor *> * output)

Add all fields which are currently present to the given vector. This

is useful to implement Reflection::ListFields(). Descriptors are appended

in increasing tag order.

void ExtensionSet ()

Defined at line 259 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h

void ExtensionSet (const ExtensionSet & rhs)

Defined at line 260 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h

void RegisterExtension (const MessageLite * extendee, int number, FieldType type, bool is_repeated, bool is_packed, bool is_utf8)

These are called at startup by protocol-compiler-generated code to

register known extensions. The registrations are used by ParseField()

to look up extensions for parsed field numbers. Note that dynamic parsing

does not use ParseField(); only protocol-compiler-generated parsing

methods do.

void RegisterEnumExtension (const MessageLite * extendee, int number, FieldType type, bool is_repeated, bool is_packed, const uint32_t * validation_data)
void RegisterMessageExtension (const MessageLite * extendee, int number, FieldType type, bool is_repeated, bool is_packed, const MessageLite * prototype, LazyEagerVerifyFnType verify_func, LazyAnnotation is_lazy)
bool ShouldRegisterAtThisTime (std::initializer_list<WeakPrototypeRef> messages, bool is_preregistration)
bool IsEmpty ()

Whether there are any fields which are currently present. Note that this

is different from IsCompletelyEmpty(), which returns false if the list has

any capacity; and Size(), which also accounts for cleared fields.

bool Has (int number)

=================================================================

Accessors

Generated message classes include type-safe templated wrappers around

these methods. Generally you should use those rather than call these

directly, unless you are doing low-level memory management.

When calling any of these accessors, the extension number requested

MUST exist in the DescriptorPool provided to the constructor. Otherwise,

the method will fail an assert. Normally, though, you would not call

these directly; you would either call the generated accessors of your

message class (e.g. GetExtension()) or you would call the accessors

of the reflection interface. In both cases, it is impossible to

trigger this assert failure: the generated accessors only accept

linked-in extension types as parameters, while the Reflection interface

requires you to provide the FieldDescriptor describing the extension.

When calling any of these accessors, a protocol-compiler-generated

implementation of the extension corresponding to the number MUST

be linked in, and the FieldDescriptor used to refer to it MUST be

the one generated by that linked-in code. Otherwise, the method will

die on an assert failure. The message objects returned by the message

accessors are guaranteed to be of the correct linked-in type.

These methods pretty much match Reflection except that:

- They're not virtual.

- They identify fields by number rather than FieldDescriptors.

- They identify enum values using integers rather than descriptors.

- Strings provide Mutable() in addition to Set() accessors.

int ExtensionSize (int number)
int NumExtensions ()
FieldType ExtensionType (int number)
void ClearExtension (int number)
const MessageLite & GetMessage (Arena * arena, int number, const MessageLite & default_value)
const MessageLite & GetMessage (Arena * arena, int number, const Descriptor * message_type, MessageFactory * factory)
const MessageLite & GetRepeatedMessage (int number, int index)
std::string * MutableRepeatedString (int number, int index)
MessageLite * MutableRepeatedMessage (int number, int index)
std::string * AddString (Arena * arena, int number, FieldType type, const FieldDescriptor * descriptor)
MessageLite * AddMessage (Arena * arena, int number, FieldType type, const ClassData * class_data, const FieldDescriptor * descriptor)
MessageLite * AddMessage (Arena * arena, const FieldDescriptor * descriptor, MessageFactory * factory)
void AddAllocatedMessage (Arena * arena, const FieldDescriptor * descriptor, MessageLite * new_entry)
void UnsafeArenaAddAllocatedMessage (Arena * arena, const FieldDescriptor * descriptor, MessageLite * new_entry)
void RemoveLast (int number)
MessageLite * ReleaseLast (Arena * arena, int number)
MessageLite * UnsafeArenaReleaseLast (Arena * arena, int number)
void SwapElements (int number, int index1, int index2)
void Clear ()

=================================================================

convenience methods for implementing methods of Message

These could all be implemented in terms of the other methods of this

class, but providing them here helps keep the generated code size down.

void MergeFrom (Arena * arena, const MessageLite * extendee, const ExtensionSet & other, Arena * other_arena)
void Swap (Arena * arena, const MessageLite * extendee, ExtensionSet * other, Arena * other_arena)
void InternalSwap (ExtensionSet * other)
void SwapExtension (Arena * arena, const MessageLite * extendee, ExtensionSet * other, Arena * other_arena, int number)
void UnsafeShallowSwapExtension (Arena * arena, ExtensionSet * other, int number)
bool IsInitialized (Arena * arena, const MessageLite * extendee)
ExtensionSet & operator= (const ExtensionSet & )

Defined at line 262 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h

template <typename T>
const T & Get (int number, const internal::type_identity_t<T> & default_value)

singular fields -------------------------------------------------

Defined at line 351 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h

template <typename T, typename U>
void Set (Arena * arena, int number, FieldType type, U && value, const FieldDescriptor * descriptor)

Defined at line 362 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h

template <typename T>
const T & GetRepeated (int number, int index)

Defined at line 432 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h

bool IsLazy (int number)

Defined at line 632 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h

void ~ExtensionSet ()
std::string * MutableString (Arena * arena, int number, FieldType type, const FieldDescriptor * descriptor)
MessageLite * MutableMessage (Arena * arena, int number, FieldType type, const MessageLite & prototype, const FieldDescriptor * descriptor)
MessageLite * MutableMessage (Arena * arena, const FieldDescriptor * descriptor, MessageFactory * factory)
void SetAllocatedMessage (Arena * arena, int number, FieldType type, const FieldDescriptor * descriptor, MessageLite * message)

Adds the given message to the ExtensionSet, taking ownership of the

message object. Existing message with the same number will be deleted.

If "message" is nullptr, this is equivalent to "ClearExtension(number)".

void UnsafeArenaSetAllocatedMessage (Arena * arena, int number, FieldType type, const FieldDescriptor * descriptor, MessageLite * message)
MessageLite * ReleaseMessage (Arena * arena, int number, const MessageLite & prototype)
MessageLite * UnsafeArenaReleaseMessage (Arena * arena, int number, const MessageLite & prototype)
MessageLite * ReleaseMessage (Arena * arena, const FieldDescriptor * descriptor, MessageFactory * factory)
MessageLite * UnsafeArenaReleaseMessage (Arena * arena, const FieldDescriptor * descriptor, MessageFactory * factory)
const void * GetRawRepeatedField (int number, const void * default_value)

Fetches a RepeatedField extension by number; returns |default_value|

if no such extension exists. User should not touch this directly; it is

used by the GetRepeatedExtension() method.

void * MutableRawRepeatedField (Arena * arena, int number, FieldType field_type, bool packed, const FieldDescriptor * desc)

Fetches a mutable version of a RepeatedField extension by number,

instantiating one if none exists. Similar to above, user should not use

this directly; it underlies MutableRepeatedExtension().

void * MutableRawRepeatedField (int number)

This is an overload of MutableRawRepeatedField to maintain compatibility

with old code using a previous API. This version of

MutableRawRepeatedField() will ABSL_CHECK-fail on a missing extension.

(E.g.: borg/clients/internal/proto1/proto2_reflection.cc.)

const char * ParseField (uint64_t tag, const char * ptr, const MessageLite * extendee, internal::InternalMetadata * metadata, internal::ParseContext * ctx)

Lite parser

const char * ParseField (uint64_t tag, const char * ptr, const Message * extendee, internal::InternalMetadata * metadata, internal::ParseContext * ctx)

Full parser

uint8_t * InternalSerializeMessageSetWithCachedSizesToArray (const MessageLite * extendee, uint8_t * target, io::EpsCopyOutputStream * stream)
template <typename T, typename U>
void SetRepeated (int number, int index, U && value)

Defined at line 440 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h

template <typename T>
auto & Add (Arena * arena, int number, FieldType type, const FieldDescriptor * descriptor)

Defined at line 447 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h

template <typename T>
void Add (Arena * arena, int number, FieldType type, bool packed, T value, const FieldDescriptor * descriptor)

Defined at line 456 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h

template <typename Msg>
const char * ParseMessageSet (const char * ptr, const Msg * extendee, InternalMetadata * metadata, internal::ParseContext * ctx)

Defined at line 517 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h

void SerializeWithCachedSizes (const MessageLite * extendee, int start_field_number, int end_field_number, io::CodedOutputStream * output)

Write all extension fields with field numbers in the range

[start_field_number, end_field_number)

to the output stream, using the cached sizes computed when ByteSize() was

last called. Note that the range bounds are inclusive-exclusive.

Defined at line 545 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h

uint8_t * SerializeWithCachedSizesToArray (int start_field_number, int end_field_number, uint8_t * target)

For backward-compatibility, versions of two of the above methods that

serialize deterministically iff SetDefaultSerializationDeterministic()

has been called.

uint8_t * SerializeMessageSetWithCachedSizesToArray (const MessageLite * extendee, uint8_t * target)
size_t ByteSize ()

Returns the total serialized size of all the extensions.

size_t MessageSetByteSize ()

Like ByteSize() but uses MessageSet format.

size_t SpaceUsedExcludingSelfLong ()

Returns (an estimate of) the total number of bytes used for storing the

extensions in memory, excluding sizeof(*this). If the ExtensionSet is

for a lite message (and thus possibly contains lite messages), the results

are undefined (might work, might crash, might corrupt data, might not even

be linked in). It's up to the protocol compiler to avoid calling this on

such ExtensionSets (easy enough since lite messages don't implement

SpaceUsed()).

int SpaceUsedExcludingSelf ()

This method just calls SpaceUsedExcludingSelfLong() but it can not be

inlined because the definition of SpaceUsedExcludingSelfLong() is not

included in lite runtime and when an inline method refers to it MSVC

will complain about unresolved symbols when building the lite runtime

as .dll.

bool MoveExtension (Arena * arena, int dst_number, ExtensionSet & src, int src_number)

Moves an extension from one ExtensionSet to another.

If the source extension does not exist, then destination extension is

cleared.

If the destination extension already exists, it is overwritten otherwise

it is created and then moved.

LazyField * TryGetLazyField (Arena * arena, int number, FieldType type)

Returns a pointer to the LazyField for the given extension number, or

nullptr if the extension is not lazy.

If the extension does not exist, it is created as a lazy extension.

This function returns nullptr if lazy parsing is not supported, if the

extension exists but is not lazy, or if the extension is not a message

type.

uint8_t * _InternalSerialize (const MessageLite * extendee, int start_field_number, int end_field_number, uint8_t * target, io::EpsCopyOutputStream * stream)

Same as SerializeWithCachedSizes, but without any bounds checking.

The caller must ensure that target has sufficient capacity for the

serialized extensions.

Returns a pointer past the last written byte.

Defined at line 558 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h

uint8_t * _InternalSerializeAll (const MessageLite * extendee, uint8_t * target, io::EpsCopyOutputStream * stream)

Same as _InternalSerialize, but do not verify the range of field numbers.

Defined at line 570 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h

void SerializeMessageSetWithCachedSizes (const MessageLite * extendee, io::CodedOutputStream * output)

Like above but serializes in MessageSet format.

Defined at line 581 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h

Records

Friends

class FindExtensionTest
bool ExtensionSet (const Message & root, const Message & message)
void ExtensionSet ()
class WireFormat
class DynamicExtensionInfoHelper
class ReflectionVisit
class Reflection
template <typename Type>
class RepeatedEnumTypeTraits
template <typename Type>
class EnumTypeTraits
template <typename Type>
class RepeatedPrimitiveTypeTraits
template <typename Type>
class PrimitiveTypeTraits