File tree Expand file tree Collapse file tree 10 files changed +105
-11
lines changed
include/firebase/firestore Expand file tree Collapse file tree 10 files changed +105
-11
lines changed Original file line number Diff line number Diff line change @@ -55,8 +55,10 @@ template <typename T>
55
55
Future<T> FailedFuture () {
56
56
static auto * future = new Future<T>(FailedFuture<T>(
57
57
Error::kErrorFailedPrecondition ,
58
- " This instance is in an invalid state. This is because the underlying "
59
- " Firestore instance has been destructed." ));
58
+ " The object that issued this future is in an invalid state. This can be "
59
+ " because:\n - the object was default-constructed and never reassigned;\n "
60
+ " - the object was moved from;\n - the Firestore instance with which the "
61
+ " object was associated has been destroyed." ));
60
62
return *future;
61
63
}
62
64
Original file line number Diff line number Diff line change @@ -159,6 +159,19 @@ class DocumentChange {
159
159
*/
160
160
virtual std::size_t new_index () const ;
161
161
162
+ /* *
163
+ * @brief Returns true if this `DocumentChange` is valid, false if it is
164
+ * not valid. An invalid `DocumentChange` could be the result of:
165
+ * - Creating a `DocumentChange` using the default constructor.
166
+ * - Moving from the `DocumentChange`.
167
+ * - Deleting your Firestore instance, which will invalidate all
168
+ * `DocumentChange` instances associated with it.
169
+ *
170
+ * @return true if this `DocumentChange` is valid, false if this
171
+ * `DocumentChange` is invalid.
172
+ */
173
+ bool is_valid () const { return internal_ != nullptr ; }
174
+
162
175
private:
163
176
friend class FirestoreInternal ;
164
177
friend class Wrapper ;
Original file line number Diff line number Diff line change @@ -285,16 +285,17 @@ class DocumentReference {
285
285
callback);
286
286
287
287
/* *
288
- * @brief Returns true if this DocumentReference is valid, false if it is not
289
- * valid. An invalid DocumentReference could be the result of:
290
- * - Creating a DocumentReference with the default constructor.
291
- * - Calling CollectionReference::Parent() on a CollectionReference that is
292
- * not a subcollection.
288
+ * @brief Returns true if this `DocumentReference` is valid, false if it is
289
+ * not valid. An invalid `DocumentReference` could be the result of:
290
+ * - Creating a `DocumentReference` using the default constructor.
291
+ * - Moving from the `DocumentReference`.
292
+ * - Calling `CollectionReference::Parent()` on a `CollectionReference` that
293
+ * is not a subcollection.
293
294
* - Deleting your Firestore instance, which will invalidate all
294
- * DocumentReference instances associated with it.
295
+ * ` DocumentReference` instances associated with it.
295
296
*
296
- * @return true if this DocumentReference is valid, false if this
297
- * DocumentReference is invalid.
297
+ * @return true if this ` DocumentReference` is valid, false if this
298
+ * ` DocumentReference` is invalid.
298
299
*/
299
300
bool is_valid () const { return internal_ != nullptr ; }
300
301
Original file line number Diff line number Diff line change @@ -229,6 +229,19 @@ class DocumentSnapshot {
229
229
const FieldPath& field,
230
230
ServerTimestampBehavior stb = ServerTimestampBehavior::kDefault ) const ;
231
231
232
+ /* *
233
+ * @brief Returns true if this `DocumentSnapshot` is valid, false if it is
234
+ * not valid. An invalid `DocumentSnapshot` could be the result of:
235
+ * - Creating a `DocumentSnapshot` with the default constructor.
236
+ * - Moving from the `DocumentSnapshot`.
237
+ * - Deleting your Firestore instance, which will invalidate all
238
+ * `DocumentSnapshot` instances associated with it.
239
+ *
240
+ * @return true if this `DocumentSnapshot` is valid, false if this
241
+ * `DocumentSnapshot` is invalid.
242
+ */
243
+ bool is_valid () const { return internal_ != nullptr ; }
244
+
232
245
/* *
233
246
* Returns a string representation of this `DocumentSnapshot` for
234
247
* logging/debugging purposes.
Original file line number Diff line number Diff line change @@ -122,6 +122,19 @@ class FieldPath final {
122
122
*/
123
123
static FieldPath DocumentId ();
124
124
125
+ /* *
126
+ * @brief Returns true if this `FieldPath` is valid, false if it is not valid.
127
+ * An invalid `FieldPath` could be the result of:
128
+ * - Creating a `FieldPath` using the default constructor.
129
+ * - Moving from the `FieldPath`.
130
+ * - Deleting your Firestore instance, which will invalidate all
131
+ * `FieldPath` instances associated with it.
132
+ *
133
+ * @return true if this `FieldPath` is valid, false if this `FieldPath` is
134
+ * invalid.
135
+ */
136
+ bool is_valid () const { return internal_ != nullptr ; }
137
+
125
138
/* *
126
139
* Returns a string representation of this `FieldPath` for
127
140
* logging/debugging purposes.
Original file line number Diff line number Diff line change @@ -277,8 +277,9 @@ class FieldValue final {
277
277
* @brief Returns `true` if this `FieldValue` is valid, `false` if it is not
278
278
* valid. An invalid `FieldValue` could be the result of:
279
279
* - Creating a `FieldValue` using the default constructor.
280
+ * - Moving from the `FieldValue`.
280
281
* - Calling `DocumentSnapshot::Get(field)` for a field that does not exist
281
- * in the document.
282
+ * in the document.
282
283
*
283
284
* @return `true` if this `FieldValue` is valid, `false` if this `FieldValue`
284
285
* is invalid.
Original file line number Diff line number Diff line change @@ -94,6 +94,19 @@ class ListenerRegistration {
94
94
*/
95
95
virtual void Remove ();
96
96
97
+ /* *
98
+ * @brief Returns true if this `ListenerRegistration` is valid, false if it is
99
+ * not valid. An invalid `ListenerRegistration` could be the result of:
100
+ * - Creating a `ListenerRegistration` using the default constructor.
101
+ * - Moving from the `ListenerRegistration`.
102
+ * - Deleting your Firestore instance, which will invalidate all
103
+ * `ListenerRegistration` instances associated with it.
104
+ *
105
+ * @return true if this `ListenerRegistration` is valid, false if this
106
+ * `ListenerRegistration` is invalid.
107
+ */
108
+ bool is_valid () const { return internal_ != nullptr ; }
109
+
97
110
private:
98
111
friend class DocumentReferenceInternal ;
99
112
friend class FirestoreInternal ;
Original file line number Diff line number Diff line change @@ -637,6 +637,18 @@ class Query {
637
637
std::function<void (const QuerySnapshot&, Error, const std::string&)>
638
638
callback);
639
639
640
+ /* *
641
+ * @brief Returns true if this `Query` is valid, false if it is not valid. An
642
+ * invalid `Query` could be the result of:
643
+ * - Creating a `Query` using the default constructor.
644
+ * - Moving from the `Query`.
645
+ * - Deleting your Firestore instance, which will invalidate all `Query`
646
+ * instances associated with it.
647
+ *
648
+ * @return true if this `Query` is valid, false if this `Query` is invalid.
649
+ */
650
+ bool is_valid () const { return internal_ != nullptr ; }
651
+
640
652
private:
641
653
friend bool operator ==(const Query& lhs, const Query& rhs);
642
654
Original file line number Diff line number Diff line change @@ -150,6 +150,19 @@ class QuerySnapshot {
150
150
*/
151
151
virtual std::size_t size () const ;
152
152
153
+ /* *
154
+ * @brief Returns true if this `QuerySnapshot` is valid, false if it is not
155
+ * valid. An invalid `QuerySnapshot` could be the result of:
156
+ * - Creating a `QuerySnapshot` using the default constructor.
157
+ * - Moving from the `QuerySnapshot`.
158
+ * - Deleting your Firestore instance, which will invalidate all
159
+ * `QuerySnapshot` instances associated with it.
160
+ *
161
+ * @return true if this `QuerySnapshot` is valid, false if this
162
+ * `QuerySnapshot` is invalid.
163
+ */
164
+ bool is_valid () const { return internal_ != nullptr ; }
165
+
153
166
private:
154
167
friend class EventListenerInternal ;
155
168
friend class FirestoreInternal ;
Original file line number Diff line number Diff line change @@ -157,6 +157,19 @@ class WriteBatch {
157
157
*/
158
158
virtual Future<void > Commit ();
159
159
160
+ /* *
161
+ * @brief Returns true if this `WriteBatch` is valid, false if it is not
162
+ * valid. An invalid `WriteBatch` could be the result of:
163
+ * - Creating a `WriteBatch` using the default constructor.
164
+ * - Moving from the `WriteBatch`.
165
+ * - Deleting your Firestore instance, which will invalidate all
166
+ * `WriteBatch` instances associated with it.
167
+ *
168
+ * @return true if this `WriteBatch` is valid, false if this `WriteBatch` is
169
+ * invalid.
170
+ */
171
+ bool is_valid () const { return internal_ != nullptr ; }
172
+
160
173
private:
161
174
friend class FirestoreInternal ;
162
175
friend class WriteBatchInternal ;
You can’t perform that action at this time.
0 commit comments