Vanetza
 
Loading...
Searching...
No Matches
serialization_buffer.hpp
1#ifndef SERIALIZATION_BUFFER_HPP_8G2XAHRG
2#define SERIALIZATION_BUFFER_HPP_8G2XAHRG
3
4#include <vanetza/common/byte_buffer.hpp>
5#include <vanetza/common/byte_buffer_sink.hpp>
6#include <vanetza/common/byte_buffer_source.hpp>
7#include <vanetza/geonet/serialization.hpp>
8#include <boost/iostreams/stream_buffer.hpp>
9
10namespace vanetza
11{
12namespace geonet
13{
14
15/**
16 * This function is deprecated.
17 * It will be removed as soon as geonet::serialize signatures are
18 * compatible with common::serialize_into_buffer
19 */
20template<typename T>
21void serialize_into_buffer(const T& t, ByteBuffer& buf)
22{
23 byte_buffer_sink sink(buf);
24 boost::iostreams::stream_buffer<byte_buffer_sink> stream(sink);
25 OutputArchive ar(stream);
26 serialize(t, ar);
27}
28
29/**
30 * This function is deprecated.
31 * It will be removed as soon as geonet::deserialize signatures are
32 * compatible with common::deserialize_into_buffer
33 */
34template<typename T>
35void deserialize_from_buffer(T& t, const ByteBuffer& buf)
36{
37 byte_buffer_source source(buf);
38 boost::iostreams::stream_buffer<byte_buffer_source> stream(source);
39 InputArchive ar(stream);
40 deserialize(t, ar);
41}
42
43} // namespace geonet
44} // namespace vanetza
45
46#endif /* SERIALIZATION_BUFFER_HPP_8G2XAHRG */
47