Viam C++ SDK current
Loading...
Searching...
No Matches
repeated_ptr_convert.hpp
1#pragma once
2
3#include <vector>
4
5#include <google/protobuf/repeated_field.h>
6
7#include <viam/sdk/common/proto_convert.hpp>
8
9namespace viam {
10namespace sdk {
11namespace impl {
12
14 template <typename T, typename = EquivalentApiType<T>>
15 auto operator()(const std::vector<T>& v) const {
16 ::google::protobuf::RepeatedPtrField<EquivalentApiType<T>> result;
17 result.Reserve(v.size());
18
19 for (const auto& elem : v) {
20 *(result.Add()) = v2::to_proto(elem);
21 }
22
23 return result;
24 }
25};
26
28 template <typename T, typename = EquivalentSdkType<T>>
29 auto operator()(const ::google::protobuf::RepeatedPtrField<T>& v) const {
30 std::vector<EquivalentSdkType<T>> result;
31 result.reserve(v.size());
32
33 for (const auto& elem : v) {
34 result.push_back(v2::from_proto(elem));
35 }
36
37 return result;
38 }
39};
40
41namespace {
42
44
45constexpr auto& from_repeated_field =
47
48} // namespace
49
50} // namespace impl
51} // namespace sdk
52} // namespace viam
Definition repeated_ptr_convert.hpp:27
Definition repeated_ptr_convert.hpp:13
Definition proto_convert.hpp:17