7#include <userver/decimal64/decimal64.hpp>
8#include <userver/storages/postgres/io/buffer_io.hpp>
9#include <userver/storages/postgres/io/buffer_io_base.hpp>
10#include <userver/storages/postgres/io/numeric_data.hpp>
11#include <userver/storages/postgres/io/type_mapping.hpp>
13USERVER_NAMESPACE_BEGIN
17template <
int Prec,
typename RoundPolicy>
20 using BaseType = detail::BufferFormatterBase<
decimal64::
Decimal<Prec, RoundPolicy>>;
21 using BaseType::BaseType;
22 using ValueType =
typename BaseType::ValueType;
24 template <
typename Buffer>
25 void operator()(
const UserTypes&, Buffer& buffer)
const {
26 auto bin_str = detail::Int64ToNumericBuffer({
this->value.AsUnbiased(), Prec});
27 buffer.reserve(buffer.size() + bin_str.size());
28 std::copy(bin_str.begin(), bin_str.end(), std::back_inserter(buffer));
32template <
int Prec,
typename RoundPolicy>
35 using BaseType = detail::BufferParserBase<
decimal64::
Decimal<Prec, RoundPolicy>>;
36 using BaseType::BaseType;
37 using ValueType =
typename BaseType::ValueType;
40 auto rep = detail::NumericBufferToInt64(buffer);
41 this->value = ValueType::FromBiased(rep.value, rep.fractional_digit_count);
45template <
int Prec,
typename RoundPolicy>