13 template <
typename Stream> msgpack::packer<Stream>&
operator()(msgpack::packer<Stream>& o,
uint128_t const& v)
const
17 std::string str =
format(v);
18 o.pack_str(
static_cast<uint32_t
>(str.size()));
19 o.pack_str_body(str.c_str(),
static_cast<uint32_t
>(str.size()));
27 if (o.type == msgpack::type::POSITIVE_INTEGER) {
29 }
else if (o.type == msgpack::type::STR) {
34 if (o.via.str.size > 39) {
35 throw_or_abort(
"uint128_t deserialization failed: string too long");
38 for (
size_t i = 0; i < o.via.str.size; ++i) {
39 char c = o.via.str.ptr[i];
40 if (c <
'0' || c >
'9') {
41 throw_or_abort(
"uint128_t deserialization failed: Non-digit character in input");
44 result = result * 10 + (
static_cast<uint128_t>(c -
'0'));
std::string format(Args... args)
constexpr std::array< uint8_t, S > convert(const std::string_view &in)
unsigned __int128 uint128_t
msgpack::object const & operator()(msgpack::object const &o, uint128_t &v) const
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, uint128_t const &v) const
void throw_or_abort(std::string const &err)