updated protobuf to 3.18.1
This commit is contained in:
570
external/include/google/protobuf/extension_set.h
vendored
570
external/include/google/protobuf/extension_set.h
vendored
@@ -53,7 +53,9 @@
|
||||
#include <google/protobuf/repeated_field.h>
|
||||
#include <google/protobuf/wire_format_lite.h>
|
||||
|
||||
#include <google/protobuf/port_def.inc>
|
||||
// clang-format off
|
||||
#include <google/protobuf/port_def.inc> // Must be last
|
||||
// clang-format on
|
||||
|
||||
#ifdef SWIG
|
||||
#error "You cannot SWIG proto headers"
|
||||
@@ -85,7 +87,7 @@ class InternalMetadata;
|
||||
// #include wire_format_lite.h. Also, ensures that we use only one byte to
|
||||
// store these values, which is important to keep the layout of
|
||||
// ExtensionSet::Extension small.
|
||||
typedef uint8 FieldType;
|
||||
typedef uint8_t FieldType;
|
||||
|
||||
// A function which, given an integer value, returns true if the number
|
||||
// matches one of the defined values for the corresponding enum type. This
|
||||
@@ -99,12 +101,18 @@ typedef bool EnumValidityFuncWithArg(const void* arg, int number);
|
||||
// Information about a registered extension.
|
||||
struct ExtensionInfo {
|
||||
inline ExtensionInfo() {}
|
||||
inline ExtensionInfo(FieldType type_param, bool isrepeated, bool ispacked)
|
||||
: type(type_param),
|
||||
inline ExtensionInfo(const MessageLite* extendee, int param_number,
|
||||
FieldType type_param, bool isrepeated, bool ispacked)
|
||||
: message(extendee),
|
||||
number(param_number),
|
||||
type(type_param),
|
||||
is_repeated(isrepeated),
|
||||
is_packed(ispacked),
|
||||
descriptor(NULL) {}
|
||||
|
||||
const MessageLite* message;
|
||||
int number;
|
||||
|
||||
FieldType type;
|
||||
bool is_repeated;
|
||||
bool is_packed;
|
||||
@@ -143,15 +151,15 @@ class PROTOBUF_EXPORT ExtensionFinder {
|
||||
// files which have been compiled into the binary.
|
||||
class PROTOBUF_EXPORT GeneratedExtensionFinder : public ExtensionFinder {
|
||||
public:
|
||||
GeneratedExtensionFinder(const MessageLite* containing_type)
|
||||
: containing_type_(containing_type) {}
|
||||
explicit GeneratedExtensionFinder(const MessageLite* extendee)
|
||||
: extendee_(extendee) {}
|
||||
~GeneratedExtensionFinder() override {}
|
||||
|
||||
// Returns true and fills in *output if found, otherwise returns false.
|
||||
bool Find(int number, ExtensionInfo* output) override;
|
||||
|
||||
private:
|
||||
const MessageLite* containing_type_;
|
||||
const MessageLite* extendee_;
|
||||
};
|
||||
|
||||
// A FieldSkipper used for parsing MessageSet.
|
||||
@@ -182,24 +190,22 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
// to look up extensions for parsed field numbers. Note that dynamic parsing
|
||||
// does not use ParseField(); only protocol-compiler-generated parsing
|
||||
// methods do.
|
||||
static void RegisterExtension(const MessageLite* containing_type, int number,
|
||||
static void RegisterExtension(const MessageLite* extendee, int number,
|
||||
FieldType type, bool is_repeated,
|
||||
bool is_packed);
|
||||
static void RegisterEnumExtension(const MessageLite* containing_type,
|
||||
int number, FieldType type,
|
||||
bool is_repeated, bool is_packed,
|
||||
EnumValidityFunc* is_valid);
|
||||
static void RegisterMessageExtension(const MessageLite* containing_type,
|
||||
int number, FieldType type,
|
||||
bool is_repeated, bool is_packed,
|
||||
static void RegisterEnumExtension(const MessageLite* extendee, int number,
|
||||
FieldType type, bool is_repeated,
|
||||
bool is_packed, EnumValidityFunc* is_valid);
|
||||
static void RegisterMessageExtension(const MessageLite* extendee, int number,
|
||||
FieldType type, bool is_repeated,
|
||||
bool is_packed,
|
||||
const MessageLite* prototype);
|
||||
|
||||
// =================================================================
|
||||
|
||||
// Add all fields which are currently present to the given vector. This
|
||||
// is useful to implement Reflection::ListFields().
|
||||
void AppendToList(const Descriptor* containing_type,
|
||||
const DescriptorPool* pool,
|
||||
void AppendToList(const Descriptor* extendee, const DescriptorPool* pool,
|
||||
std::vector<const FieldDescriptor*>* output) const;
|
||||
|
||||
// =================================================================
|
||||
@@ -240,10 +246,10 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
|
||||
// singular fields -------------------------------------------------
|
||||
|
||||
int32 GetInt32(int number, int32 default_value) const;
|
||||
int64 GetInt64(int number, int64 default_value) const;
|
||||
uint32 GetUInt32(int number, uint32 default_value) const;
|
||||
uint64 GetUInt64(int number, uint64 default_value) const;
|
||||
int32_t GetInt32(int number, int32_t default_value) const;
|
||||
int64_t GetInt64(int number, int64_t default_value) const;
|
||||
uint32_t GetUInt32(int number, uint32_t default_value) const;
|
||||
uint64_t GetUInt64(int number, uint64_t default_value) const;
|
||||
float GetFloat(int number, float default_value) const;
|
||||
double GetDouble(int number, double default_value) const;
|
||||
bool GetBool(int number, bool default_value) const;
|
||||
@@ -259,10 +265,10 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
// the extension lives in the same pool as the descriptor for the containing
|
||||
// type.
|
||||
#define desc const FieldDescriptor* descriptor // avoid line wrapping
|
||||
void SetInt32(int number, FieldType type, int32 value, desc);
|
||||
void SetInt64(int number, FieldType type, int64 value, desc);
|
||||
void SetUInt32(int number, FieldType type, uint32 value, desc);
|
||||
void SetUInt64(int number, FieldType type, uint64 value, desc);
|
||||
void SetInt32(int number, FieldType type, int32_t value, desc);
|
||||
void SetInt64(int number, FieldType type, int64_t value, desc);
|
||||
void SetUInt32(int number, FieldType type, uint32_t value, desc);
|
||||
void SetUInt64(int number, FieldType type, uint64_t value, desc);
|
||||
void SetFloat(int number, FieldType type, float value, desc);
|
||||
void SetDouble(int number, FieldType type, double value, desc);
|
||||
void SetBool(int number, FieldType type, bool value, desc);
|
||||
@@ -312,10 +318,10 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
// (E.g.: borg/clients/internal/proto1/proto2_reflection.cc.)
|
||||
void* MutableRawRepeatedField(int number);
|
||||
|
||||
int32 GetRepeatedInt32(int number, int index) const;
|
||||
int64 GetRepeatedInt64(int number, int index) const;
|
||||
uint32 GetRepeatedUInt32(int number, int index) const;
|
||||
uint64 GetRepeatedUInt64(int number, int index) const;
|
||||
int32_t GetRepeatedInt32(int number, int index) const;
|
||||
int64_t GetRepeatedInt64(int number, int index) const;
|
||||
uint32_t GetRepeatedUInt32(int number, int index) const;
|
||||
uint64_t GetRepeatedUInt64(int number, int index) const;
|
||||
float GetRepeatedFloat(int number, int index) const;
|
||||
double GetRepeatedDouble(int number, int index) const;
|
||||
bool GetRepeatedBool(int number, int index) const;
|
||||
@@ -323,10 +329,10 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
const std::string& GetRepeatedString(int number, int index) const;
|
||||
const MessageLite& GetRepeatedMessage(int number, int index) const;
|
||||
|
||||
void SetRepeatedInt32(int number, int index, int32 value);
|
||||
void SetRepeatedInt64(int number, int index, int64 value);
|
||||
void SetRepeatedUInt32(int number, int index, uint32 value);
|
||||
void SetRepeatedUInt64(int number, int index, uint64 value);
|
||||
void SetRepeatedInt32(int number, int index, int32_t value);
|
||||
void SetRepeatedInt64(int number, int index, int64_t value);
|
||||
void SetRepeatedUInt32(int number, int index, uint32_t value);
|
||||
void SetRepeatedUInt64(int number, int index, uint64_t value);
|
||||
void SetRepeatedFloat(int number, int index, float value);
|
||||
void SetRepeatedDouble(int number, int index, double value);
|
||||
void SetRepeatedBool(int number, int index, bool value);
|
||||
@@ -336,10 +342,10 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
MessageLite* MutableRepeatedMessage(int number, int index);
|
||||
|
||||
#define desc const FieldDescriptor* descriptor // avoid line wrapping
|
||||
void AddInt32(int number, FieldType type, bool packed, int32 value, desc);
|
||||
void AddInt64(int number, FieldType type, bool packed, int64 value, desc);
|
||||
void AddUInt32(int number, FieldType type, bool packed, uint32 value, desc);
|
||||
void AddUInt64(int number, FieldType type, bool packed, uint64 value, desc);
|
||||
void AddInt32(int number, FieldType type, bool packed, int32_t value, desc);
|
||||
void AddInt64(int number, FieldType type, bool packed, int64_t value, desc);
|
||||
void AddUInt32(int number, FieldType type, bool packed, uint32_t value, desc);
|
||||
void AddUInt64(int number, FieldType type, bool packed, uint64_t value, desc);
|
||||
void AddFloat(int number, FieldType type, bool packed, float value, desc);
|
||||
void AddDouble(int number, FieldType type, bool packed, double value, desc);
|
||||
void AddBool(int number, FieldType type, bool packed, bool value, desc);
|
||||
@@ -352,10 +358,13 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
MessageFactory* factory);
|
||||
void AddAllocatedMessage(const FieldDescriptor* descriptor,
|
||||
MessageLite* new_entry);
|
||||
void UnsafeArenaAddAllocatedMessage(const FieldDescriptor* descriptor,
|
||||
MessageLite* new_entry);
|
||||
#undef desc
|
||||
|
||||
void RemoveLast(int number);
|
||||
PROTOBUF_MUST_USE_RESULT MessageLite* ReleaseLast(int number);
|
||||
MessageLite* UnsafeArenaReleaseLast(int number);
|
||||
void SwapElements(int number, int index1, int index2);
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
@@ -377,49 +386,47 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
|
||||
// Parses a single extension from the input. The input should start out
|
||||
// positioned immediately after the tag.
|
||||
bool ParseField(uint32 tag, io::CodedInputStream* input,
|
||||
bool ParseField(uint32_t tag, io::CodedInputStream* input,
|
||||
ExtensionFinder* extension_finder,
|
||||
FieldSkipper* field_skipper);
|
||||
|
||||
// Specific versions for lite or full messages (constructs the appropriate
|
||||
// FieldSkipper automatically). |containing_type| is the default
|
||||
// FieldSkipper automatically). |extendee| is the default
|
||||
// instance for the containing message; it is used only to look up the
|
||||
// extension by number. See RegisterExtension(), above. Unlike the other
|
||||
// methods of ExtensionSet, this only works for generated message types --
|
||||
// it looks up extensions registered using RegisterExtension().
|
||||
bool ParseField(uint32 tag, io::CodedInputStream* input,
|
||||
const MessageLite* containing_type);
|
||||
bool ParseField(uint32 tag, io::CodedInputStream* input,
|
||||
const Message* containing_type,
|
||||
UnknownFieldSet* unknown_fields);
|
||||
bool ParseField(uint32 tag, io::CodedInputStream* input,
|
||||
const MessageLite* containing_type,
|
||||
bool ParseField(uint32_t tag, io::CodedInputStream* input,
|
||||
const MessageLite* extendee);
|
||||
bool ParseField(uint32_t tag, io::CodedInputStream* input,
|
||||
const Message* extendee, UnknownFieldSet* unknown_fields);
|
||||
bool ParseField(uint32_t tag, io::CodedInputStream* input,
|
||||
const MessageLite* extendee,
|
||||
io::CodedOutputStream* unknown_fields);
|
||||
|
||||
// Lite parser
|
||||
const char* ParseField(uint64 tag, const char* ptr,
|
||||
const MessageLite* containing_type,
|
||||
const char* ParseField(uint64_t tag, const char* ptr,
|
||||
const MessageLite* extendee,
|
||||
internal::InternalMetadata* metadata,
|
||||
internal::ParseContext* ctx);
|
||||
// Full parser
|
||||
const char* ParseField(uint64 tag, const char* ptr,
|
||||
const Message* containing_type,
|
||||
const char* ParseField(uint64_t tag, const char* ptr, const Message* extendee,
|
||||
internal::InternalMetadata* metadata,
|
||||
internal::ParseContext* ctx);
|
||||
template <typename Msg>
|
||||
const char* ParseMessageSet(const char* ptr, const Msg* containing_type,
|
||||
const char* ParseMessageSet(const char* ptr, const Msg* extendee,
|
||||
InternalMetadata* metadata,
|
||||
internal::ParseContext* ctx) {
|
||||
struct MessageSetItem {
|
||||
const char* _InternalParse(const char* ptr, ParseContext* ctx) {
|
||||
return me->ParseMessageSetItem(ptr, containing_type, metadata, ctx);
|
||||
return me->ParseMessageSetItem(ptr, extendee, metadata, ctx);
|
||||
}
|
||||
ExtensionSet* me;
|
||||
const Msg* containing_type;
|
||||
const Msg* extendee;
|
||||
InternalMetadata* metadata;
|
||||
} item{this, containing_type, metadata};
|
||||
} item{this, extendee, metadata};
|
||||
while (!ctx->Done(&ptr)) {
|
||||
uint32 tag;
|
||||
uint32_t tag;
|
||||
ptr = ReadTag(ptr, &tag);
|
||||
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
||||
if (tag == WireFormatLite::kMessageSetItemStartTag) {
|
||||
@@ -430,7 +437,7 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
ctx->SetLastTag(tag);
|
||||
return ptr;
|
||||
}
|
||||
ptr = ParseField(tag, ptr, containing_type, metadata, ctx);
|
||||
ptr = ParseField(tag, ptr, extendee, metadata, ctx);
|
||||
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
||||
}
|
||||
}
|
||||
@@ -448,21 +455,21 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
|
||||
// Specific versions for lite or full messages (constructs the appropriate
|
||||
// FieldSkipper automatically).
|
||||
bool ParseMessageSet(io::CodedInputStream* input,
|
||||
const MessageLite* containing_type,
|
||||
bool ParseMessageSet(io::CodedInputStream* input, const MessageLite* extendee,
|
||||
std::string* unknown_fields);
|
||||
bool ParseMessageSet(io::CodedInputStream* input,
|
||||
const Message* containing_type,
|
||||
bool ParseMessageSet(io::CodedInputStream* input, const Message* extendee,
|
||||
UnknownFieldSet* unknown_fields);
|
||||
|
||||
// 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.
|
||||
void SerializeWithCachedSizes(int start_field_number, int end_field_number,
|
||||
void SerializeWithCachedSizes(const MessageLite* extendee,
|
||||
int start_field_number, int end_field_number,
|
||||
io::CodedOutputStream* output) const {
|
||||
output->SetCur(_InternalSerialize(start_field_number, end_field_number,
|
||||
output->Cur(), output->EpsCopy()));
|
||||
output->SetCur(_InternalSerialize(extendee, start_field_number,
|
||||
end_field_number, output->Cur(),
|
||||
output->EpsCopy()));
|
||||
}
|
||||
|
||||
// Same as SerializeWithCachedSizes, but without any bounds checking.
|
||||
@@ -470,32 +477,37 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
// serialized extensions.
|
||||
//
|
||||
// Returns a pointer past the last written byte.
|
||||
uint8* _InternalSerialize(int start_field_number, int end_field_number,
|
||||
uint8* target,
|
||||
io::EpsCopyOutputStream* stream) const {
|
||||
|
||||
uint8_t* _InternalSerialize(const MessageLite* extendee,
|
||||
int start_field_number, int end_field_number,
|
||||
uint8_t* target,
|
||||
io::EpsCopyOutputStream* stream) const {
|
||||
if (flat_size_ == 0) {
|
||||
assert(!is_large());
|
||||
return target;
|
||||
}
|
||||
return _InternalSerializeImpl(start_field_number, end_field_number, target,
|
||||
stream);
|
||||
return _InternalSerializeImpl(extendee, start_field_number,
|
||||
end_field_number, target, stream);
|
||||
}
|
||||
|
||||
// Like above but serializes in MessageSet format.
|
||||
void SerializeMessageSetWithCachedSizes(io::CodedOutputStream* output) const {
|
||||
void SerializeMessageSetWithCachedSizes(const MessageLite* extendee,
|
||||
io::CodedOutputStream* output) const {
|
||||
output->SetCur(InternalSerializeMessageSetWithCachedSizesToArray(
|
||||
output->Cur(), output->EpsCopy()));
|
||||
extendee, output->Cur(), output->EpsCopy()));
|
||||
}
|
||||
uint8* InternalSerializeMessageSetWithCachedSizesToArray(
|
||||
uint8* target, io::EpsCopyOutputStream* stream) const;
|
||||
uint8_t* InternalSerializeMessageSetWithCachedSizesToArray(
|
||||
const MessageLite* extendee, uint8_t* target,
|
||||
io::EpsCopyOutputStream* stream) const;
|
||||
|
||||
// For backward-compatibility, versions of two of the above methods that
|
||||
// serialize deterministically iff SetDefaultSerializationDeterministic()
|
||||
// has been called.
|
||||
uint8* SerializeWithCachedSizesToArray(int start_field_number,
|
||||
int end_field_number,
|
||||
uint8* target) const;
|
||||
uint8* SerializeMessageSetWithCachedSizesToArray(uint8* target) const;
|
||||
uint8_t* SerializeWithCachedSizesToArray(int start_field_number,
|
||||
int end_field_number,
|
||||
uint8_t* target) const;
|
||||
uint8_t* SerializeMessageSetWithCachedSizesToArray(
|
||||
const MessageLite* extendee, uint8_t* target) const;
|
||||
|
||||
// Returns the total serialized size of all the extensions.
|
||||
size_t ByteSize() const;
|
||||
@@ -520,10 +532,40 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
int SpaceUsedExcludingSelf() const;
|
||||
|
||||
private:
|
||||
template <typename Type>
|
||||
friend class PrimitiveTypeTraits;
|
||||
|
||||
template <typename Type>
|
||||
friend class RepeatedPrimitiveTypeTraits;
|
||||
|
||||
template <typename Type, bool IsValid(int)>
|
||||
friend class EnumTypeTraits;
|
||||
|
||||
template <typename Type, bool IsValid(int)>
|
||||
friend class RepeatedEnumTypeTraits;
|
||||
|
||||
const int32_t& GetRefInt32(int number, const int32_t& default_value) const;
|
||||
const int64_t& GetRefInt64(int number, const int64_t& default_value) const;
|
||||
const uint32_t& GetRefUInt32(int number, const uint32_t& default_value) const;
|
||||
const uint64_t& GetRefUInt64(int number, const uint64_t& default_value) const;
|
||||
const float& GetRefFloat(int number, const float& default_value) const;
|
||||
const double& GetRefDouble(int number, const double& default_value) const;
|
||||
const bool& GetRefBool(int number, const bool& default_value) const;
|
||||
const int& GetRefEnum(int number, const int& default_value) const;
|
||||
const int32_t& GetRefRepeatedInt32(int number, int index) const;
|
||||
const int64_t& GetRefRepeatedInt64(int number, int index) const;
|
||||
const uint32_t& GetRefRepeatedUInt32(int number, int index) const;
|
||||
const uint64_t& GetRefRepeatedUInt64(int number, int index) const;
|
||||
const float& GetRefRepeatedFloat(int number, int index) const;
|
||||
const double& GetRefRepeatedDouble(int number, int index) const;
|
||||
const bool& GetRefRepeatedBool(int number, int index) const;
|
||||
const int& GetRefRepeatedEnum(int number, int index) const;
|
||||
|
||||
// Implementation of _InternalSerialize for non-empty map_.
|
||||
uint8* _InternalSerializeImpl(int start_field_number, int end_field_number,
|
||||
uint8* target,
|
||||
io::EpsCopyOutputStream* stream) const;
|
||||
uint8_t* _InternalSerializeImpl(const MessageLite* extendee,
|
||||
int start_field_number, int end_field_number,
|
||||
uint8_t* target,
|
||||
io::EpsCopyOutputStream* stream) const;
|
||||
// Interface of a lazily parsed singular message extension.
|
||||
class PROTOBUF_EXPORT LazyMessageExtension {
|
||||
public:
|
||||
@@ -533,7 +575,8 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
virtual LazyMessageExtension* New(Arena* arena) const = 0;
|
||||
virtual const MessageLite& GetMessage(
|
||||
const MessageLite& prototype) const = 0;
|
||||
virtual MessageLite* MutableMessage(const MessageLite& prototype) = 0;
|
||||
virtual MessageLite* MutableMessage(const MessageLite& prototype,
|
||||
Arena* arena) = 0;
|
||||
virtual void SetAllocatedMessage(MessageLite* message) = 0;
|
||||
virtual void UnsafeArenaSetAllocatedMessage(MessageLite* message) = 0;
|
||||
virtual PROTOBUF_MUST_USE_RESULT MessageLite* ReleaseMessage(
|
||||
@@ -548,28 +591,32 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
virtual size_t ByteSizeLong() const = 0;
|
||||
virtual size_t SpaceUsedLong() const = 0;
|
||||
|
||||
virtual void MergeFrom(const LazyMessageExtension& other) = 0;
|
||||
virtual void MergeFrom(const LazyMessageExtension& other, Arena* arena) = 0;
|
||||
virtual void MergeFromMessage(const MessageLite& msg, Arena* arena) = 0;
|
||||
virtual void Clear() = 0;
|
||||
|
||||
virtual bool ReadMessage(const MessageLite& prototype,
|
||||
io::CodedInputStream* input) = 0;
|
||||
virtual const char* _InternalParse(const char* ptr, ParseContext* ctx) = 0;
|
||||
virtual uint8* WriteMessageToArray(
|
||||
int number, uint8* target, io::EpsCopyOutputStream* stream) const = 0;
|
||||
virtual uint8_t* WriteMessageToArray(
|
||||
const MessageLite* prototype, int number, uint8_t* target,
|
||||
io::EpsCopyOutputStream* stream) const = 0;
|
||||
|
||||
private:
|
||||
virtual void UnusedKeyMethod(); // Dummy key method to avoid weak vtable.
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LazyMessageExtension);
|
||||
};
|
||||
// Give access to function defined below to see LazyMessageExtension.
|
||||
friend LazyMessageExtension* MaybeCreateLazyExtension(Arena* arena);
|
||||
struct Extension {
|
||||
// The order of these fields packs Extension into 24 bytes when using 8
|
||||
// byte alignment. Consider this when adding or removing fields here.
|
||||
union {
|
||||
int32 int32_value;
|
||||
int64 int64_value;
|
||||
uint32 uint32_value;
|
||||
uint64 uint64_value;
|
||||
int32_t int32_t_value;
|
||||
int64_t int64_t_value;
|
||||
uint32_t uint32_t_value;
|
||||
uint64_t uint64_t_value;
|
||||
float float_value;
|
||||
double double_value;
|
||||
bool bool_value;
|
||||
@@ -578,10 +625,10 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
MessageLite* message_value;
|
||||
LazyMessageExtension* lazymessage_value;
|
||||
|
||||
RepeatedField<int32>* repeated_int32_value;
|
||||
RepeatedField<int64>* repeated_int64_value;
|
||||
RepeatedField<uint32>* repeated_uint32_value;
|
||||
RepeatedField<uint64>* repeated_uint64_value;
|
||||
RepeatedField<int32_t>* repeated_int32_t_value;
|
||||
RepeatedField<int64_t>* repeated_int64_t_value;
|
||||
RepeatedField<uint32_t>* repeated_uint32_t_value;
|
||||
RepeatedField<uint64_t>* repeated_uint64_t_value;
|
||||
RepeatedField<float>* repeated_float_value;
|
||||
RepeatedField<double>* repeated_double_value;
|
||||
RepeatedField<bool>* repeated_bool_value;
|
||||
@@ -622,10 +669,12 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
const FieldDescriptor* descriptor;
|
||||
|
||||
// Some helper methods for operations on a single Extension.
|
||||
uint8* InternalSerializeFieldWithCachedSizesToArray(
|
||||
int number, uint8* target, io::EpsCopyOutputStream* stream) const;
|
||||
uint8* InternalSerializeMessageSetItemWithCachedSizesToArray(
|
||||
int number, uint8* target, io::EpsCopyOutputStream* stream) const;
|
||||
uint8_t* InternalSerializeFieldWithCachedSizesToArray(
|
||||
const MessageLite* extendee, const ExtensionSet* extension_set,
|
||||
int number, uint8_t* target, io::EpsCopyOutputStream* stream) const;
|
||||
uint8_t* InternalSerializeMessageSetItemWithCachedSizesToArray(
|
||||
const MessageLite* extendee, const ExtensionSet* extension_set,
|
||||
int number, uint8_t* target, io::EpsCopyOutputStream* stream) const;
|
||||
size_t ByteSize(int number) const;
|
||||
size_t MessageSetItemByteSize(int number) const;
|
||||
void Clear();
|
||||
@@ -678,8 +727,8 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
// Grows the flat_capacity_.
|
||||
// If flat_capacity_ > kMaximumFlatCapacity, converts to LargeMap.
|
||||
void GrowCapacity(size_t minimum_new_capacity);
|
||||
static constexpr uint16 kMaximumFlatCapacity = 256;
|
||||
bool is_large() const { return flat_capacity_ > kMaximumFlatCapacity; }
|
||||
static constexpr uint16_t kMaximumFlatCapacity = 256;
|
||||
bool is_large() const { return static_cast<int16_t>(flat_size_) < 0; }
|
||||
|
||||
// Removes a key from the ExtensionSet.
|
||||
void Erase(int key);
|
||||
@@ -723,7 +772,7 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
// Note to support packed repeated field compatibility, it also fills whether
|
||||
// the tag on wire is packed, which can be different from
|
||||
// extension->is_packed (whether packed=true is specified).
|
||||
bool FindExtensionInfoFromTag(uint32 tag, ExtensionFinder* extension_finder,
|
||||
bool FindExtensionInfoFromTag(uint32_t tag, ExtensionFinder* extension_finder,
|
||||
int* field_number, ExtensionInfo* extension,
|
||||
bool* was_packed_on_wire);
|
||||
|
||||
@@ -734,7 +783,12 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
bool FindExtensionInfoFromFieldNumber(int wire_type, int field_number,
|
||||
ExtensionFinder* extension_finder,
|
||||
ExtensionInfo* extension,
|
||||
bool* was_packed_on_wire);
|
||||
bool* was_packed_on_wire) const;
|
||||
|
||||
// Find the prototype for a LazyMessage from the extension registry. Returns
|
||||
// null if the extension is not found.
|
||||
const MessageLite* GetPrototypeForLazyMessage(const MessageLite* extendee,
|
||||
int number) const;
|
||||
|
||||
// Parses a single extension from the input. The input should start out
|
||||
// positioned immediately after the wire tag. This method is called in
|
||||
@@ -772,36 +826,33 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
ExtensionFinder* extension_finder,
|
||||
MessageSetFieldSkipper* field_skipper);
|
||||
|
||||
bool FindExtension(int wire_type, uint32 field,
|
||||
const MessageLite* containing_type,
|
||||
bool FindExtension(int wire_type, uint32_t field, const MessageLite* extendee,
|
||||
const internal::ParseContext* /*ctx*/,
|
||||
ExtensionInfo* extension, bool* was_packed_on_wire) {
|
||||
GeneratedExtensionFinder finder(containing_type);
|
||||
GeneratedExtensionFinder finder(extendee);
|
||||
return FindExtensionInfoFromFieldNumber(wire_type, field, &finder,
|
||||
extension, was_packed_on_wire);
|
||||
}
|
||||
inline bool FindExtension(int wire_type, uint32 field,
|
||||
const Message* containing_type,
|
||||
inline bool FindExtension(int wire_type, uint32_t field,
|
||||
const Message* extendee,
|
||||
const internal::ParseContext* ctx,
|
||||
ExtensionInfo* extension, bool* was_packed_on_wire);
|
||||
// Used for MessageSet only
|
||||
const char* ParseFieldMaybeLazily(uint64 tag, const char* ptr,
|
||||
const MessageLite* containing_type,
|
||||
const char* ParseFieldMaybeLazily(uint64_t tag, const char* ptr,
|
||||
const MessageLite* extendee,
|
||||
internal::InternalMetadata* metadata,
|
||||
internal::ParseContext* ctx) {
|
||||
// Lite MessageSet doesn't implement lazy.
|
||||
return ParseField(tag, ptr, containing_type, metadata, ctx);
|
||||
return ParseField(tag, ptr, extendee, metadata, ctx);
|
||||
}
|
||||
const char* ParseFieldMaybeLazily(uint64 tag, const char* ptr,
|
||||
const Message* containing_type,
|
||||
const char* ParseFieldMaybeLazily(uint64_t tag, const char* ptr,
|
||||
const Message* extendee,
|
||||
internal::InternalMetadata* metadata,
|
||||
internal::ParseContext* ctx);
|
||||
const char* ParseMessageSetItem(const char* ptr,
|
||||
const MessageLite* containing_type,
|
||||
const char* ParseMessageSetItem(const char* ptr, const MessageLite* extendee,
|
||||
internal::InternalMetadata* metadata,
|
||||
internal::ParseContext* ctx);
|
||||
const char* ParseMessageSetItem(const char* ptr,
|
||||
const Message* containing_type,
|
||||
const char* ParseMessageSetItem(const char* ptr, const Message* extendee,
|
||||
internal::InternalMetadata* metadata,
|
||||
internal::ParseContext* ctx);
|
||||
|
||||
@@ -813,8 +864,7 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
const char* ptr,
|
||||
internal::ParseContext* ctx);
|
||||
template <typename Msg, typename T>
|
||||
const char* ParseMessageSetItemTmpl(const char* ptr,
|
||||
const Msg* containing_type,
|
||||
const char* ParseMessageSetItemTmpl(const char* ptr, const Msg* extendee,
|
||||
internal::InternalMetadata* metadata,
|
||||
internal::ParseContext* ctx);
|
||||
|
||||
@@ -850,8 +900,8 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
// Manual memory-management:
|
||||
// map_.flat is an allocated array of flat_capacity_ elements.
|
||||
// [map_.flat, map_.flat + flat_size_) is the currently-in-use prefix.
|
||||
uint16 flat_capacity_;
|
||||
uint16 flat_size_;
|
||||
uint16_t flat_capacity_;
|
||||
uint16_t flat_size_; // negative int16_t(flat_size_) indicates is_large()
|
||||
union AllocatedData {
|
||||
KeyValue* flat;
|
||||
|
||||
@@ -860,7 +910,7 @@ class PROTOBUF_EXPORT ExtensionSet {
|
||||
LargeMap* large;
|
||||
} map_;
|
||||
|
||||
static void DeleteFlatMap(const KeyValue* flat, uint16 flat_capacity);
|
||||
static void DeleteFlatMap(const KeyValue* flat, uint16_t flat_capacity);
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionSet);
|
||||
};
|
||||
@@ -937,7 +987,7 @@ inline void ExtensionSet::AddString(int number, FieldType type,
|
||||
// For example, if "foo" is an extension of type "optional int32", then if you
|
||||
// try to write code like:
|
||||
// my_message.MutableExtension(foo)
|
||||
// you will get a compile error because PrimitiveTypeTraits<int32> does not
|
||||
// you will get a compile error because PrimitiveTypeTraits<int32_t> does not
|
||||
// have a "Mutable()" method.
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
@@ -955,6 +1005,9 @@ class PrimitiveTypeTraits {
|
||||
|
||||
static inline ConstType Get(int number, const ExtensionSet& set,
|
||||
ConstType default_value);
|
||||
|
||||
static inline const ConstType* GetPtr(int number, const ExtensionSet& set,
|
||||
const ConstType& default_value);
|
||||
static inline void Set(int number, FieldType field_type, ConstType value,
|
||||
ExtensionSet* set);
|
||||
template <typename ExtendeeT>
|
||||
@@ -974,6 +1027,10 @@ class RepeatedPrimitiveTypeTraits {
|
||||
typedef RepeatedField<Type> RepeatedFieldType;
|
||||
|
||||
static inline Type Get(int number, const ExtensionSet& set, int index);
|
||||
static inline const Type* GetPtr(int number, const ExtensionSet& set,
|
||||
int index);
|
||||
static inline const RepeatedField<ConstType>* GetRepeatedPtr(
|
||||
int number, const ExtensionSet& set);
|
||||
static inline void Set(int number, int index, Type value, ExtensionSet* set);
|
||||
static inline void Add(int number, FieldType field_type, bool is_packed,
|
||||
Type value, ExtensionSet* set);
|
||||
@@ -998,10 +1055,10 @@ class PROTOBUF_EXPORT RepeatedPrimitiveDefaults {
|
||||
template <typename Type>
|
||||
friend class RepeatedPrimitiveTypeTraits;
|
||||
static const RepeatedPrimitiveDefaults* default_instance();
|
||||
RepeatedField<int32> default_repeated_field_int32_;
|
||||
RepeatedField<int64> default_repeated_field_int64_;
|
||||
RepeatedField<uint32> default_repeated_field_uint32_;
|
||||
RepeatedField<uint64> default_repeated_field_uint64_;
|
||||
RepeatedField<int32_t> default_repeated_field_int32_t_;
|
||||
RepeatedField<int64_t> default_repeated_field_int64_t_;
|
||||
RepeatedField<uint32_t> default_repeated_field_uint32_t_;
|
||||
RepeatedField<uint64_t> default_repeated_field_uint64_t_;
|
||||
RepeatedField<double> default_repeated_field_double_;
|
||||
RepeatedField<float> default_repeated_field_float_;
|
||||
RepeatedField<bool> default_repeated_field_bool_;
|
||||
@@ -1014,6 +1071,11 @@ class PROTOBUF_EXPORT RepeatedPrimitiveDefaults {
|
||||
return set.Get##METHOD(number, default_value); \
|
||||
} \
|
||||
template <> \
|
||||
inline const TYPE* PrimitiveTypeTraits<TYPE>::GetPtr( \
|
||||
int number, const ExtensionSet& set, const TYPE& default_value) { \
|
||||
return &set.GetRef##METHOD(number, default_value); \
|
||||
} \
|
||||
template <> \
|
||||
inline void PrimitiveTypeTraits<TYPE>::Set(int number, FieldType field_type, \
|
||||
TYPE value, ExtensionSet* set) { \
|
||||
set->Set##METHOD(number, field_type, value, NULL); \
|
||||
@@ -1025,6 +1087,11 @@ class PROTOBUF_EXPORT RepeatedPrimitiveDefaults {
|
||||
return set.GetRepeated##METHOD(number, index); \
|
||||
} \
|
||||
template <> \
|
||||
inline const TYPE* RepeatedPrimitiveTypeTraits<TYPE>::GetPtr( \
|
||||
int number, const ExtensionSet& set, int index) { \
|
||||
return &set.GetRefRepeated##METHOD(number, index); \
|
||||
} \
|
||||
template <> \
|
||||
inline void RepeatedPrimitiveTypeTraits<TYPE>::Set( \
|
||||
int number, int index, TYPE value, ExtensionSet* set) { \
|
||||
set->SetRepeated##METHOD(number, index, value); \
|
||||
@@ -1049,6 +1116,12 @@ class PROTOBUF_EXPORT RepeatedPrimitiveDefaults {
|
||||
set.GetRawRepeatedField(number, GetDefaultRepeatedField())); \
|
||||
} \
|
||||
template <> \
|
||||
inline const RepeatedField<TYPE>* \
|
||||
RepeatedPrimitiveTypeTraits<TYPE>::GetRepeatedPtr(int number, \
|
||||
const ExtensionSet& set) { \
|
||||
return &GetRepeated(number, set); \
|
||||
} \
|
||||
template <> \
|
||||
inline RepeatedField<TYPE>* \
|
||||
RepeatedPrimitiveTypeTraits<TYPE>::MutableRepeated( \
|
||||
int number, FieldType field_type, bool is_packed, ExtensionSet* set) { \
|
||||
@@ -1056,10 +1129,10 @@ class PROTOBUF_EXPORT RepeatedPrimitiveDefaults {
|
||||
set->MutableRawRepeatedField(number, field_type, is_packed, NULL)); \
|
||||
}
|
||||
|
||||
PROTOBUF_DEFINE_PRIMITIVE_TYPE(int32, Int32)
|
||||
PROTOBUF_DEFINE_PRIMITIVE_TYPE(int64, Int64)
|
||||
PROTOBUF_DEFINE_PRIMITIVE_TYPE(uint32, UInt32)
|
||||
PROTOBUF_DEFINE_PRIMITIVE_TYPE(uint64, UInt64)
|
||||
PROTOBUF_DEFINE_PRIMITIVE_TYPE(int32_t, Int32)
|
||||
PROTOBUF_DEFINE_PRIMITIVE_TYPE(int64_t, Int64)
|
||||
PROTOBUF_DEFINE_PRIMITIVE_TYPE(uint32_t, UInt32)
|
||||
PROTOBUF_DEFINE_PRIMITIVE_TYPE(uint64_t, UInt64)
|
||||
PROTOBUF_DEFINE_PRIMITIVE_TYPE(float, Float)
|
||||
PROTOBUF_DEFINE_PRIMITIVE_TYPE(double, Double)
|
||||
PROTOBUF_DEFINE_PRIMITIVE_TYPE(bool, Bool)
|
||||
@@ -1080,6 +1153,10 @@ class PROTOBUF_EXPORT StringTypeTraits {
|
||||
ConstType default_value) {
|
||||
return set.GetString(number, default_value);
|
||||
}
|
||||
static inline const std::string* GetPtr(int number, const ExtensionSet& set,
|
||||
ConstType default_value) {
|
||||
return &Get(number, set, default_value);
|
||||
}
|
||||
static inline void Set(int number, FieldType field_type,
|
||||
const std::string& value, ExtensionSet* set) {
|
||||
set->SetString(number, field_type, value, NULL);
|
||||
@@ -1107,6 +1184,14 @@ class PROTOBUF_EXPORT RepeatedStringTypeTraits {
|
||||
int index) {
|
||||
return set.GetRepeatedString(number, index);
|
||||
}
|
||||
static inline const std::string* GetPtr(int number, const ExtensionSet& set,
|
||||
int index) {
|
||||
return &Get(number, set, index);
|
||||
}
|
||||
static inline const RepeatedPtrField<std::string>* GetRepeatedPtr(
|
||||
int number, const ExtensionSet& set) {
|
||||
return &GetRepeated(number, set);
|
||||
}
|
||||
static inline void Set(int number, int index, const std::string& value,
|
||||
ExtensionSet* set) {
|
||||
set->SetRepeatedString(number, index, value);
|
||||
@@ -1163,6 +1248,11 @@ class EnumTypeTraits {
|
||||
ConstType default_value) {
|
||||
return static_cast<Type>(set.GetEnum(number, default_value));
|
||||
}
|
||||
static inline const ConstType* GetPtr(int number, const ExtensionSet& set,
|
||||
const ConstType& default_value) {
|
||||
return reinterpret_cast<const Type*>(
|
||||
&set.GetRefEnum(number, default_value));
|
||||
}
|
||||
static inline void Set(int number, FieldType field_type, ConstType value,
|
||||
ExtensionSet* set) {
|
||||
GOOGLE_DCHECK(IsValid(value));
|
||||
@@ -1187,6 +1277,11 @@ class RepeatedEnumTypeTraits {
|
||||
static inline ConstType Get(int number, const ExtensionSet& set, int index) {
|
||||
return static_cast<Type>(set.GetRepeatedEnum(number, index));
|
||||
}
|
||||
static inline const ConstType* GetPtr(int number, const ExtensionSet& set,
|
||||
int index) {
|
||||
return reinterpret_cast<const Type*>(
|
||||
&set.GetRefRepeatedEnum(number, index));
|
||||
}
|
||||
static inline void Set(int number, int index, ConstType value,
|
||||
ExtensionSet* set) {
|
||||
GOOGLE_DCHECK(IsValid(value));
|
||||
@@ -1206,7 +1301,10 @@ class RepeatedEnumTypeTraits {
|
||||
return *reinterpret_cast<const RepeatedField<Type>*>(
|
||||
set.GetRawRepeatedField(number, GetDefaultRepeatedField()));
|
||||
}
|
||||
|
||||
static inline const RepeatedField<Type>* GetRepeatedPtr(
|
||||
int number, const ExtensionSet& set) {
|
||||
return &GetRepeated(number, set);
|
||||
}
|
||||
static inline RepeatedField<Type>* MutableRepeated(int number,
|
||||
FieldType field_type,
|
||||
bool is_packed,
|
||||
@@ -1220,10 +1318,10 @@ class RepeatedEnumTypeTraits {
|
||||
// RepeatedField<int>. We need to be able to instantiate global static
|
||||
// objects to return as default (empty) repeated fields on non-existent
|
||||
// extensions. We would not be able to know a-priori all of the enum types
|
||||
// (values of |Type|) to instantiate all of these, so we just re-use int32's
|
||||
// default repeated field object.
|
||||
// (values of |Type|) to instantiate all of these, so we just re-use
|
||||
// int32_t's default repeated field object.
|
||||
return reinterpret_cast<const RepeatedField<Type>*>(
|
||||
RepeatedPrimitiveTypeTraits<int32>::GetDefaultRepeatedField());
|
||||
RepeatedPrimitiveTypeTraits<int32_t>::GetDefaultRepeatedField());
|
||||
}
|
||||
template <typename ExtendeeT>
|
||||
static void Register(int number, FieldType type, bool is_packed) {
|
||||
@@ -1249,6 +1347,11 @@ class MessageTypeTraits {
|
||||
ConstType default_value) {
|
||||
return static_cast<const Type&>(set.GetMessage(number, default_value));
|
||||
}
|
||||
static inline std::nullptr_t GetPtr(int number, const ExtensionSet& set,
|
||||
ConstType default_value) {
|
||||
// Cannot be implemented because of forward declared messages?
|
||||
return nullptr;
|
||||
}
|
||||
static inline MutableType Mutable(int number, FieldType field_type,
|
||||
ExtensionSet* set) {
|
||||
return static_cast<Type*>(set->MutableMessage(
|
||||
@@ -1282,7 +1385,7 @@ class MessageTypeTraits {
|
||||
}
|
||||
};
|
||||
|
||||
// forward declaration
|
||||
// forward declaration.
|
||||
class RepeatedMessageGenericTypeTraits;
|
||||
|
||||
template <typename Type>
|
||||
@@ -1297,6 +1400,16 @@ class RepeatedMessageTypeTraits {
|
||||
static inline ConstType Get(int number, const ExtensionSet& set, int index) {
|
||||
return static_cast<const Type&>(set.GetRepeatedMessage(number, index));
|
||||
}
|
||||
static inline std::nullptr_t GetPtr(int number, const ExtensionSet& set,
|
||||
int index) {
|
||||
// Cannot be implemented because of forward declared messages?
|
||||
return nullptr;
|
||||
}
|
||||
static inline std::nullptr_t GetRepeatedPtr(int number,
|
||||
const ExtensionSet& set) {
|
||||
// Cannot be implemented because of forward declared messages?
|
||||
return nullptr;
|
||||
}
|
||||
static inline MutableType Mutable(int number, int index, ExtensionSet* set) {
|
||||
return static_cast<Type*>(set->MutableRepeatedMessage(number, index));
|
||||
}
|
||||
@@ -1347,7 +1460,7 @@ RepeatedMessageTypeTraits<Type>::GetDefaultRepeatedField() {
|
||||
// optional int32 bar = 1234;
|
||||
// }
|
||||
// then "bar" will be defined in C++ as:
|
||||
// ExtensionIdentifier<Foo, PrimitiveTypeTraits<int32>, 5, false> bar(1234);
|
||||
// ExtensionIdentifier<Foo, PrimitiveTypeTraits<int32_t>, 5, false> bar(1234);
|
||||
//
|
||||
// Note that we could, in theory, supply the field number as a template
|
||||
// parameter, and thus make an instance of ExtensionIdentifier have no
|
||||
@@ -1378,6 +1491,10 @@ class ExtensionIdentifier {
|
||||
TypeTraits::template Register<ExtendeeType>(number, field_type, is_packed);
|
||||
}
|
||||
|
||||
typename TypeTraits::ConstType const& default_value_ref() const {
|
||||
return default_value_;
|
||||
}
|
||||
|
||||
private:
|
||||
const int number_;
|
||||
typename TypeTraits::ConstType default_value_;
|
||||
@@ -1386,189 +1503,10 @@ class ExtensionIdentifier {
|
||||
// -------------------------------------------------------------------
|
||||
// Generated accessors
|
||||
|
||||
// This macro should be expanded in the context of a generated type which
|
||||
// has extensions.
|
||||
//
|
||||
// We use "_proto_TypeTraits" as a type name below because "TypeTraits"
|
||||
// causes problems if the class has a nested message or enum type with that
|
||||
// name and "_TypeTraits" is technically reserved for the C++ library since
|
||||
// it starts with an underscore followed by a capital letter.
|
||||
//
|
||||
// For similar reason, we use "_field_type" and "_is_packed" as parameter names
|
||||
// below, so that "field_type" and "is_packed" can be used as field names.
|
||||
#define GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(CLASSNAME) \
|
||||
/* Has, Size, Clear */ \
|
||||
template <typename _proto_TypeTraits, \
|
||||
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
|
||||
bool _is_packed> \
|
||||
inline bool HasExtension( \
|
||||
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
|
||||
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) const { \
|
||||
return _extensions_.Has(id.number()); \
|
||||
} \
|
||||
\
|
||||
template <typename _proto_TypeTraits, \
|
||||
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
|
||||
bool _is_packed> \
|
||||
inline void ClearExtension( \
|
||||
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
|
||||
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \
|
||||
_extensions_.ClearExtension(id.number()); \
|
||||
} \
|
||||
\
|
||||
template <typename _proto_TypeTraits, \
|
||||
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
|
||||
bool _is_packed> \
|
||||
inline int ExtensionSize( \
|
||||
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
|
||||
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) const { \
|
||||
return _extensions_.ExtensionSize(id.number()); \
|
||||
} \
|
||||
\
|
||||
/* Singular accessors */ \
|
||||
template <typename _proto_TypeTraits, \
|
||||
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
|
||||
bool _is_packed> \
|
||||
inline typename _proto_TypeTraits::Singular::ConstType GetExtension( \
|
||||
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
|
||||
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) const { \
|
||||
return _proto_TypeTraits::Get(id.number(), _extensions_, \
|
||||
id.default_value()); \
|
||||
} \
|
||||
\
|
||||
template <typename _proto_TypeTraits, \
|
||||
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
|
||||
bool _is_packed> \
|
||||
inline typename _proto_TypeTraits::Singular::MutableType MutableExtension( \
|
||||
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
|
||||
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \
|
||||
return _proto_TypeTraits::Mutable(id.number(), _field_type, \
|
||||
&_extensions_); \
|
||||
} \
|
||||
\
|
||||
template <typename _proto_TypeTraits, \
|
||||
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
|
||||
bool _is_packed> \
|
||||
inline void SetExtension( \
|
||||
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
|
||||
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \
|
||||
typename _proto_TypeTraits::Singular::ConstType value) { \
|
||||
_proto_TypeTraits::Set(id.number(), _field_type, value, &_extensions_); \
|
||||
} \
|
||||
\
|
||||
template <typename _proto_TypeTraits, \
|
||||
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
|
||||
bool _is_packed> \
|
||||
inline void SetAllocatedExtension( \
|
||||
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
|
||||
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \
|
||||
typename _proto_TypeTraits::Singular::MutableType value) { \
|
||||
_proto_TypeTraits::SetAllocated(id.number(), _field_type, value, \
|
||||
&_extensions_); \
|
||||
} \
|
||||
template <typename _proto_TypeTraits, \
|
||||
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
|
||||
bool _is_packed> \
|
||||
inline void UnsafeArenaSetAllocatedExtension( \
|
||||
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
|
||||
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \
|
||||
typename _proto_TypeTraits::Singular::MutableType value) { \
|
||||
_proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type, \
|
||||
value, &_extensions_); \
|
||||
} \
|
||||
template <typename _proto_TypeTraits, \
|
||||
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
|
||||
bool _is_packed> \
|
||||
inline PROTOBUF_MUST_USE_RESULT \
|
||||
typename _proto_TypeTraits::Singular::MutableType \
|
||||
ReleaseExtension( \
|
||||
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
|
||||
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \
|
||||
return _proto_TypeTraits::Release(id.number(), _field_type, \
|
||||
&_extensions_); \
|
||||
} \
|
||||
template <typename _proto_TypeTraits, \
|
||||
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
|
||||
bool _is_packed> \
|
||||
inline typename _proto_TypeTraits::Singular::MutableType \
|
||||
UnsafeArenaReleaseExtension( \
|
||||
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
|
||||
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \
|
||||
return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type, \
|
||||
&_extensions_); \
|
||||
} \
|
||||
\
|
||||
/* Repeated accessors */ \
|
||||
template <typename _proto_TypeTraits, \
|
||||
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
|
||||
bool _is_packed> \
|
||||
inline typename _proto_TypeTraits::Repeated::ConstType GetExtension( \
|
||||
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
|
||||
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \
|
||||
int index) const { \
|
||||
return _proto_TypeTraits::Get(id.number(), _extensions_, index); \
|
||||
} \
|
||||
\
|
||||
template <typename _proto_TypeTraits, \
|
||||
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
|
||||
bool _is_packed> \
|
||||
inline typename _proto_TypeTraits::Repeated::MutableType MutableExtension( \
|
||||
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
|
||||
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \
|
||||
int index) { \
|
||||
return _proto_TypeTraits::Mutable(id.number(), index, &_extensions_); \
|
||||
} \
|
||||
\
|
||||
template <typename _proto_TypeTraits, \
|
||||
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
|
||||
bool _is_packed> \
|
||||
inline void SetExtension( \
|
||||
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
|
||||
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \
|
||||
int index, typename _proto_TypeTraits::Repeated::ConstType value) { \
|
||||
_proto_TypeTraits::Set(id.number(), index, value, &_extensions_); \
|
||||
} \
|
||||
\
|
||||
template <typename _proto_TypeTraits, \
|
||||
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
|
||||
bool _is_packed> \
|
||||
inline typename _proto_TypeTraits::Repeated::MutableType AddExtension( \
|
||||
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
|
||||
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \
|
||||
return _proto_TypeTraits::Add(id.number(), _field_type, &_extensions_); \
|
||||
} \
|
||||
\
|
||||
template <typename _proto_TypeTraits, \
|
||||
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
|
||||
bool _is_packed> \
|
||||
inline void AddExtension( \
|
||||
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
|
||||
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \
|
||||
typename _proto_TypeTraits::Repeated::ConstType value) { \
|
||||
_proto_TypeTraits::Add(id.number(), _field_type, _is_packed, value, \
|
||||
&_extensions_); \
|
||||
} \
|
||||
\
|
||||
template <typename _proto_TypeTraits, \
|
||||
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
|
||||
bool _is_packed> \
|
||||
inline const typename _proto_TypeTraits::Repeated::RepeatedFieldType& \
|
||||
GetRepeatedExtension( \
|
||||
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
|
||||
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) const { \
|
||||
return _proto_TypeTraits::GetRepeated(id.number(), _extensions_); \
|
||||
} \
|
||||
\
|
||||
template <typename _proto_TypeTraits, \
|
||||
::PROTOBUF_NAMESPACE_ID::internal::FieldType _field_type, \
|
||||
bool _is_packed> \
|
||||
inline typename _proto_TypeTraits::Repeated::RepeatedFieldType* \
|
||||
MutableRepeatedExtension( \
|
||||
const ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< \
|
||||
CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \
|
||||
return _proto_TypeTraits::MutableRepeated(id.number(), _field_type, \
|
||||
_is_packed, &_extensions_); \
|
||||
}
|
||||
|
||||
// Used to retrieve a lazy extension, may return nullptr in some environments.
|
||||
extern PROTOBUF_ATTRIBUTE_WEAK ExtensionSet::LazyMessageExtension*
|
||||
MaybeCreateLazyExtension(Arena* arena);
|
||||
|
||||
} // namespace internal
|
||||
|
||||
|
||||
Reference in New Issue
Block a user