8#ifndef binarystreams_h_
9#define binarystreams_h_
22template <
class _Ch,
class _Tr = std::
char_traits<_Ch>>
30 : _outbuf( new _Ch[sz + sizeof(
std::streamsize ) / sizeof( _Ch )] ), _inbuf( 0 ) {
31 memcpy( _outbuf, &sz,
sizeof( std::streamsize ) );
32 setp( _outbuf +
sizeof( std::streamsize ),
33 _outbuf + sz *
sizeof( _Ch ) +
sizeof(
unsigned int ) );
36 std::streamsize sz = *( (
const std::streamsize*)p );
38 memcpy( _inbuf, p +
sizeof( std::streamsize ), sz );
39 setg( _inbuf, _inbuf, _inbuf + sz *
sizeof( _Ch ) );
57 ? (
sizeof( _Ch ) * ( *(std::streamsize*)_outbuf ) +
sizeof( std::streamsize ) )
63 static size_t computesize(
size_t s ) {
return s +
sizeof( std::streamsize ); }
77template <
class _Ch,
class _Tr = std::
char_traits<_Ch>>
79class basic_binostream :
public std::basic_ostream<_Ch, _Tr> {
98 sz = _buf->outbufsize();
99 return _buf->givebuf();
118template <
class _Ch,
class _Tr = std::
char_traits<_Ch>>
120class basic_binistream :
public std::basic_istream<_Ch, _Tr> {
140template <
class _Ty,
class _Ch,
class _Tr>
141inline basic_binostream<_Ch, _Tr>&
operator<<( basic_binostream<_Ch, _Tr>& o,
const _Ty
t ) {
142 int sz =
sizeof( _Ty );
143 o.write( (
const _Ch*)( &
t ), sz );
147template <
class _Ty,
class _Ch,
class _Tr>
149 int sz =
sizeof( _Ty );
150 i.read( (_Ch*)( &
t ), sz );
basic_binistream< char > binistream
basic_binstreambuf< char > binstreambuf
basic_binostream< char > binostream
std::istream & operator>>(std::istream &is, CosmicEventParser &ev)
ostream & operator<<(ostream &s, const EvtComplex &c)
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)