class ExtensionSet
Defined at line 201 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 ExtensionSet ()
Defined at line 203 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h
void ExtensionSet (const ExtensionSet & rhs)
Defined at line 204 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h
void ExtensionSet (internal::InternalVisibility , Arena * arena)
Arena enabled constructors: for internal use only.
Defined at line 207 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h
void ExtensionSet (ArenaInitialized , Arena * arena)
Defined at line 213 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h
void ExtensionSet (Arena * arena)
TODO: make constructor private, and migrate `ArenaInitialized`
to `InternalVisibility` overloaded constructor(s).
Defined at line 1065 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h
void ~ExtensionSet ()
void RegisterExtension (const MessageLite *extendee,intnumber,FieldTypetype,boolis_repeated,boolis_packed)
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,intnumber,FieldTypetype,boolis_repeated,boolis_packed,EnumValidityFunc *is_valid)
void RegisterMessageExtension (const MessageLite *extendee,intnumber,FieldTypetype,boolis_repeated,boolis_packed,const MessageLite *prototype,LazyEagerVerifyFnTypeverify_func,LazyAnnotationis_lazy)
bool ShouldRegisterAtThisTime (std::initializer_list<WeakPrototypeRef> messages, bool is_preregistration)
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.
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)
Arena * GetArena ()
Defined at line 347 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h
int NumExtensions ()
FieldType ExtensionType (int number)
void ClearExtension (int number)
int32_t GetInt32 (int number, int32_t default_value)
singular fields -------------------------------------------------
int64_t GetInt64 (int number, int64_t default_value)
uint32_t GetUInt32 (int number, uint32_t default_value)
uint64_t GetUInt64 (int number, uint64_t default_value)
float GetFloat (int number, float default_value)
double GetDouble (int number, double default_value)
bool GetBool (int number, bool default_value)
int GetEnum (int number, int default_value)
const std::string & GetString (int number, const std::string & default_value)
const MessageLite & GetMessage (int number, const MessageLite & default_value)
const MessageLite & GetMessage (intnumber,const Descriptor *message_type,MessageFactory *factory)
void SetInt32 (intnumber,FieldTypetype,int32_tvalue,const FieldDescriptor *descriptor)
void SetInt64 (intnumber,FieldTypetype,int64_tvalue,const FieldDescriptor *descriptor)
void SetUInt32 (intnumber,FieldTypetype,uint32_tvalue,const FieldDescriptor *descriptor)
void SetUInt64 (intnumber,FieldTypetype,uint64_tvalue,const FieldDescriptor *descriptor)
void SetFloat (intnumber,FieldTypetype,floatvalue,const FieldDescriptor *descriptor)
void SetDouble (intnumber,FieldTypetype,doublevalue,const FieldDescriptor *descriptor)
void SetBool (intnumber,FieldTypetype,boolvalue,const FieldDescriptor *descriptor)
void SetEnum (intnumber,FieldTypetype,intvalue,const FieldDescriptor *descriptor)
void SetString (intnumber,FieldTypetype,std::stringvalue,const FieldDescriptor *descriptor)
These are just for convenience...
Defined at line 1069 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h
std::string * MutableString (intnumber,FieldTypetype,const FieldDescriptor *descriptor)
MessageLite * MutableMessage (intnumber,FieldTypetype,const MessageLite &prototype,const FieldDescriptor *descriptor)
MessageLite * MutableMessage (const FieldDescriptor * descriptor, MessageFactory * factory)
void SetAllocatedMessage (intnumber,FieldTypetype,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 (intnumber,FieldTypetype,const FieldDescriptor *descriptor,MessageLite *message)
MessageLite * ReleaseMessage (int number, const MessageLite & prototype)
MessageLite * UnsafeArenaReleaseMessage (int number, const MessageLite & prototype)
MessageLite * ReleaseMessage (const FieldDescriptor * descriptor, MessageFactory * factory)
MessageLite * UnsafeArenaReleaseMessage (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 (intnumber,FieldTypefield_type,boolpacked,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.)
int32_t GetRepeatedInt32 (int number, int index)
int64_t GetRepeatedInt64 (int number, int index)
uint32_t GetRepeatedUInt32 (int number, int index)
uint64_t GetRepeatedUInt64 (int number, int index)
float GetRepeatedFloat (int number, int index)
double GetRepeatedDouble (int number, int index)
bool GetRepeatedBool (int number, int index)
int GetRepeatedEnum (int number, int index)
const std::string & GetRepeatedString (int number, int index)
const MessageLite & GetRepeatedMessage (int number, int index)
void SetRepeatedInt32 (intnumber,intindex,int32_tvalue)
void SetRepeatedInt64 (intnumber,intindex,int64_tvalue)
void SetRepeatedUInt32 (intnumber,intindex,uint32_tvalue)
void SetRepeatedUInt64 (intnumber,intindex,uint64_tvalue)
void SetRepeatedFloat (intnumber,intindex,floatvalue)
void SetRepeatedDouble (intnumber,intindex,doublevalue)
void SetRepeatedBool (intnumber,intindex,boolvalue)
void SetRepeatedEnum (intnumber,intindex,intvalue)
std::string * MutableRepeatedString (int number, int index)
MessageLite * MutableRepeatedMessage (int number, int index)
void AddInt32 (intnumber,FieldTypetype,boolpacked,int32_tvalue,const FieldDescriptor *descriptor)
void AddInt64 (intnumber,FieldTypetype,boolpacked,int64_tvalue,const FieldDescriptor *descriptor)
void AddUInt32 (intnumber,FieldTypetype,boolpacked,uint32_tvalue,const FieldDescriptor *descriptor)
void AddUInt64 (intnumber,FieldTypetype,boolpacked,uint64_tvalue,const FieldDescriptor *descriptor)
void AddFloat (intnumber,FieldTypetype,boolpacked,floatvalue,const FieldDescriptor *descriptor)
void AddDouble (intnumber,FieldTypetype,boolpacked,doublevalue,const FieldDescriptor *descriptor)
void AddBool (intnumber,FieldTypetype,boolpacked,boolvalue,const FieldDescriptor *descriptor)
void AddEnum (intnumber,FieldTypetype,boolpacked,intvalue,const FieldDescriptor *descriptor)
std::string * AddString (intnumber,FieldTypetype,const FieldDescriptor *descriptor)
MessageLite * AddMessage (intnumber,FieldTypetype,const MessageLite &prototype,const FieldDescriptor *descriptor)
MessageLite * AddMessage (const FieldDescriptor * descriptor, MessageFactory * factory)
void AddAllocatedMessage (const FieldDescriptor * descriptor, MessageLite * new_entry)
void UnsafeArenaAddAllocatedMessage (const FieldDescriptor * descriptor, MessageLite * new_entry)
void RemoveLast (int number)
MessageLite * ReleaseLast (int number)
MessageLite * UnsafeArenaReleaseLast (int number)
void SwapElements (intnumber,intindex1,intindex2)
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 (const MessageLite * extendee, const ExtensionSet & other)
void Swap (const MessageLite * extendee, ExtensionSet * other)
void InternalSwap (ExtensionSet * other)
void SwapExtension (const MessageLite *extendee,ExtensionSet *other,intnumber)
void UnsafeShallowSwapExtension (ExtensionSet * other, int number)
bool IsInitialized (const MessageLite * extendee)
const char * ParseField (uint64_ttag,const char *ptr,const MessageLite *extendee,internal::InternalMetadata *metadata,internal::ParseContext *ctx)
Lite parser
const char * ParseField (uint64_ttag,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)
uint8_t * SerializeWithCachedSizesToArray (intstart_field_number,intend_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.
ExtensionSet & operator= (const ExtensionSet & )
Defined at line 215 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 441 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h
void SerializeWithCachedSizes (const MessageLite *extendee,intstart_field_number,intend_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 469 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h
uint8_t * _InternalSerialize (const MessageLite *extendee,intstart_field_number,intend_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 483 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 496 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h
size_t InternalGetArenaOffset (internal::InternalVisibility )
Defined at line 536 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h
void SetRepeatedString (intnumber,intindex,std::stringvalue)
Defined at line 1074 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h
void AddString (intnumber,FieldTypetype,std::stringvalue,const FieldDescriptor *descriptor)
Defined at line 1078 of file ../../third_party/protobuf/src/src/google/protobuf/extension_set.h
Records
Friends
void ExtensionSet ()
class WireFormat
class DynamicExtensionInfoHelper
class ReflectionVisit
class Reflection
template <typename Type, bool IsValid(int)>
class RepeatedEnumTypeTraits
template <typename Type, bool IsValid(int)>
class EnumTypeTraits
template <typename Type>
class RepeatedPrimitiveTypeTraits
template <typename Type>
class PrimitiveTypeTraits