SRS-control 0.1.4
Loading...
Searching...
No Matches
ProtoDeserializer.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
4#include <google/protobuf/message_lite.h>
5#include <srs/data/message.pb.h>
6#include <string_view>
7
8namespace srs::process
9{
11 {
12 public:
13 ProtoDeserializer() = default;
14
15 static void convert(std::string_view data, proto::Data& proto)
16 {
17 proto.Clear();
18 namespace protobuf = google::protobuf;
19 namespace io = protobuf::io;
20 auto input_stream = io::ArrayInputStream{ data.data(), static_cast<int>(data.size()) };
21 proto.ParseFromZeroCopyStream(&input_stream);
22 }
23
24 auto convert(std::string_view str_data) -> const proto::Data&
25 {
26 convert(str_data, data_);
27 return data_;
28 }
29
30 private:
31 proto::Data data_;
32 };
33} // namespace srs::process
auto convert(std::string_view str_data) -> const proto::Data &
static void convert(std::string_view data, proto::Data &proto)