diff options
author | Jisi Liu <jisi.liu@gmail.com> | 2017-08-18 16:25:35 -0700 |
---|---|---|
committer | Jisi Liu <jisi.liu@gmail.com> | 2017-08-18 16:25:35 -0700 |
commit | 139775ccc040a07e07c5407e34834dab27928cbc (patch) | |
tree | c500f4eabfea9d2e059f18b7d612c6e2a2db3ad5 /src/google/protobuf/map_field.h | |
parent | 1825d6d8f0aedcd7966c5c137a71e46ae650b3da (diff) | |
parent | 26ac3e8e242f1cd6de15291a9973905a14b546ba (diff) | |
download | protobuf-139775ccc040a07e07c5407e34834dab27928cbc.tar.gz protobuf-139775ccc040a07e07c5407e34834dab27928cbc.tar.bz2 protobuf-139775ccc040a07e07c5407e34834dab27928cbc.zip |
Merge remote-tracking branch 'origin/3.4.x' into mergemaster
Diffstat (limited to 'src/google/protobuf/map_field.h')
-rw-r--r-- | src/google/protobuf/map_field.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/google/protobuf/map_field.h b/src/google/protobuf/map_field.h index 9d5a328e..bd478901 100644 --- a/src/google/protobuf/map_field.h +++ b/src/google/protobuf/map_field.h @@ -170,6 +170,7 @@ class LIBPROTOBUF_EXPORT MapFieldBase { // IncreaseIterator() is called by operator++() of MapIterator only. // It implements the ++ operator of MapIterator. virtual void IncreaseIterator(MapIterator* map_iter) const = 0; + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldBase); }; // This class provides common Map Reflection implementations for generated @@ -199,6 +200,7 @@ class TypeDefinedMapFieldBase : public MapFieldBase { void IncreaseIterator(MapIterator* map_iter) const; virtual void SetMapIteratorValue(MapIterator* map_iter) const = 0; + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeDefinedMapFieldBase); }; // This class provides access to map field using generated api. It is used for @@ -231,6 +233,9 @@ class MapField : public TypeDefinedMapFieldBase<Key, T> { typedef typename MapIf<kIsValueEnum, T, const T&>::type CastValueType; public: + typedef typename Derived::SuperType EntryTypeTrait; + typedef Map<Key, T> MapType; + MapField() {} explicit MapField(Arena* arena) : TypeDefinedMapFieldBase<Key, T>(arena), impl_(arena) {} @@ -287,6 +292,15 @@ class MapField : public TypeDefinedMapFieldBase<Key, T> { friend class ::google::protobuf::Arena; friend class MapFieldStateTest; // For testing, it needs raw access to impl_ + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapField); +}; + +template <typename MEntry> +struct MapEntryToMapField { + typedef DeconstructMapEntry<typename MEntry::SuperType> T; + typedef MapField<MEntry, typename T::Key, typename T::Value, T::kKeyFieldType, + T::kValueFieldType, T::default_enum_value> + MapFieldType; }; class LIBPROTOBUF_EXPORT DynamicMapField: public TypeDefinedMapFieldBase<MapKey, MapValueRef> { @@ -314,6 +328,7 @@ class LIBPROTOBUF_EXPORT DynamicMapField: public TypeDefinedMapFieldBase<MapKey, void SyncMapWithRepeatedFieldNoLock() const; size_t SpaceUsedExcludingSelfNoLock() const; void SetMapIteratorValue(MapIterator* map_iter) const; + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMapField); }; } // namespace internal @@ -338,6 +353,10 @@ class LIBPROTOBUF_EXPORT MapKey { MapKey(const MapKey& other) : type_(0) { CopyFrom(other); } + MapKey& operator=(const MapKey& other) { + CopyFrom(other); + return *this; + } ~MapKey() { if (type_ == FieldDescriptor::CPPTYPE_STRING) { @@ -697,6 +716,7 @@ class LIBPROTOBUF_EXPORT MapValueRef { void* data_; // type_ is 0 or a valid FieldDescriptor::CppType. int type_; + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapValueRef); }; #undef TYPE_CHECK @@ -718,6 +738,11 @@ class LIBPROTOBUF_EXPORT MapIterator { ~MapIterator() { map_->DeleteIterator(this); } + MapIterator& operator=(const MapIterator& other) { + map_ = other.map_; + map_->CopyIterator(this, other); + return *this; + } friend bool operator==(const MapIterator& a, const MapIterator& b) { return a.map_->EqualIterator(a, b); } |