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/message_lite.h>
4#include <srs/data/message.pb.h>
5
6namespace srs::process
7{
9 {
10 public:
11 ProtoDeserializer() = default;
12
13 static void convert(std::string_view data, proto::Data& proto)
14 {
15 proto.Clear();
16 namespace protobuf = google::protobuf;
17 namespace io = protobuf::io;
18 auto input_stream = io::ArrayInputStream{ data.data(), static_cast<int>(data.size()) };
19 proto.ParseFromZeroCopyStream(&input_stream);
20 }
21
22 auto convert(std::string_view str_data) -> const proto::Data&
23 {
24 convert(str_data, data_);
25 return data_;
26 }
27
28 private:
29 proto::Data data_;
30 };
31} // namespace srs
auto convert(std::string_view str_data) -> const proto::Data &
static void convert(std::string_view data, proto::Data &proto)