7#include "../utility/utility.hpp"
10#include "../macros.hpp"
14hi_export_module(hikogui.codec.pickle);
16namespace hi {
inline namespace v1 {
23hi_export
template<
typename T>
32 hi_static_not_implemented();
36 requires(std::has_unique_object_representations_v<T>
and not std::is_pointer_v<T>)
38 auto *
rhs_ =
reinterpret_cast<std::byte
const *
>(&rhs);
50 hi_static_not_implemented();
54 requires(std::has_unique_object_representations_v<T>
and not std::is_pointer_v<T>)
57 auto tmp = base64::decode(*b);
58 if (
tmp.size() !=
sizeof(T)) {
60 std::format(
"Length of base64 encoded object is {}, expected length {}",
tmp.size(),
sizeof(T)));
68 throw parse_error(std::format(
"Expecting std::string to be encoded as a base64-string, got {}", rhs));
73hi_export
template<numeric_
integral T>
84 throw parse_error(std::format(
"Encoded value is to out of range, got {}", rhs));
86 return static_cast<T
>(*i);
88 throw parse_error(std::format(
"Expecting numeric integrals to be encoded as a long long, got {}", rhs));
93hi_export
template<std::
floating_po
int T>
103 return static_cast<T
>(*f);
106 return static_cast<T
>(*i);
109 throw parse_error(std::format(
"Expecting floating point to be encoded as a double or long long, got {}", rhs));
127 throw parse_error(std::format(
"Expecting bool to be encoded as a bool, got {}", rhs));
145 throw parse_error(std::format(
"Expecting std::string to be encoded as a string, got {}", rhs));
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
A dynamic data type.
Definition datum.hpp:212
Encode and decode a type to and from a UTF-8 string.
Definition pickle.hpp:24
T decode(datum rhs) const
Decode a UTF-8 string into a value of a given type.
Definition pickle.hpp:48
datum encode(T const &rhs) const noexcept
Encode the value of a type into a UTF-8 string.
Definition pickle.hpp:30
Exception thrown during parsing on an error.
Definition exception_intf.hpp:47