7#if !defined(ASYNC_MQTT_UTIL_ENDIAN_CONVERT_HPP)
8#define ASYNC_MQTT_UTIL_ENDIAN_CONVERT_HPP
12#include <boost/endian/conversion.hpp>
14#include <async_mqtt/util/static_vector.hpp>
19T endian_load(
char const* buf) {
20 static_vector<
unsigned char,
sizeof(T)> usbuf(
sizeof(T));
21 std::copy(buf, buf +
sizeof(T), usbuf.data());
22 return boost::endian::endian_load<T, sizeof(T), boost::endian::order::big>(usbuf.data());
26void endian_store(T val,
char* buf) {
27 static_vector<
unsigned char,
sizeof(T)> usbuf(
sizeof(T));
28 boost::endian::endian_store<T, sizeof(T), boost::endian::order::big>(usbuf.data(), val);
29 std::copy(usbuf.begin(), usbuf.end(), buf);
33static_vector<char,
sizeof(T)> endian_static_vector(T val) {
34 static_vector<
unsigned char,
sizeof(T)> usbuf(
sizeof(T));
35 boost::endian::endian_store<T, sizeof(T), boost::endian::order::big>(usbuf.data(), val);
36 static_vector<char,
sizeof(T)> cbuf(
sizeof(T));
37 std::copy(usbuf.begin(), usbuf.end(), cbuf.begin());