userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
time_of_day.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/formats/parse/time_of_day.hpp
4
/// @brief utils::datetime::TimeOfDay parser for any format
5
///
6
/// @ingroup userver_universal userver_formats_parse
7
8
#
include
<
userver
/
utils
/
time_of_day
.
hpp
>
9
10
#
include
<
userver
/
formats
/
common
/
meta
.
hpp
>
11
#
include
<
userver
/
formats
/
parse
/
to
.
hpp
>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
formats::
parse
{
16
17
template
<common::IsFormatValue Value,
typename
Duration>
18
utils
::
datetime
::TimeOfDay<Duration> Parse(
const
Value& value,
To
<
utils
::
datetime
::TimeOfDay<Duration>>) {
19
std::optional<std::string> str;
20
try
{
21
str = value.
template
As<std::string>();
22
return
utils
::
datetime
::TimeOfDay<Duration>{*str};
23
}
catch
(
const
std::exception& e) {
24
if
(str) {
25
throw
typename
Value::ParseException(
"'"
+ *str +
"' cannot be parsed to `utils::datetime::TimeOfDay`"
);
26
}
else
{
27
throw
typename
Value::ParseException(
"Only strings can be parsed as `utils::datetime::TimeOfDay`"
);
28
}
29
}
30
}
31
32
}
// namespace formats::parse
33
34
USERVER_NAMESPACE_END
userver
formats
parse
time_of_day.hpp
Generated on
for userver by
Doxygen
1.17.0