19 #ifndef OST_IO_BINARY_DATA_SOURCE_HH
20 #define OST_IO_BINARY_DATA_SOURCE_HH
28 #include <boost/type_traits/is_floating_point.hpp>
29 #include <boost/type_traits/is_integral.hpp>
32 namespace ost {
namespace io {
39 template <
typename SERIALIZABLE>
44 template <
typename SERIALIZABLE>
54 std::istream& stream_;
59 template <
bool B,
typename T>
60 struct SerializeHelper;
63 struct SerializeHelper<false, T> {
66 value.Serialize(source);
71 struct SerializeHelper<true, T> {
74 source.
Stream().read(reinterpret_cast<char*>(&value),
sizeof(T));
82 detail::SerializeHelper<boost::is_integral<T>::value ||
83 boost::is_floating_point<T>::value,
88 char* value,
size_t size)
90 sink.
Stream().read(value, size);
95 static char tmp_buf[1024];
97 source.
Stream().read(reinterpret_cast<char*>(&str_len),
sizeof(
size_t));
98 source.
Stream().read(tmp_buf, str_len);
99 str.reserve(str_len+1);
100 str.assign(tmp_buf, str_len);