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
=
detail
::
BufferFormatterBase
<
decimal64
::
Decimal
<
Prec
,
RoundPolicy
>>;
21
using
BaseType
::
BaseType
;
22
using
ValueType
=
typename
BaseType
::
ValueType
;
23
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
));
29
}
30
};
31
32
template
<
int
Prec
,
typename
RoundPolicy
>
33
struct
BufferParser
<
decimal64
::
Decimal
<
Prec
,
RoundPolicy
>>
34
:
detail
::
BufferParserBase
<
decimal64
::
Decimal
<
Prec
,
RoundPolicy
>> {
35
using
BaseType
=
detail
::
BufferParserBase
<
decimal64
::
Decimal
<
Prec
,
RoundPolicy
>>;
36
using
BaseType
::
BaseType
;
37
using
ValueType
=
typename
BaseType
::
ValueType
;
38
39
void
operator
()(
const
FieldBuffer
&
buffer
) {
40
auto
rep
=
detail
::
NumericBufferToInt64
(
buffer
);
41
this
->
value
=
ValueType
::
FromBiased
(
rep
.
value
,
rep
.
fractional_digit_count
);
42
}
43
};
44
45
template
<
int
Prec,
typename
RoundPolicy>
46
struct
CppToSystemPg<
decimal64
::Decimal<Prec, RoundPolicy>> : PredefinedOid<PredefinedOids::kNumeric> {};
47
}
// namespace storages::postgres::io
48
49
USERVER_NAMESPACE_END
userver
storages
postgres
io
decimal64.hpp
Generated on Tue Nov 26 2024 15:32:01 for userver by
Doxygen
1.10.0