From adf9fb31eeef639ef23b2ff22a71adaa91a263b7 Mon Sep 17 00:00:00 2001 From: zxu Date: Mon, 12 Feb 2018 17:00:25 -0500 Subject: Update FieldValue of type Reference (#775) * update FieldValue of type Reference * address change * fix bad path string literal in test * use ReferenceValue and qualified name --- Firestore/core/src/firebase/firestore/model/field_value.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'Firestore/core/src/firebase/firestore/model/field_value.h') diff --git a/Firestore/core/src/firebase/firestore/model/field_value.h b/Firestore/core/src/firebase/firestore/model/field_value.h index d43b23f..e547be3 100644 --- a/Firestore/core/src/firebase/firestore/model/field_value.h +++ b/Firestore/core/src/firebase/firestore/model/field_value.h @@ -25,6 +25,8 @@ #include #include "Firestore/core/include/firebase/firestore/geo_point.h" +#include "Firestore/core/src/firebase/firestore/model/database_id.h" +#include "Firestore/core/src/firebase/firestore/model/document_key.h" #include "Firestore/core/src/firebase/firestore/model/timestamp.h" namespace firebase { @@ -38,6 +40,12 @@ struct ServerTimestamp { bool has_previous_value_; }; +struct ReferenceValue { + DocumentKey reference; + // Does not own the DatabaseId instance. + const DatabaseId* database_id; +}; + /** * tagged-union class representing an immutable data value as stored in * Firestore. FieldValue represents all the different kinds of values @@ -103,7 +111,10 @@ class FieldValue { static FieldValue StringValue(const std::string& value); static FieldValue StringValue(std::string&& value); static FieldValue BlobValue(const uint8_t* source, size_t size); - // static FieldValue ReferenceValue(); + static FieldValue ReferenceValue(const DocumentKey& value, + const DatabaseId* database_id); + static FieldValue ReferenceValue(DocumentKey&& value, + const DatabaseId* database_id); static FieldValue GeoPointValue(const GeoPoint& value); static FieldValue ArrayValue(const std::vector& value); static FieldValue ArrayValue(std::vector&& value); @@ -133,6 +144,8 @@ class FieldValue { ServerTimestamp server_timestamp_value_; std::string string_value_; std::vector blob_value_; + // Qualified name to avoid conflict with the member function of same name. + firebase::firestore::model::ReferenceValue reference_value_; GeoPoint geo_point_value_; std::vector array_value_; std::map object_value_; -- cgit v1.2.3