userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
time_of_day_conv.cpp
1
#include <
userver/proto-structs/io/userver/proto_structs/time_of_day_conv.hpp
>
2
3
#include <google/type/timeofday.pb.h>
4
5
#include <
userver/proto-structs/exceptions.hpp
>
6
#include <
userver/proto-structs/io/context.hpp
>
7
#include <userver/utils/impl/internal_tag.hpp>
8
9
USERVER_NAMESPACE_BEGIN
10
11
namespace
proto_structs::io
{
12
13
TimeOfDay ReadProtoStruct(
ReadContext
& ctx,
To<TimeOfDay>
, const ::google::type::TimeOfDay& msg) {
14
try
{
15
return
TimeOfDay(utils::impl::InternalTag{}, msg.hours(), msg.minutes(), msg.seconds(), msg.nanos());
16
}
catch
(
const
ValueError& e) {
17
ctx.AddError(e.what());
18
return
TimeOfDay{};
19
}
20
}
21
22
void
WriteProtoStruct(
WriteContext
&,
const
TimeOfDay& obj, ::google::type::TimeOfDay& msg) {
23
msg.set_hours(
static_cast<
std::int32_t
>
(obj.Hours().count()));
24
msg.set_minutes(
static_cast<
std::int32_t
>
(obj.Minutes().count()));
25
msg.set_seconds(
static_cast<
std::int32_t
>
(obj.Seconds().count()));
26
msg.set_nanos(
static_cast<
std::int32_t
>
(obj.Nanos().count()));
27
}
28
29
}
// namespace proto_structs::io
30
31
USERVER_NAMESPACE_END
proto-structs
src
proto-structs
io
userver
proto_structs
time_of_day_conv.cpp
Generated on
for userver by
Doxygen
1.17.0