Support map field

PiperOrigin-RevId: 601484393
pull/15529/head
Protobuf Team Bot 10 months ago committed by Copybara-Service
parent 9146ce6ddb
commit 8dfe58bb16
  1. 20
      src/google/protobuf/map_field.h

@ -299,6 +299,8 @@ class ContendedMapCleanTest;
class GeneratedMessageReflection;
class MapFieldAccessor;
template <typename MessageT>
struct MapDynamicFieldInfo;
struct MapFieldTestPeer;
// This class provides access to map field using reflection, which is the same
@ -800,14 +802,6 @@ class PROTOBUF_EXPORT MapValueConstRef {
return *reinterpret_cast<Message*>(data_);
}
protected:
// data_ point to a map value. MapValueConstRef does not
// own this value.
void* data_;
// type_ is 0 or a valid FieldDescriptor::CppType.
// Use "CppType()" to indicate zero.
FieldDescriptor::CppType type_;
FieldDescriptor::CppType type() const {
if (type_ == FieldDescriptor::CppType() || data_ == nullptr) {
ABSL_LOG(FATAL)
@ -817,6 +811,14 @@ class PROTOBUF_EXPORT MapValueConstRef {
return type_;
}
protected:
// data_ point to a map value. MapValueConstRef does not
// own this value.
void* data_;
// type_ is 0 or a valid FieldDescriptor::CppType.
// Use "CppType()" to indicate zero.
FieldDescriptor::CppType type_;
private:
template <typename Derived, typename K, typename V,
internal::WireFormatLite::FieldType key_wire_type,
@ -965,6 +967,8 @@ class PROTOBUF_EXPORT MapIterator {
internal::WireFormatLite::FieldType kValueFieldType>
friend class internal::MapField;
friend class internal::MapFieldBase;
template <typename MessageT>
friend struct internal::MapDynamicFieldInfo;
MapIterator(internal::MapFieldBase* map, const Descriptor* descriptor) {
map_ = map;

Loading…
Cancel
Save