Go to the documentation of this file.
31 #ifndef GOOGLE_PROTOBUF_MAP_ENTRY_LITE_H__
32 #define GOOGLE_PROTOBUF_MAP_ENTRY_LITE_H__
37 #include <google/protobuf/stubs/casts.h>
38 #include <google/protobuf/parse_context.h>
39 #include <google/protobuf/io/coded_stream.h>
40 #include <google/protobuf/arena.h>
41 #include <google/protobuf/arenastring.h>
42 #include <google/protobuf/generated_message_util.h>
43 #include <google/protobuf/map.h>
44 #include <google/protobuf/map_type_handler.h>
45 #include <google/protobuf/port.h>
46 #include <google/protobuf/wire_format_lite.h>
48 #include <google/protobuf/port_def.inc>
50 #error "You cannot SWIG proto headers"
56 template <
typename Derived,
typename Key,
typename Value,
60 template <
typename Derived,
typename Key,
typename Value,
75 template <
bool is_enum,
bool is_message,
bool is_
stringlike,
typename T>
80 template <
bool is_message,
bool is_
stringlike,
typename T>
81 struct MoveHelper<
true, is_message, is_stringlike,
T> {
88 template <
bool is_
stringlike,
typename T>
89 struct MoveHelper<
false,
true, is_stringlike,
T> {
104 struct MapEntryFuncs {
125 size_t inner_length =
128 static_cast<uint32_t>(inner_length));
133 return 2 + KeyTypeHandler::GetCachedSize(
key) +
134 ValueTypeHandler::GetCachedSize(
value);
141 template <
typename Derived,
typename Base,
typename Key,
typename Value,
144 class MapEntryImpl :
public Base {
197 if (Base::GetArenaForAllocation() !=
nullptr)
return;
198 KeyTypeHandler::DeleteNoArena(
key_);
199 ValueTypeHandler::DeleteNoArena(
value_);
205 return KeyTypeHandler::GetExternalReference(
key_);
208 return ValueTypeHandler::DefaultIfNotInitialized(
value_);
212 return KeyTypeHandler::EnsureMutable(&
key_, Base::GetArenaForAllocation());
216 return ValueTypeHandler::EnsureMutable(&
value_,
217 Base::GetArenaForAllocation());
227 MergeFromInternal(*::google::protobuf::internal::DownCast<const Derived*>(&other));
231 while (!
ctx->Done(&
ptr)) {
239 if (!Derived::ValidateKey(
key))
return nullptr;
277 KeyTypeHandler::GetCachedSize(
key())
280 ValueTypeHandler::GetCachedSize(
value())
290 Derived* entry = Arena::CreateMessage<Derived>(
arena);
298 if (
from._has_bits_[0]) {
299 if (
from.has_key()) {
300 KeyTypeHandler::EnsureMutable(&
key_, Base::GetArenaForAllocation());
304 if (
from.has_value()) {
305 ValueTypeHandler::EnsureMutable(&
value_, Base::GetArenaForAllocation());
307 Base::GetArenaForAllocation());
323 template <
typename MapField,
typename Map>
328 if (
entry_ !=
nullptr &&
entry_->GetArenaForAllocation() ==
nullptr)
348 static_assert(
kTagSize == 1,
"tag size must be 1");
352 if (PROTOBUF_PREDICT_TRUE(map_size !=
map_->
size())) {
362 if (
input->ExpectAtEnd())
return true;
380 if (PROTOBUF_PREDICT_FALSE(!
ptr || !Derived::ValidateKey(&
key_))) {
386 if (PROTOBUF_PREDICT_TRUE(map_size !=
map_->
size())) {
391 if (PROTOBUF_PREDICT_FALSE(!
ptr ||
396 if (PROTOBUF_PREDICT_TRUE(
ctx->Done(&
ptr)))
return ptr;
397 if (!
ptr)
return nullptr;
404 if (!
ptr)
return nullptr;
410 if (!
ptr)
return nullptr;
418 template <
typename UnknownType>
420 bool (*is_valid)(
int),
425 if (!
ptr)
return nullptr;
426 if (is_valid(entry->value())) {
430 metadata->mutable_unknown_fields<UnknownType>());
467 typedef MoveHelper<KeyTypeHandler::kIsEnum, KeyTypeHandler::kIsMessage,
468 KeyTypeHandler::kWireType ==
472 typedef MoveHelper<ValueTypeHandler::kIsEnum, ValueTypeHandler::kIsMessage,
473 ValueTypeHandler::kWireType ==
515 template <
typename T,
typename Key,
typename Value,
519 kKeyFieldType, kValueFieldType> {
537 template <
typename Derived>
538 struct DeconstructMapEntry;
555 template <
typename Key,
typename PtrToKeyValuePair>
564 template <
typename T>
565 struct CompareByFirstField {
569 template <
typename T>
570 struct CompareByDerefFirst {
576 template <WireFormatLite::FieldType FieldType>
578 template <
typename T>
606 template <
typename T>
608 return const_cast<T*
>(&
x);
612 template <
typename MapEntryType>
613 struct MapEntryHelper;
615 template <
typename T,
typename Key,
typename Value,
652 #include <google/protobuf/port_undef.inc>
654 #endif // GOOGLE_PROTOBUF_MAP_ENTRY_LITE_H__
MapTypeHandler< kKeyFieldType, Key > KeyTypeHandler
static const int kKeyFieldNumber
const char * ReadTag(const char *p, uint32 *out, uint32 max_tag=0)
void InternalArenaConstructable_
int GetCachedSize() const override
static const WireFormatLite::FieldType kEntryValueFieldType
Arena * GetArena(MessageLite *msg, int64 arena_offset)
const Descriptor::ReservedRange value
ValueMapEntryAccessorType * mutable_value()
const Value & entry_value() const
static const T & From(const T &x)
MapTypeHandler< kValueFieldType, Value > ValueTypeHandler
void MergeFrom(const MapEntryLite &other)
const Value & value() const
void UnsafeSetTaggedPointer(TaggedPtr< ::std::string > value)
const char * UnknownFieldParse(uint32 tag, std::string *unknown, const char *ptr, ParseContext *ctx)
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntryLite)
OPENSSL_EXPORT pem_password_cb void * u
::uint8_t * _InternalSerialize(::uint8_t *ptr, io::EpsCopyOutputStream *stream) const override
static const int kValueFieldNumber
#define T(upbtypeconst, upbtype, ctype, default_value)
grpc_core::ScopedArenaPtr arena
void CheckTypeAndMergeFrom(const MessageLite &other) override
size_t ByteSizeLong() const override
MapEntryImpl< T, MessageLite, Key, Value, kKeyFieldType, kValueFieldType > SuperType
static const int kKeyFieldNumber
static const int kValueFieldNumber
bool ReadBeyondKeyValuePair(io::CodedInputStream *input) PROTOBUF_COLD
std::string GetTypeName() const override
void UseKeyAndValueFromEntry()
static void Move(T *src, T *dest)
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
int Read(int fd, void *buf, unsigned int count)
static void * tag(intptr_t t)
#define GOOGLE_PROTOBUF_PARSER_ASSERT(predicate)
MoveHelper< KeyTypeHandler::kIsEnum, KeyTypeHandler::kIsMessage, KeyTypeHandler::kWireType==WireFormatLite::WIRETYPE_LENGTH_DELIMITED, Key > KeyMover
void MergeFromInternal(const MapEntryImpl &from)
void WriteLengthDelimited(uint32 num, StringPiece val, std::string *s)
KeyTypeHandler::TypeOnMemory KeyOnMemory
static const uint8 kKeyTag
MapEntryImpl * NewEntry()
static int GetCachedSize(const Key &key, const Value &value)
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntryImpl)
static size_t VarintSize32(uint32 value)
static uint8_t * InternalSerialize(int field_number, const Key &key, const Value &value, uint8_t *ptr, io::EpsCopyOutputStream *stream)
MapTypeHandler< kValueFieldType, Value > ValueTypeHandler
KeyTypeHandler::TypeOnMemory KeyOnMemory
static const uint8 kValueTag
bool operator()(const T &a, const T &b) const
static const WireFormatLite::FieldType kEntryKeyFieldType
def Merge(text, message, allow_unknown_extension=False, allow_field_number=False, descriptor_pool=None, allow_unknown_field=False)
void ValidateValue(const Json &actual, const Json &expected)
static const size_t kTagSize
ValueTypeHandler::MapEntryAccessorType ValueMapEntryAccessorType
virtual const ValueMapEntryAccessorType & value() const
Base * New(Arena *arena) const override
bool IsInitialized() const override
MapEntryFuncs< Key, Value, kKeyFieldType, kValueFieldType > Funcs
MapEntryHelper(const MapPair< Key, Value > &map_pair)
KeyTypeHandler::MapEntryAccessorType KeyMapEntryAccessorType
SortItem(PtrToKeyValuePair p)
MoveHelper< ValueTypeHandler::kIsEnum, ValueTypeHandler::kIsMessage, ValueTypeHandler::kWireType==WireFormatLite::WIRETYPE_LENGTH_DELIMITED, Value > ValueMover
const Key & entry_key() const
static void Move(T *src, T *dest)
bool MergePartialFromCodedStream(io::CodedInputStream *input)
int Write(int fd, const void *buf, unsigned int count)
static void Move(T *src, T *dest)
static size_t ByteSizeLong(const Key &key, const Value &value)
ValueTypeHandler::TypeOnMemory ValueOnMemory
internal::KeyMatcher< M > Key(M inner_matcher)
MapEntryImpl(Arena *arena)
EntryType * NewEntry() const
static void Move(T *src, T *dest)
const char * _InternalParse(const char *ptr, ParseContext *ctx)
internal::InternalMetadata _internal_metadata_
static void Move(T *src, int *dest)
const char * ParseWithEnumValidation(const char *ptr, ParseContext *ctx, bool(*is_valid)(int), uint32_t field_num, InternalMetadata *metadata)
const char * _InternalParse(const char *ptr, ParseContext *ctx) final
static uint8 * WriteVarint32ToArray(uint32 value, uint8 *target)
MapEntryLite(Arena *arena)
MapTypeHandler< kKeyFieldType, Key > KeyTypeHandler
static void Move(int *src, T *dest)
KeyMapEntryAccessorType * mutable_key()
size_type erase(const key_type &key)
ValueTypeHandler::TypeOnMemory ValueOnMemory
void MapEntryHasMergeTypeTrait
MapTypeHandler< kKeyFieldType, Key > KeyTypeHandler
MapTypeHandler< kValueFieldType, Value > ValueTypeHandler
bool operator()(const T &a, const T &b) const
virtual const KeyMapEntryAccessorType & key() const
void DestructorSkippable_
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:19