aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/core/src/firebase/firestore/model
diff options
context:
space:
mode:
authorGravatar rsgowman <rgowman@google.com>2018-03-08 11:53:37 -0500
committerGravatar GitHub <noreply@github.com>2018-03-08 11:53:37 -0500
commit2ae36f1e9671b40723dd06462b4a416e4baa5a57 (patch)
tree0a00567da114b546d4943f9cb180797b976e18a2 /Firestore/core/src/firebase/firestore/model
parentb7750b588c1d7ae9ea3891a254a39de5d3b3c572 (diff)
[De]Serialize FieldValue map_values ("Objects") (#878)
These can (recursively) contain other FieldValues.
Diffstat (limited to 'Firestore/core/src/firebase/firestore/model')
-rw-r--r--Firestore/core/src/firebase/firestore/model/field_value.cc11
-rw-r--r--Firestore/core/src/firebase/firestore/model/field_value.h13
2 files changed, 13 insertions, 11 deletions
diff --git a/Firestore/core/src/firebase/firestore/model/field_value.cc b/Firestore/core/src/firebase/firestore/model/field_value.cc
index 03cf1d4..a38a676 100644
--- a/Firestore/core/src/firebase/firestore/model/field_value.cc
+++ b/Firestore/core/src/firebase/firestore/model/field_value.cc
@@ -113,7 +113,7 @@ FieldValue& FieldValue::operator=(const FieldValue& value) {
}
case Type::Object: {
// copy-and-swap
- std::map<const std::string, const FieldValue> tmp = value.object_value_;
+ std::map<std::string, FieldValue> tmp = value.object_value_;
std::swap(object_value_, tmp);
break;
}
@@ -281,13 +281,12 @@ FieldValue FieldValue::ArrayValue(std::vector<FieldValue>&& value) {
}
FieldValue FieldValue::ObjectValue(
- const std::map<const std::string, const FieldValue>& value) {
- std::map<const std::string, const FieldValue> copy(value);
+ const std::map<std::string, FieldValue>& value) {
+ std::map<std::string, FieldValue> copy(value);
return ObjectValue(std::move(copy));
}
-FieldValue FieldValue::ObjectValue(
- std::map<const std::string, const FieldValue>&& value) {
+FieldValue FieldValue::ObjectValue(std::map<std::string, FieldValue>&& value) {
FieldValue result;
result.SwitchTo(Type::Object);
std::swap(result.object_value_, value);
@@ -418,7 +417,7 @@ void FieldValue::SwitchTo(const Type type) {
new (&array_value_) std::vector<FieldValue>();
break;
case Type::Object:
- new (&object_value_) std::map<const std::string, const FieldValue>();
+ new (&object_value_) std::map<std::string, FieldValue>();
break;
default: {} // The other types where there is nothing to worry about.
}
diff --git a/Firestore/core/src/firebase/firestore/model/field_value.h b/Firestore/core/src/firebase/firestore/model/field_value.h
index cb219f5..fc8619d 100644
--- a/Firestore/core/src/firebase/firestore/model/field_value.h
+++ b/Firestore/core/src/firebase/firestore/model/field_value.h
@@ -111,6 +111,11 @@ class FieldValue {
return string_value_;
}
+ const std::map<std::string, FieldValue>& object_value() const {
+ FIREBASE_ASSERT(tag_ == Type::Object);
+ return object_value_;
+ }
+
/** factory methods. */
static const FieldValue& NullValue();
static const FieldValue& TrueValue();
@@ -134,10 +139,8 @@ class FieldValue {
static FieldValue GeoPointValue(const GeoPoint& value);
static FieldValue ArrayValue(const std::vector<FieldValue>& value);
static FieldValue ArrayValue(std::vector<FieldValue>&& value);
- static FieldValue ObjectValue(
- const std::map<const std::string, const FieldValue>& value);
- static FieldValue ObjectValue(
- std::map<const std::string, const FieldValue>&& value);
+ static FieldValue ObjectValue(const std::map<std::string, FieldValue>& value);
+ static FieldValue ObjectValue(std::map<std::string, FieldValue>&& value);
friend bool operator<(const FieldValue& lhs, const FieldValue& rhs);
@@ -164,7 +167,7 @@ class FieldValue {
firebase::firestore::model::ReferenceValue reference_value_;
GeoPoint geo_point_value_;
std::vector<FieldValue> array_value_;
- std::map<const std::string, const FieldValue> object_value_;
+ std::map<std::string, FieldValue> object_value_;
};
};