aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/map_field.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/map_field.h')
-rw-r--r--src/google/protobuf/map_field.h25
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);
}