Avro C++
|
Generic datum which can hold any Avro type. More...
#include <GenericDatum.hh>
Public Member Functions | |
Type | type () const |
The avro data type this datum holds. | |
template<typename T > | |
const T & | value () const |
Returns the value held by this datum. | |
template<typename T > | |
T & | value () |
Returns the reference to the value held by this datum, which can be used to change the contents. | |
bool | isUnion () const |
Returns true if and only if this datum is a union. | |
size_t | unionBranch () const |
Returns the index of the current branch, if this is a union. | |
void | selectBranch (size_t branch) |
Selects a new branch in the union if this is a union. | |
GenericDatum () | |
Makes a new AVRO_NULL datum. | |
GenericDatum (bool v) | |
Makes a new AVRO_BOOL datum whose value is of type bool. | |
GenericDatum (int32_t v) | |
Makes a new AVRO_INT datum whose value is of type int32_t. | |
GenericDatum (int64_t v) | |
Makes a new AVRO_LONG datum whose value is of type int64_t. | |
GenericDatum (float v) | |
Makes a new AVRO_FLOAT datum whose value is of type float. | |
GenericDatum (double v) | |
Makes a new AVRO_DOUBLE datum whose value is of type double. | |
GenericDatum (const std::string &v) | |
Makes a new AVRO_STRING datum whose value is of type std::string. | |
GenericDatum (const std::vector< uint8_t > &v) | |
Makes a new AVRO_BYTES datum whose value is of type std::vector<uint8_t>. | |
GenericDatum (const NodePtr &schema) | |
Constructs a datum corresponding to the given avro type. | |
template<typename T > | |
GenericDatum (const NodePtr &schema, const T &v) | |
Constructs a datum corresponding to the given avro type and set the value. | |
GenericDatum (const ValidSchema &schema) | |
Constructs a datum corresponding to the given avro type. |
Generic datum which can hold any Avro type.
The datum has a type and a value. The type is one of the Avro data types. The C++ type for value corresponds to the Avro type.
null
corresponds to no C++ type. It is illegal to to try to access values for null
. boolean
maps to C++ bool
int
maps to C++ int32_t
. long
maps to C++ int64_t
. float
maps to C++ float
. double
maps to C++ double
. string
maps to C++ std::string
. bytes
maps to C++ std::vector<uint_t>
. fixed
maps to C++ class GenericFixed
. enum
maps to C++ class GenericEnum
. array
maps to C++ class GenericArray
. map
maps to C++ class GenericMap
. union
. The object should have the C++ type corresponing to one of the constituent types of the union. avro::GenericDatum::GenericDatum | ( | const std::vector< uint8_t > & | v | ) | [inline] |
Makes a new AVRO_BYTES datum whose value is of type std::vector<uint8_t>.
avro::GenericDatum::GenericDatum | ( | const NodePtr & | schema | ) |
Constructs a datum corresponding to the given avro type.
The value will the appropraite default corresponding to the data type.
schema | The schema that defines the avro type. |
avro::GenericDatum::GenericDatum | ( | const NodePtr & | schema, |
const T & | v | ||
) | [inline] |
Constructs a datum corresponding to the given avro type and set the value.
schema | The schema that defines the avro type. |
v | The value for this type. |
avro::GenericDatum::GenericDatum | ( | const ValidSchema & | schema | ) |
Constructs a datum corresponding to the given avro type.
The value will the appropraite default corresponding to the data type.
schema | The schema that defines the avro type. |
void avro::GenericDatum::selectBranch | ( | size_t | branch | ) | [inline] |
Selects a new branch in the union if this is a union.
size_t avro::GenericDatum::unionBranch | ( | ) | const [inline] |
Returns the index of the current branch, if this is a union.
const T& avro::GenericDatum::value | ( | ) | const [inline] |
Returns the value held by this datum.
T The type for the value. This must correspond to the avro type returned by type().
T& avro::GenericDatum::value | ( | ) | [inline] |
Returns the reference to the value held by this datum, which can be used to change the contents.
Please note that only value can be changed, the data type of the value held cannot be changed.
T The type for the value. This must correspond to the avro type returned by type().