8 #ifndef UNPACK_STREAM_H_INCLUDED
9 #define UNPACK_STREAM_H_INCLUDED
12 #ifndef UNPACK_MESSAGE_H_INCLUDED
13 # error Do not include this file directly. Use <detail/unpack_message.h> instead
36 template<
typename T >
37 void unpack_stream_static(std::istream& is, T& msg)
41 is.read(reinterpret_cast<char*>(buffer), k_len);
43 msg.assign(buffer, k_len);
53 template<
typename T >
54 void unpack_stream_dynamic(std::istream& is, T& msg)
61 is.read(reinterpret_cast<char*>(body), k_static_len);
63 msg.assign(body, k_static_len);
66 size_t len = msg.size();
67 std::vector<byte_t> data(len);
68 ::memcpy(&data[0], body, k_static_len);
71 const size_t k_one_kb = 1024;
72 size_t remains = len - k_static_len;
73 size_t offset = k_static_len;
76 is.read(reinterpret_cast<char*>(&data[offset]), k_one_kb);
78 remains = remains > k_one_kb
84 msg.assign(&data[0], len);