userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
timestamp_conv.cpp
1
#include <
userver/proto-structs/io/userver/proto_structs/timestamp_conv.hpp
>
2
3
#include <google/protobuf/timestamp.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
Timestamp ReadProtoStruct(
ReadContext
& ctx,
To<Timestamp>
, const ::google::protobuf::Timestamp& msg) {
14
try
{
15
return
Timestamp(utils::impl::InternalTag{}, msg.seconds(), msg.nanos());
16
}
catch
(
const
ValueError& e) {
17
ctx.AddError(e.what());
18
return
Timestamp{};
19
}
20
}
21
22
void
WriteProtoStruct(
WriteContext
&,
const
Timestamp& obj, ::google::protobuf::Timestamp& msg) {
23
msg.set_seconds(obj.Seconds().count());
24
msg.set_nanos(
static_cast<
std::int32_t
>
(obj.Nanos().count()));
25
}
26
27
}
// namespace proto_structs::io
28
29
USERVER_NAMESPACE_END
proto-structs
src
proto-structs
io
userver
proto_structs
timestamp_conv.cpp
Generated on
for userver by
Doxygen
1.17.0