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,
To
<
formats
::
bson
::
Value
>) {
19
return
bson
::
ValueBuilder
(duration.count())
.
ExtractValue
(
)
;
20
}
21
22
}
// namespace formats::serialize
23
24
USERVER_NAMESPACE_END
userver
formats
bson
serialize_duration.hpp
Generated on Wed Dec 4 2024 18:50:04 for userver by
Doxygen
1.10.0