userver
C++ Async Framework
Loading...
Searching...
No Matches
serialize_duration.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/formats/bson/serialize_duration.hpp
4
/// @brief Serializers for std::chrono::duration types.
5
/// @ingroup userver_universal userver_formats_serialize
6
7
#
include
<
chrono
>
8
9
#
include
<
userver
/
formats
/
bson
/
value_builder
.
hpp
>
10
11
USERVER_NAMESPACE_BEGIN
12
13
namespace
formats::
serialize
{
14
15
// Declare Serialize() as static as multiple translation units might declare
16
// different implementations of std::chrono::duration<> serializations.
17
template
<
class
Rep,
class
Period>
18
static
bson
::
Value
Serialize(std::chrono::duration<Rep, Period> duration,
19
To
<formats::
bson
::
Value
>) {
20
return
bson
::
ValueBuilder
(duration.count())
.
ExtractValue
(
)
;
21
}
22
23
}
// namespace formats::serialize
24
25
USERVER_NAMESPACE_END
userver
formats
bson
serialize_duration.hpp
Generated on Wed May 15 2024 22:32:34 for userver by
Doxygen
1.10.0