IOLink  IOL_v1.2.0_release
iolink::DataConverter Class Reference

Handle conversion of data buffers described by an IOLink DataType. More...

#include <iolink/tool/DataConverter.h>

Static Public Member Functions

static void convert (DataType srcType, const void *src, DataType dstType, void *dst, size_t count)
 Convert each element of the source buffer into another data type and writes it into the destination buffer. More...
 
static void endianReverse (DataType srcType, const void *src, void *dst, size_t count)
 This converter is used to revert endianness of a set of samples. More...
 

Detailed Description

Handle conversion of data buffers described by an IOLink DataType.

Member Function Documentation

◆ convert()

static void iolink::DataConverter::convert ( DataType  srcType,
const void *  src,
DataType  dstType,
void *  dst,
size_t  count 
)
static

Convert each element of the source buffer into another data type and writes it into the destination buffer.

This method uses the simpliest way of converting data: static casting. So it is only compatible with numeric types, and can lead to stranges values in specific cases.

This method throws an exception when the arguments are invalid (null buffers for example), when types aren't numeric ones, or when the source type is not convertible into the destination one.

See also
DataType::isConvertibleTo
Parameters
srcTypeThe type of data stored in the source buffer
srcThe source buffer
dstTypeThe type of data stored in the destination buffer
dstThe destination buffer
countThe number of element to convert
Exceptions
Error

◆ endianReverse()

static void iolink::DataConverter::endianReverse ( DataType  srcType,
const void *  src,
void *  dst,
size_t  count 
)
static

This converter is used to revert endianness of a set of samples.

This method throws an exception when the arguments are invalid (null buffers for example), when given source type is not handled.

Parameters
srcTypeThe type of data stored in the source buffer
srcThe source buffer
dstThe destination buffer
countThe number of element to convert
Exceptions
Errorif given datatype is not handled

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