8#ifndef binarystreams_h_
9#define binarystreams_h_
22template <
class _Ch,
class _Tr = std::
char_traits<_Ch> >
29 basic_binstreambuf (std::streamsize sz) : _outbuf(new _Ch[sz + sizeof(
std::streamsize)/sizeof(_Ch)]), _inbuf(0) {
30 memcpy(_outbuf, &sz,
sizeof(std::streamsize));
31 setp (_outbuf +
sizeof(std::streamsize), _outbuf + sz*
sizeof(_Ch) +
sizeof(
unsigned int));
34 std::streamsize sz = *((
const std::streamsize*)p);
36 memcpy (_inbuf, p +
sizeof(std::streamsize), sz);
37 setg (_inbuf, _inbuf, _inbuf + sz *
sizeof(_Ch));
51 return (_outbuf) ? (
sizeof(_Ch) * (*(std::streamsize*)_outbuf) +
sizeof(std::streamsize)) : 0;
57 return s +
sizeof(std::streamsize);
72template <
class _Ch,
class _Tr = std::
char_traits<_Ch> >
90 sz = _buf->outbufsize();
91 return _buf->givebuf ();
110template <
class _Ch,
class _Tr = std::
char_traits<_Ch> >
129template <
class _Ty,
class _Ch,
class _Tr>
131 int sz =
sizeof(_Ty);
132 o.write ((
const _Ch*)(&
t), sz);
136template <
class _Ty,
class _Ch,
class _Tr>
138 int sz =
sizeof(_Ty);
139 i.read ((_Ch*)(&
t),sz);
std::ostream & operator<<(std::ostream &out, const SelectInfo &info)
basic_binistream< char > binistream
basic_binstreambuf< char > binstreambuf
basic_binistream< _Ch, _Tr > & operator>>(basic_binistream< _Ch, _Tr > &i, _Ty &t)
basic_binostream< char > binostream
basic_binistream(const _Ch *ptr)
virtual ~basic_binistream()
static size_t computesize(size_t s)
virtual ~basic_binostream()
basic_binostream(std::streamsize sz)
void * popbuf(size_t &sz)
basic_binstreambuf(const _Ch *p)
virtual ~basic_binstreambuf()
size_t outbufsize() const
static size_t computesize(size_t s)
basic_binstreambuf(std::streamsize sz)