client-cpp  0.6.3
kaa::AvroByteArrayConverter< T > Class Template Reference

#include <AvroByteArrayConverter.hpp>

Public Member Functions

 AvroByteArrayConverter ()
 
fromByteArray (const std::uint8_t *data, const std::uint32_t &dataSize)
 
void fromByteArray (const std::uint8_t *data, const std::uint32_t &dataSize, T &datum)
 
SharedDataBuffer toByteArray (const T &datum)
 
void toByteArray (const T &datum, std::vector< std::uint8_t > &dest)
 
void toByteArray (const T &datum, std::ostream &stream)
 
void switchToJson (const avro::ValidSchema &schema)
 
void switchToBinary ()
 

Detailed Description

template<typename T>
class kaa::AvroByteArrayConverter< T >

Used to convert predefined avro objects to/from bytes. NOT Thread safe.

Parameters
<T>predefined avro object.

Definition at line 42 of file AvroByteArrayConverter.hpp.

Constructor & Destructor Documentation

template<typename T >
kaa::AvroByteArrayConverter< T >::AvroByteArrayConverter ( )

Instantiates a new avro byte array converter based on <T>.

Definition at line 114 of file AvroByteArrayConverter.hpp.

Member Function Documentation

template<typename T >
T kaa::AvroByteArrayConverter< T >::fromByteArray ( const std::uint8_t *  data,
const std::uint32_t &  dataSize 
)

Creates avro object from byte array Throws KaaException when invalid data was passed (zero-sized or null buffer)

Parameters
datathe data
dataSizesize of data
Returns
the result of conversion

Definition at line 120 of file AvroByteArrayConverter.hpp.

template<typename T>
void kaa::AvroByteArrayConverter< T >::fromByteArray ( const std::uint8_t *  data,
const std::uint32_t &  dataSize,
T &  datum 
)

Creates avro object from byte array Throws KaaException when invalid data was passed (zero-sized or null buffer)

Parameters
datathe data
dataSizesize of data
theresult of conversion

Definition at line 136 of file AvroByteArrayConverter.hpp.

template<typename T>
void kaa::AvroByteArrayConverter< T >::switchToBinary ( )
inline

Definition at line 103 of file AvroByteArrayConverter.hpp.

template<typename T>
void kaa::AvroByteArrayConverter< T >::switchToJson ( const avro::ValidSchema &  schema)
inline

Used for debug purpose

Definition at line 98 of file AvroByteArrayConverter.hpp.

template<typename T>
SharedDataBuffer kaa::AvroByteArrayConverter< T >::toByteArray ( const T &  datum)

Converts object to byte array

Parameters
datumthe encoding avro object
Returns
SharedDataBuffer result of a conversion

Definition at line 149 of file AvroByteArrayConverter.hpp.

template<typename T>
void kaa::AvroByteArrayConverter< T >::toByteArray ( const T &  datum,
std::vector< std::uint8_t > &  dest 
)

Converts object to byte array

Parameters
datumthe encoding avro object
destthe buffer that encoded data will be put in
Returns
serialized bytes

Definition at line 174 of file AvroByteArrayConverter.hpp.

template<typename T>
void kaa::AvroByteArrayConverter< T >::toByteArray ( const T &  datum,
std::ostream &  stream 
)

Converts object to stream

Parameters
datumthe encoding avro object
streamthe output stream that encoded data will be put in

Definition at line 194 of file AvroByteArrayConverter.hpp.


The documentation for this class was generated from the following file: