7#include <boost/numeric/conversion/cast.hpp>
20 template<
typename CookedType,
typename RAW_ITERATOR,
typename COOKED_ITERATOR>
22 const RAW_ITERATOR& raw_begin,
const RAW_ITERATOR& raw_end,
const COOKED_ITERATOR& cooked_begin)
const {
24 assert((std::is_same<
typename std::iterator_traits<RAW_ITERATOR>::value_type, int32_t>::value));
26 static_assert(std::is_same<typename std::iterator_traits<RAW_ITERATOR>::value_type, int8_t>::value ||
27 std::is_same<typename std::iterator_traits<RAW_ITERATOR>::value_type, int16_t>::value ||
28 std::is_same<typename std::iterator_traits<RAW_ITERATOR>::value_type, int32_t>::value,
29 "RAW_ITERATOR template argument must be an iterator with value type equal to int8_t, int16_t or int32_t.");
31 static_assert(std::is_same<typename std::iterator_traits<COOKED_ITERATOR>::value_type, CookedType>::value,
32 "COOKED_ITERATOR template argument must be an iterator with value type equal to the CookedType template "
38 template<
typename CookedType,
typename RAW_ITERATOR,
typename COOKED_ITERATOR>
40 static void impl(
const RAW_ITERATOR& raw_begin,
const RAW_ITERATOR& raw_end, COOKED_ITERATOR cooked_begin);
44 template<
typename CookedType>
47 vectorToCooked<CookedType>(&
raw, (&
raw) + 1, &cooked);
51 template<
typename CookedType>
52 uint32_t
toRaw(CookedType cookedValue)
const;
61 template<
typename CookedType,
typename RAW_ITERATOR,
typename COOKED_ITERATOR>
63 const RAW_ITERATOR& raw_begin,
const RAW_ITERATOR& raw_end, COOKED_ITERATOR cooked_begin) {
64 for(
auto it = raw_begin; it != raw_end; ++it) {
66 float genericRepresentation;
67 memcpy(&genericRepresentation, &(*it),
sizeof(
float));
70 *cooked_begin = numeric::convert<CookedType>(genericRepresentation);
75 template<
typename CookedType>
79 float genericRepresentation = numeric::convert<float>(cookedValue);
83 memcpy(&rawValue, &genericRepresentation,
sizeof(
float));
88 template<
typename RAW_ITERATOR,
typename COOKED_ITERATOR>
90 static void impl(
const RAW_ITERATOR& raw_begin,
const RAW_ITERATOR& raw_end, COOKED_ITERATOR cooked_begin) {
91 for(
auto it = raw_begin; it != raw_end; ++it) {
93 float genericRepresentation;
94 memcpy(&genericRepresentation, &(*it),
sizeof(
float));
@ raw
Raw access: disable any possible conversion from the original hardware data type into the given UserT...
std::string to_string(const std::string &v)
static void impl(const RAW_ITERATOR &raw_begin, const RAW_ITERATOR &raw_end, COOKED_ITERATOR cooked_begin)
static void impl(const RAW_ITERATOR &raw_begin, const RAW_ITERATOR &raw_end, COOKED_ITERATOR cooked_begin)
Needs to have the same interface as FixedPointConverter, except for the constructor.
IEEE754_SingleConverter(const std::string &="")
bool operator!=(const IEEE754_SingleConverter &) const
CookedType scalarToCooked(int32_t const &raw) const
Inefficient convenience function for converting a single value to cooked.
uint32_t toRaw(CookedType cookedValue) const
bool operator==(const IEEE754_SingleConverter &) const
void vectorToCooked(const RAW_ITERATOR &raw_begin, const RAW_ITERATOR &raw_end, const COOKED_ITERATOR &cooked_begin) const