NDArrayHelper.h
Go to the documentation of this file.
1#pragma once
2#include <string>
3#include <vector>
4
5#include <SimoxUtility/algorithm/string.h>
6
8{
10 {
11 public:
12 // Uses the simox utility to parse floatingpoint and fixed precision types
13 // it then writes the result into a byte vector
14 // an empty byte vector encodes a parsing error.
15 template <typename T>
16 std::vector<unsigned char> static toByteVector(const std::string& str)
17 {
18 try
19 {
20 auto val = simox::alg::to_<T>(str);
21 std::vector<unsigned char> res(sizeof(val), 0);
22 T* reinterpPtr = reinterpret_cast<T*>(res.data());
23 T* laundered = std::launder(reinterpPtr);
24 *laundered = val;
25 return res;
26 }
27 catch (const simox::error::SimoxError& err)
28 {
29 return {};
30 }
31 }
32 };
33} // namespace armarx::skills::gui
std::string str(const T &t)
static std::vector< unsigned char > toByteVector(const std::string &str)