firebase::database::DataSnapshot

#include <data_snapshot.h>

A DataSnapshot instance contains data from a Firebase Database location.

Summary

Any time you read Database data, you receive the data as a DataSnapshot. These are efficiently-generated and cannot be changed. To modify data, use DatabaseReference::SetValue() or DatabaseReference::RunTransaction().

Constructors and Destructors

DataSnapshot(const DataSnapshot & snapshot)
Copy constructor.
DataSnapshot(DataSnapshot && snapshot)
Move constructor.
~DataSnapshot()
Destructor.

Public functions

Child(const char *path) const
Get a DataSnapshot for the location at the specified relative path.
Child(const std::string & path) const
Get a DataSnapshot for the location at the specified relative path.
Exists() const
bool
Returns true if the data is non-empty.
GetChildren() const
std::vector< DataSnapshot >
Get all the immediate children of this location.
GetChildrenCount() const
size_t
Get the number of children of this location.
GetKey() const
const char *
Get the key name of the source location of this snapshot.
GetKeyString() const
std::string
Get the key name of the source location of this snapshot.
GetPriority() const
Get the priority of the data contained in this snapshot.
GetReference() const
Obtain a DatabaseReference to the source location for this snapshot.
GetValue() const
Get the value of the data contained in this snapshot.
HasChild(const char *path) const
bool
Does this DataSnapshot have data at a particular location?
HasChild(const std::string & path) const
bool
Does this DataSnapshot have data at a particular location?
HasChildren() const
bool
Does this DataSnapshot have any children at all?
IsValid() const
bool
Returns true if this snapshot is valid, false if it is not valid.
operator=(const DataSnapshot & snapshot)
Copy assignment operator.
operator=(DataSnapshot && snapshot)
Move assignment operator.

Public functions

Child

DataSnapshot Child(
  const char *path
) const 

Get a DataSnapshot for the location at the specified relative path.

Details
Parameters
path
Path relative to this snapshot's location. It only needs to be valid during this call.
Returns
A DataSnapshot corresponding to specified child location.

Child

DataSnapshot Child(
  const std::string & path
) const 

Get a DataSnapshot for the location at the specified relative path.

Details
Parameters
path
Path relative to this snapshot's location.
Returns
A DataSnapshot corresponding to specified child location.

DataSnapshot

 DataSnapshot(
  const DataSnapshot & snapshot
)

Copy constructor.

DataSnapshots are immutable, so they can be efficiently copied.

Details
Parameters
snapshot
DataSnapshot to copy.

DataSnapshot

 DataSnapshot(
  DataSnapshot && snapshot
)

Move constructor.

DataSnapshots are immutable, so they can be efficiently moved.

Details
Parameters
snapshot
DataSnapshot to move into this one.

Exists

bool Exists() const 

Returns true if the data is non-empty.

GetChildren

std::vector< DataSnapshot > GetChildren() const 

Get all the immediate children of this location.

Details
Returns
The immediate children of this snapshot.

GetChildrenCount

size_t GetChildrenCount() const 

Get the number of children of this location.

Details
Returns
The number of immediate children of this snapshot.

GetKey

const char * GetKey() const 

Get the key name of the source location of this snapshot.

Note:The returned pointer is only guaranteed to be valid while the DataSnapshot is still in memory.

Details
Returns
Key name of the source location of this snapshot.

GetKeyString

std::string GetKeyString() const 

Get the key name of the source location of this snapshot.

Details
Returns
Key name of the source location of this snapshot.

GetPriority

Variant GetPriority() const 

Get the priority of the data contained in this snapshot.

Details
Returns
The value of this location's Priority relative to its siblings.

GetReference

DatabaseReference GetReference() const 

Obtain a DatabaseReference to the source location for this snapshot.

Details
Returns
A DatabaseReference corresponding to same location as this snapshot.

GetValue

Variant GetValue() const 

Get the value of the data contained in this snapshot.

Details
Returns
The value of the data contained in this location.

HasChild

bool HasChild(
  const char *path
) const 

Does this DataSnapshot have data at a particular location?

Details
Parameters
path
Path relative to this snapshot's location. The pointer only needs to be valid during this call.
Returns
True if the snapshot has data at the specified location, false if not.

HasChild

bool HasChild(
  const std::string & path
) const 

Does this DataSnapshot have data at a particular location?

Details
Parameters
path
Path relative to this snapshot's location.
Returns
True if the snapshot has data at the specified location, false if not.

HasChildren

bool HasChildren() const 

Does this DataSnapshot have any children at all?

Details
Returns
True if the snapshot has any children, false otherwise.

IsValid

bool IsValid() const 

Returns true if this snapshot is valid, false if it is not valid.

An invalid snapshot could be returned by a transaction where an error has occured.

Details
Returns
true if this snapshot is valid, false if this snapshot is invalid.

operator=

DataSnapshot & operator=(
  const DataSnapshot & snapshot
)

Copy assignment operator.

DataSnapshots are immutable, so they can be efficiently copied.

Details
Parameters
snapshot
DataSnapshot to copy.
Returns
Reference to the destination DataSnapshot.

operator=

DataSnapshot & operator=(
  DataSnapshot && snapshot
)

Move assignment operator.

DataSnapshots are immutable, so they can be efficiently moved.

Details
Parameters
snapshot
DataSnapshot to move into this one.
Returns
Reference to this destination DataSnapshot.

~DataSnapshot

 ~DataSnapshot()

Destructor.

Send feedback about...

Need help? Visit our support page.