| IOLink 1.11.0

Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
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.
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.

## 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

  srcType | The type of data stored in the source buffer
  src | The source buffer
  dstType | The type of data stored in the destination buffer
  dst | The destination buffer
  count | The 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

  srcType | The type of data stored in the source buffer
  src | The source buffer
  dst | The destination buffer
  count | The number of element to convert

Exceptions

  Error | if given datatype is not handled

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

- iolink/public/include/iolink/tool/DataConverter.h