19
19
// shamelessly stolen and modified from rtdb's header file, melded with the
20
20
// (java) firestore api.
21
21
22
- #ifndef FIRESTORE_CORE_INCLUDE_FIREBASE_FIRESTORE_DATABASE_REFERENCE_H_
23
- #define FIRESTORE_CORE_INCLUDE_FIREBASE_FIRESTORE_DATABASE_REFERENCE_H_
22
+ #ifndef FIRESTORE_CORE_INCLUDE_FIREBASE_FIRESTORE_DOCUMENT_REFERENCE_H_
23
+ #define FIRESTORE_CORE_INCLUDE_FIREBASE_FIRESTORE_DOCUMENT_REFERENCE_H_
24
24
25
25
#include < string>
26
26
#include < unordered_map>
@@ -89,7 +89,7 @@ class DocumentReference {
89
89
/* *
90
90
* @brief Default constructor. This creates an invalid DocumentReference.
91
91
* Attempting to perform any operations on this reference will fail (and cause
92
- * a crash) unless a / valid DocumentReference has been assigned to it.
92
+ * a crash) unless a valid DocumentReference has been assigned to it.
93
93
*/
94
94
DocumentReference ();
95
95
@@ -121,7 +121,7 @@ class DocumentReference {
121
121
*
122
122
* @returns Reference to the destination DocumentReference.
123
123
*/
124
- virtual DocumentReference& operator =(const DocumentReference& reference);
124
+ DocumentReference& operator =(const DocumentReference& reference);
125
125
126
126
/* *
127
127
* @brief Move assignment operator. Moving is an efficient operation for
@@ -131,19 +131,30 @@ class DocumentReference {
131
131
*
132
132
* @returns Reference to the destination DocumentReference.
133
133
*/
134
- virtual DocumentReference& operator =(DocumentReference&& reference);
134
+ DocumentReference& operator =(DocumentReference&& reference);
135
135
136
136
/* *
137
- * @brief Gets the Firestore instance associated with this document reference.
137
+ * @brief Returns the Firestore instance associated with this document
138
+ * reference.
138
139
*
139
140
* The pointer will remain valid indefinitely.
140
141
*
141
142
* @returns Firebase Firestore instance that this DocumentReference refers to.
142
143
*/
143
- virtual Firestore* firestore () const ;
144
+ virtual const Firestore* firestore () const ;
144
145
145
146
/* *
146
- * @brief Gets the string id of this document location.
147
+ * @brief Returns the Firestore instance associated with this document
148
+ * reference.
149
+ *
150
+ * The pointer will remain valid indefinitely.
151
+ *
152
+ * @returns Firebase Firestore instance that this DocumentReference refers to.
153
+ */
154
+ virtual Firestore* firestore ();
155
+
156
+ /* *
157
+ * @brief Returns the string id of this document location.
147
158
*
148
159
* The pointer is only valid while the DocumentReference remains in memory.
149
160
*
@@ -153,14 +164,14 @@ class DocumentReference {
153
164
virtual const char * id () const ;
154
165
155
166
/* *
156
- * @brief Gets the string id of this document location.
167
+ * @brief Returns the string id of this document location.
157
168
*
158
169
* @returns String id of this document location.
159
170
*/
160
171
virtual std::string id_string () const ;
161
172
162
173
/* *
163
- * @brief Gets the path of this document (relative to the root of the
174
+ * @brief Returns the path of this document (relative to the root of the
164
175
* database) as a slash-separated string.
165
176
*
166
177
* The pointer is only valid while the DocumentReference remains in memory.
@@ -171,22 +182,22 @@ class DocumentReference {
171
182
virtual const char * path () const ;
172
183
173
184
/* *
174
- * @brief Gets the path of this document (relative to the root of the
185
+ * @brief Returns the path of this document (relative to the root of the
175
186
* database) as a slash-separated string.
176
187
*
177
188
* @returns String path of this document location.
178
189
*/
179
190
virtual std::string path_string () const ;
180
191
181
192
/* *
182
- * @brief Gets a CollectionReference to the collection that contains this
193
+ * @brief Returns a CollectionReference to the collection that contains this
183
194
* document.
184
195
*/
185
196
virtual CollectionReference get_parent () const ;
186
197
187
198
/* *
188
- * @brief Gets a CollectionReference instance that refers to the subcollection
189
- * at the specified path relative to this document.
199
+ * @brief Returns a CollectionReference instance that refers to the
200
+ * subcollection at the specified path relative to this document.
190
201
*
191
202
* @param[in] collectionPath A slash-separated relative path to a
192
203
* subcollection. The pointer only needs to be valid during this call.
@@ -196,8 +207,8 @@ class DocumentReference {
196
207
virtual CollectionReference Collection (const char * collectionPath) const ;
197
208
198
209
/* *
199
- * @brief Gets a CollectionReference instance that refers to the subcollection
200
- * at the specified path relative to this document.
210
+ * @brief Returns a CollectionReference instance that refers to the
211
+ * subcollection at the specified path relative to this document.
201
212
*
202
213
* @param[in] collectionPath A slash-separated relative path to a
203
214
* subcollection.
@@ -208,7 +219,7 @@ class DocumentReference {
208
219
const std::string& collectionPath) const ;
209
220
210
221
/* *
211
- * @brief Reads the document referenced by this DocumentReference
222
+ * @brief Reads the document referenced by this DocumentReference.
212
223
*
213
224
* @return A Future that will be resolved with the contents of the Document at
214
225
* this DocumentReference.
@@ -286,7 +297,8 @@ class DocumentReference {
286
297
* @brief Starts listening to the document referenced by this
287
298
* DocumentReference.
288
299
*
289
- * @param[in] callback function or lambda to call.
300
+ * @param[in] callback function or lambda to call. When this function is
301
+ * called, exactly one of the parameters will be non-null.
290
302
*
291
303
* @return A registration object that can be used to remove the listener.
292
304
*
@@ -301,7 +313,8 @@ class DocumentReference {
301
313
* DocumentReference.
302
314
*
303
315
* @param[in] options The options to use for this listen.
304
- * @param[in] callback function or lambda to call.
316
+ * @param[in] callback function or lambda to call. When this function is
317
+ * called, exactly one of the parameters will be non-null.
305
318
*
306
319
* @return A registration object that can be used to remove the listener.
307
320
*
@@ -359,4 +372,4 @@ struct hash<firebase::firestore::DocumentReference> {
359
372
};
360
373
} // namespace std
361
374
362
- #endif // FIRESTORE_CORE_INCLUDE_FIREBASE_FIRESTORE_DATABASE_REFERENCE_H_
375
+ #endif // FIRESTORE_CORE_INCLUDE_FIREBASE_FIRESTORE_DOCUMENT_REFERENCE_H_
0 commit comments