binary_serialization.h
Go to the documentation of this file.
1 
11 #ifndef __OPC_UA_BINARY_SERIALIZATION_TOOLS_H__
12 #define __OPC_UA_BINARY_SERIALIZATION_TOOLS_H__
13 
14 #include <algorithm>
15 #include <stdint.h>
16 
17 
18 namespace OpcUa
19 {
20 template<class Stream, class Container>
21 inline void SerializeContainer(Stream & out, const Container & c, uint32_t emptySizeValue = ~uint32_t())
22 {
23  if (c.empty())
24  {
25  out.Serialize(emptySizeValue);
26  }
27 
28  else
29  {
30  out.Serialize(static_cast<uint32_t>(c.size()));
31  std::for_each(c.begin(), c.end(), [&](typename Container::value_type const & v) { out.Serialize(v); });
32  }
33 }
34 
35 template<class Stream, class Container>
36 inline void DeserializeContainer(Stream & in, Container & c)
37 {
38  uint32_t size = 0;
39  in.Deserialize(size);
40 
41  c.clear();
42 
43  if (!size || size == ~uint32_t())
44  {
45  return;
46  }
47 
48  for (uint32_t i = 0; i < size; ++i)
49  {
50  typename Container::value_type val;
51  in.Deserialize(val);
52  c.push_back(val);
53  }
54 }
55 }
56 
57 #endif // __OPC_UA_BINARY_SERIALIZATION_TOOLS_H__
58 
void SerializeContainer(Stream &out, const Container &c, uint32_t emptySizeValue=~uint32_t())
void DeserializeContainer(Stream &in, Container &c)
OPC UA Address space part. GNU LGPL.


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:06:03