Skip to content

Commit f5eadba

Browse files
amabluea-maurice
authored andcommitted
Gave DataSnapshot a default constructor, so that it can be used by developers
to hold on to DataSnapshots. PiperOrigin-RevId: 246156219
1 parent 18b17c0 commit f5eadba

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

database/src/include/firebase/database/data_snapshot.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
#define FIREBASE_DATABASE_CLIENT_CPP_SRC_INCLUDE_FIREBASE_DATABASE_DATA_SNAPSHOT_H_
1717

1818
#include <stddef.h>
19+
1920
#include <string>
21+
2022
#include "firebase/internal/common.h"
2123
#include "firebase/variant.h"
2224

@@ -45,6 +47,13 @@ class DatabaseReference;
4547
#endif // SWIG
4648
class DataSnapshot {
4749
public:
50+
/// @brief Default constructor.
51+
///
52+
/// This DataSnapshot contains nothing and is considered invalid (i.e.
53+
/// is_valid() == false). Use this to construct an empty DataSnapshot that you
54+
/// will later populate with data from a database callback.
55+
DataSnapshot() : internal_(nullptr) {}
56+
4857
#ifdef INTERNAL_EXPERIMENTAL
4958
explicit DataSnapshot(internal::DataSnapshotInternal* internal);
5059
#endif

0 commit comments

Comments
 (0)