15 #include "../core/SmallBuffer.hpp"
16 #include "data_view.hpp"
18 #include "helics_cxx_export.h"
28 constexpr
size_t getBinaryLength(
double ) {
return 16; }
29 constexpr
size_t getBinaryLength(std::int64_t ) {
return 16; }
30 constexpr
size_t getBinaryLength(std::complex<double> ) {
return 24; }
31 inline size_t getBinaryLength(std::string_view val) {
return val.size() + 8; }
32 inline size_t getBinaryLength(
const std::vector<double>& val)
34 return val.size() *
sizeof(double) + 8;
36 inline size_t getBinaryLength(
const double* ,
size_t size)
38 return size *
sizeof(double) + 8;
41 inline size_t getBinaryLength(
const NamedPoint& np) {
return np.name.size() + 16; }
43 inline size_t getBinaryLength(
const std::vector<std::complex<double>>& cv)
45 return cv.size() *
sizeof(double) * 2 + 8;
47 inline size_t getBinaryLength(
const std::complex<double>* ,
size_t size)
49 return size *
sizeof(double) * 2 + 8;
52 HELICS_CXX_EXPORT
size_t convertToBinary(std::byte* data,
double val);
54 HELICS_CXX_EXPORT
size_t convertToBinary(std::byte* data, std::int64_t val);
56 HELICS_CXX_EXPORT
size_t convertToBinary(std::byte* data, std::complex<double> val);
58 HELICS_CXX_EXPORT
size_t convertToBinary(std::byte* data, std::string_view val);
60 HELICS_CXX_EXPORT
size_t convertToBinary(std::byte* data,
const NamedPoint& val);
62 HELICS_CXX_EXPORT
size_t convertToBinary(std::byte* data,
const std::vector<double>& val);
64 HELICS_CXX_EXPORT
size_t convertToBinary(std::byte* data,
const double* val,
size_t size);
66 HELICS_CXX_EXPORT
size_t convertToBinary(std::byte* data,
67 const std::vector<std::complex<double>>& val);
69 HELICS_CXX_EXPORT
size_t convertToBinary(std::byte* data,
70 const std::complex<double>* val,
74 HELICS_CXX_EXPORT
DataType detectType(
const std::byte* data);
76 HELICS_CXX_EXPORT
void convertFromBinary(
const std::byte* data,
double& val);
77 HELICS_CXX_EXPORT
void convertFromBinary(
const std::byte* data, std::int64_t& val);
78 HELICS_CXX_EXPORT
void convertFromBinary(
const std::byte* data, std::complex<double>& val);
79 HELICS_CXX_EXPORT
void convertFromBinary(
const std::byte* data,
char* val);
80 HELICS_CXX_EXPORT
void convertFromBinary(
const std::byte* data, std::string& val);
81 HELICS_CXX_EXPORT
void convertFromBinary(
const std::byte* data, std::string_view& val);
82 HELICS_CXX_EXPORT
void convertFromBinary(
const std::byte* data, NamedPoint& val);
84 HELICS_CXX_EXPORT
void convertFromBinary(
const std::byte* data, std::vector<double>& val);
85 HELICS_CXX_EXPORT
void convertFromBinary(
const std::byte* data,
double* val);
87 HELICS_CXX_EXPORT
void convertFromBinary(
const std::byte* data,
88 std::vector<std::complex<double>>& val);
93 HELICS_CXX_EXPORT
size_t getDataSize(
const std::byte* data);
112 store.resize(detail::getBinaryLength(val));
113 detail::convertToBinary(store.
data(), val);
119 store.resize(detail::getBinaryLength(vals, size));
120 detail::convertToBinary(store.
data(), vals, size);
135 detail::convertFromBinary(block.
bytes(), val);
142 detail::convertFromBinary(block.
bytes(), val);
146 static std::string
type() {
return typeNameString<X>(); }
152 using baseType = std::vector<std::string>;
170 std::vector<std::string> val;
176 static std::string
type() {
return "string_vector"; }