userver
C++ Async Framework
Loading...
Searching...
No Matches
decimal64.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/storages/postgres/io/decimal64.hpp
4
/// @brief decimal64::Decimal I/O support
5
/// @ingroup userver_postgres_parse_and_format
6
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
>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
storages
::
postgres
::
io
{
16
17
template
<
int
Prec
,
typename
RoundPolicy
>
18
struct
BufferFormatter
<
decimal64
::
Decimal
<
Prec
,
RoundPolicy
>>
19
:
detail
::
BufferFormatterBase
<
decimal64
::
Decimal
<
Prec
,
RoundPolicy
>> {
20
using
BaseType
=
21
detail
::
BufferFormatterBase
<
decimal64
::
Decimal
<
Prec
,
RoundPolicy
>>;
22
using
BaseType
::
BaseType
;
23
using
ValueType
=
typename
BaseType
::
ValueType
;
24
25
template
<
typename
Buffer
>
26
void
operator
()(
const
UserTypes
&,
Buffer
&
buffer
)
const
{
27
auto
bin_str
=
28
detail
::
Int64ToNumericBuffer
({
this
->
value
.
AsUnbiased
(),
Prec
});
29
buffer
.
reserve
(
buffer
.
size
() +
bin_str
.
size
());
30
std
::
copy
(
bin_str
.
begin
(),
bin_str
.
end
(),
std
::
back_inserter
(
buffer
));
31
}
32
};
33
34
template
<
int
Prec
,
typename
RoundPolicy
>
35
struct
BufferParser
<
decimal64
::
Decimal
<
Prec
,
RoundPolicy
>>
36
:
detail
::
BufferParserBase
<
decimal64
::
Decimal
<
Prec
,
RoundPolicy
>> {
37
using
BaseType
=
38
detail
::
BufferParserBase
<
decimal64
::
Decimal
<
Prec
,
RoundPolicy
>>;
39
using
BaseType
::
BaseType
;
40
using
ValueType
=
typename
BaseType
::
ValueType
;
41
42
void
operator
()(
const
FieldBuffer
&
buffer
) {
43
auto
rep
=
detail
::
NumericBufferToInt64
(
buffer
);
44
this
->
value
=
ValueType
::
FromBiased
(
rep
.
value
,
rep
.
fractional_digit_count
);
45
}
46
};
47
48
template
<
int
Prec,
typename
RoundPolicy>
49
struct
CppToSystemPg<
decimal64
::
Decimal
<Prec, RoundPolicy>>
50
: PredefinedOid<PredefinedOids::kNumeric> {};
51
}
// namespace storages::postgres::io
52
53
USERVER_NAMESPACE_END
userver
storages
postgres
io
decimal64.hpp
Generated on Wed May 15 2024 22:32:03 for userver by
Doxygen
1.10.0