#include <ByteOrderConversion.h>
Public Member Functions | |
template<typename T > | |
void | appendWithoutConversion (const T &data) |
add data without any byte conversion | |
template<typename T > | |
void | appendWithoutConversion (const std::vector< T > &data) |
add data in vectors without any byte conversion | |
ArrayBuilder (size_t array_size=1) | |
template<typename T > | |
ArrayBuilder & | operator<< (const T &data) |
Write any type into ArrayBuilder, convert to LittleEndian in process. | |
template<typename T > | |
ArrayBuilder & | operator<< (const std::vector< T > &data) |
Write vectors into ArrayBuilder, each element is written seperately and convert to LittleEndian in process. | |
template<typename T > | |
ArrayBuilder & | operator>> (T &data) |
Read a generic data type from the array builder, Endianess is converted to system architecture. | |
template<typename T > | |
ArrayBuilder & | operator>> (std::vector< T > &data) |
Read a vectors from the array builder, Endianess is converted to system architecture. | |
template<typename T > | |
T | readBack () |
void | reset (size_t array_size=1) |
Resets the Arraybuilder to initial state, all values will be deleted. | |
Public Attributes | |
std::vector< uint8_t > | array |
array of template type TArray | |
size_t | read_pos |
current read position in array | |
size_t | write_pos |
current write position in array |
template class holding an array and the current index for write commands. Can be used to easily create an array for low level byte streams
The arraybuilder is intended to be used as a conversion queue for low level byte streams. Arbitrary data can be written into the arraybuider by calling the << operator. During this write operation the data will be convertet into a little endian representation regardles of the source architecture. This can be used when a Little Endian byte stream (i.e. for a serial device) is composed of several data types. Example: To send 1 int and to floats via bytestream in little endian ending: ArrayBuilder ab; ab << int << float1 << float2; send(ab.array); To read out values from the arraybuilder you can simply use the << operator. This will automatically convert the little endian representation to the byte order of the host system.
NOTE: As the arraybuilder converts the data during write and read operations the raw data that is read out from the stream has to be appended without any conversion (use appendWithoutConversion). (TODO: Is there a better Solution to this?)
Definition at line 130 of file ByteOrderConversion.h.
icl_comm::ArrayBuilder::ArrayBuilder | ( | size_t | array_size = 1 | ) | [inline] |
Definition at line 133 of file ByteOrderConversion.h.
void icl_comm::ArrayBuilder::appendWithoutConversion | ( | const T & | data | ) | [inline] |
add data without any byte conversion
Definition at line 156 of file ByteOrderConversion.h.
void icl_comm::ArrayBuilder::appendWithoutConversion | ( | const std::vector< T > & | data | ) | [inline] |
add data in vectors without any byte conversion
Definition at line 171 of file ByteOrderConversion.h.
ArrayBuilder & icl_comm::ArrayBuilder::operator<< | ( | const T & | data | ) |
Write any type into ArrayBuilder, convert to LittleEndian in process.
Definition at line 206 of file ByteOrderConversion.h.
ArrayBuilder & icl_comm::ArrayBuilder::operator<< | ( | const std::vector< T > & | data | ) |
Write vectors into ArrayBuilder, each element is written seperately and convert to LittleEndian in process.
Definition at line 220 of file ByteOrderConversion.h.
ArrayBuilder & icl_comm::ArrayBuilder::operator>> | ( | T & | data | ) |
Read a generic data type from the array builder, Endianess is converted to system architecture.
Read arbitrary types from the arraybuilder, endianess is converted during readout.
Definition at line 237 of file ByteOrderConversion.h.
ArrayBuilder & icl_comm::ArrayBuilder::operator>> | ( | std::vector< T > & | data | ) |
Read a vectors from the array builder, Endianess is converted to system architecture.
Read a vectors from the array builder, Endianess is converted to system architecture, vector has to be initualized.
Definition at line 245 of file ByteOrderConversion.h.
T icl_comm::ArrayBuilder::readBack | ( | ) |
Read out the last data without removing it from the stream NOTE: This is only implemented for base types
Definition at line 259 of file ByteOrderConversion.h.
void icl_comm::ArrayBuilder::reset | ( | size_t | array_size = 1 | ) |
Resets the Arraybuilder to initial state, all values will be deleted.
array_size | size the array is supposed to have after reset |
Definition at line 72 of file ByteOrderConversion.cpp.
array of template type TArray
Definition at line 146 of file ByteOrderConversion.h.
current read position in array
Definition at line 143 of file ByteOrderConversion.h.
current write position in array
Definition at line 140 of file ByteOrderConversion.h.