firebase::Variant

#include <variant.h>

Variant data type used by Firebase libraries.

Summary

Constructors and Destructors

Variant()
Construct a null Variant.
Variant(int64_t value)
Construct a Variant containing the given 64-bit integer.
Variant(int value)
Construct a Variant containing the given integer.
Variant(double value)
Construct a Variant containing the given double-precision floating point value.
Variant(float value)
Construct a Variant containing the given single-precision floating point value.
Variant(bool value)
Construct a Variant containing the given boolean value.
Variant(const char *value)
Construct a Variant with the given static const string (no copy).
Variant(char *value)
Construct a Variant containing the given string value (makes a copy).
Variant(const std::string & value)
Construct a Variant containing the given string value (makes a copy).
Variant(const std::vector< Variant > & value)
Construct a Variant containing the given std::vector of Variant.
Variant(const std::vector< T > & value)
Construct a Variant containing the given std::vector of something that can be constructed into a Variant.
Variant(const T array_of_values[], size_t array_size)
Construct a Variant from an array of supported types into a Vector.
Variant(const std::map< Variant, Variant > & value)
Construct a Variatn containing the given std::map of Variant to Variant.
Variant(const std::map< K, V > & value)
Construct a Variant containing the given std::map of something that can be constructed into a Variant, to something that can be constructed into a Variant.
Variant(const Variant & other)
Copy constructor.
Variant(Variant && other)
Move constructor.
~Variant()
Destructor. Frees the memory that this Variant owns.

Public types

Type{
  kTypeNull,
  kTypeInt64,
  kTypeDouble,
  kTypeBool,
  kTypeStaticString,
  kTypeMutableString,
  kTypeVector,
  kTypeMap,
  kTypeStaticBlob,
  kTypeMutableBlob
}
enum
Type of data that this variant object contains.

Public functions

AsBool() const
Get the current Variant converted into a boolean.
AsDouble() const
Get the current Variant converted into a floating-point number.
AsInt64() const
Get the current Variant converted into an integer.
AsString() const
Get the current Variant converted into a string.
AssignMap(std::map< Variant, Variant > **map)
void
Assigns an existing map which was allocated on the heap into the Variant without performing a copy.
AssignMutableString(std::string **str)
void
Assigns an existing string which was allocated on the heap into the Variant without performing a copy.
AssignVector(std::vector< Variant > **vect)
void
Assigns an existing vector which was allocated on the heap into the Variant without performing a copy.
Clear(Type new_type)
void
Clear the given Variant data, optionally into a new type.
blob_data() const
const uint8_t *
Get the pointer to the binary data contained in a blob.
blob_size() const
size_t
Get the size of a blob.
bool_value() const
const bool &
Const accessor for a Variant containing a bool.
double_value() const
double
Const accessor for a Variant containing a double.
int64_value() const
int64_t
Const accessor for a Variant containing an integer.
is_blob() const
bool
Get whether this Variant contains a blob.
is_bool() const
bool
Get whether this Variant contains a bool.
is_container_type() const
bool
Get whether this Variant contains a container type: Vector or Map.
is_double() const
bool
Get whether this Variant contains a double.
is_fundamental_type() const
bool
Get whether this Variant contains a fundamental type: Null, Int64, Double, Bool, or one of the two String types.
is_int64() const
bool
Get whether this Variant contains an integer.
is_map() const
bool
Get whether this Variant contains a map.
is_mutable_blob() const
bool
Get whether this Variant contains a mutable blob.
is_mutable_string() const
bool
Get whether this Variant contains a mutable string.
is_null() const
bool
Get whether this Variant is currently null.
is_numeric() const
bool
Get whether this Variant contains a numeric type, Int64 or Double.
is_static_blob() const
bool
Get whether this Variant contains a static blob.
is_static_string() const
bool
Get whether this Variant contains a static string.
is_string() const
bool
Get whether this Variant contains a string.
is_vector() const
bool
Get whether this Variant contains a vector.
map()
std::map< Variant, Variant > &
Mutable accessor for a Variant containing a map of Variant data.
map() const
const std::map< Variant, Variant > &
Const accessor for a Variant containing a map of strings to Variant data.
mutable_blob_data()
uint8_t *
Get a mutable pointer to the binary data contained in a blob.
mutable_blob_data() const
uint8_t *
Const accessor for a Variant contianing mutable blob data.
mutable_string()
std::string &
Mutable accessor for a Variant containing a string.
mutable_string() const
const std::string &
Const accessor for a Variant containing a mutable string only.
operator!=(const Variant & other) const
bool
Inequality operator: x != y is evaluated as !(x == y).
operator<(const Variant & other) const
bool
Inequality operator, only meant for internal use.
operator<=(const Variant & other) const
bool
Inequality operator: x <= y is evaluated as !(x > y)
operator=(const Variant & other)
Copy assignment operator.
operator=(Variant && other)
Move assignment operator.
operator==(const Variant & other) const
bool
Equality operator.
operator>(const Variant & other) const
bool
Inequality operator: x > y is evaluated as y < x.
operator>=(const Variant & other) const
bool
Inequality operator: x >= y is evaluated as !(x < y)
set_bool_value(bool value)
void
Sets the Variant to the given boolean value.
set_double_value(double value)
void
Sets the Variant to an double-precision floating point value.
set_int64_value(int64_t value)
void
Sets the Variant to an 64-bit integer value.
set_map(const std::map< Variant, Variant > & value)
void
Sets the Variant to a copy of the given map.
set_mutable_blob(const void *src_data, size_t size_bytes)
void
Sets the Variant to a copy of the given binary data.
set_mutable_string(const std::string & value)
void
Sets the Variant to a copy of the given string.
set_null()
void
Sets the Variant value to null.
set_static_blob(const void *static_data, size_t size_bytes)
void
Sets the Variant to point to static binary data.
set_string_value(const char *value)
void
Sets the Variant to point to a static string buffer.
set_string_value(char *value)
void
Sets the Variant to a mutable string.
set_string_value(const std::string & value)
void
Sets the Variant to a mutable string.
set_vector(const std::vector< Variant > & value)
void
Sets the Variant to a copy of the given vector.
string_value() const
const char *
Const accessor for a Variant containing a string.
type() const
Get the current type contained in this Variant.
vector()
std::vector< Variant > &
Mutable accessor for a Variant containing a vector of Variant data.
vector() const
const std::vector< Variant > &
Const accessor for a Variant containing a vector of Variant data.

Public static functions

EmptyMap()
Get a Variant containing an empty map.
EmptyMutableBlob(size_t size_bytes)
Return a Variant containing an empty mutable blob of the requested size, filled with 0-bytes.
EmptyMutableString()
Get a Variant containing an empty mutable string.
EmptyString()
Get an empty string variant.
EmptyVector()
Get a Variant containing an empty vector.
False()
Get a Variant of bool value false.
FromBool(bool value)
Return a Variant from a boolean.
FromDouble(double value)
Return a Variant from a double-precision floating point number.
FromInt64(int64_t value)
Return a Variant from a 64-bit integer.
FromMutableBlob(const void *src_data, size_t size_bytes)
Return a Variant containing a copy of binary data.
FromMutableString(const std::string & value)
Return a Variant from a string.
FromStaticBlob(const void *static_data, size_t size_bytes)
Return a Variant that points to static binary data.
FromStaticString(const char *value)
Return a Variant from a static string.
MutableStringFromStaticString(const char *value)
Return a Variant from a string, but make it mutable.
Null()
Get a Variant of type Null.
One()
Get a Variant of integer value 1.
OnePointZero()
Get a Variant of double value 1.0.
True()
Get a Variant of bool value true.
TypeName(Type type)
const char *
Get the human-readable type name of a Variant type.
Zero()
Get a Variant of integer value 0.
ZeroPointZero()
Get a