19 #ifndef OST_IO_BINARY_DATA_SINK_HH
20 #define OST_IO_BINARY_DATA_SINK_HH
31 namespace ost {
namespace io {
38 template <
typename SERIALIZABLE>
43 template <
typename SERIALIZABLE>
53 std::ostream& stream_;
58 template <
bool B,
typename T>
59 struct SerializeWriteHelper;
62 struct SerializeWriteHelper<false, T> {
65 value.Serialize(sink);
70 struct SerializeWriteHelper<true, T> {
73 sink.
Stream().write(reinterpret_cast<char*>(&value),
sizeof(T));
81 detail::SerializeWriteHelper<boost::is_integral<T>::value ||
82 boost::is_floating_point<T>::value,
83 T>(sink,
const_cast<T&
>(value));
89 sink.
Stream().write(reinterpret_cast<char*>(value), size);
93 size_t str_len=str.length();
94 sink.
Stream().write(reinterpret_cast<char*>(&str_len),
sizeof(
size_t));
95 sink.
Stream().write(str.c_str(), str.length());