21
21
#include " Firestore/core/src/api/document_reference.h"
22
22
#include " Firestore/core/src/model/resource_path.h"
23
23
#include " Firestore/core/src/util/hashing.h"
24
+ #include " absl/types/optional.h"
24
25
25
26
namespace firebase {
26
27
namespace firestore {
@@ -35,22 +36,21 @@ DocumentSnapshot DocumentSnapshot::FromDocument(
35
36
std::shared_ptr<Firestore> firestore,
36
37
model::Document document,
37
38
SnapshotMetadata metadata) {
38
- return DocumentSnapshot{std::move (firestore), document->key (),
39
- Optional<model::Document>(document),
39
+ return DocumentSnapshot{std::move (firestore), document->key (), document,
40
40
std::move (metadata)};
41
41
}
42
42
43
43
DocumentSnapshot DocumentSnapshot::FromNoDocument (
44
44
std::shared_ptr<Firestore> firestore,
45
45
model::DocumentKey key,
46
46
SnapshotMetadata metadata) {
47
- return DocumentSnapshot{std::move (firestore), std::move (key),
48
- Optional<model::Document>(), std::move (metadata)};
47
+ return DocumentSnapshot{std::move (firestore), std::move (key), absl:: nullopt ,
48
+ std::move (metadata)};
49
49
}
50
50
51
51
DocumentSnapshot::DocumentSnapshot (std::shared_ptr<Firestore> firestore,
52
52
model::DocumentKey document_key,
53
- Optional <Document> document,
53
+ absl::optional <Document> document,
54
54
SnapshotMetadata metadata)
55
55
: firestore_{std::move (firestore)},
56
56
internal_key_{std::move (document_key)},
@@ -67,7 +67,7 @@ bool DocumentSnapshot::exists() const {
67
67
return internal_document_.has_value ();
68
68
}
69
69
70
- const Optional <Document>& DocumentSnapshot::internal_document () const {
70
+ const absl::optional <Document>& DocumentSnapshot::internal_document () const {
71
71
return internal_document_;
72
72
}
73
73
@@ -79,15 +79,10 @@ const std::string& DocumentSnapshot::document_id() const {
79
79
return internal_key_.path ().last_segment ();
80
80
}
81
81
82
- Optional <google_firestore_v1_Value> DocumentSnapshot::GetValue (
82
+ absl::optional <google_firestore_v1_Value> DocumentSnapshot::GetValue (
83
83
const FieldPath& field_path) const {
84
- if (internal_document_) {
85
- auto value = (*internal_document_)->field (field_path);
86
- if (value) {
87
- return Optional<google_firestore_v1_Value>(value.value ());
88
- }
89
- }
90
- return {};
84
+ return internal_document_ ? (*internal_document_)->field (field_path)
85
+ : absl::nullopt ;
91
86
}
92
87
93
88
bool operator ==(const DocumentSnapshot& lhs, const DocumentSnapshot& rhs) {
0 commit comments