HLIBpro  2.1
Public Member Functions | Protected Attributes | List of all members
TByteStream Class Reference

implements a stream of bytes for storage purposes

#include <TByteStream.hh>

Public Member Functions

 TByteStream (const size_t s=0)
 construct bytestream capable of holding s bytes
 
 TByteStream (const size_t asize, void *adata)
 construct bytestream by given array (external storage)
 
 TByteStream (const TByteStream &str)
 copy constructor
 
 ~TByteStream ()
 destructor
 
size_t position () const
 return current position in byte stream
 
size_t size () const
 return capacity of bytestream
 
TByteStreamset_size (const size_t n)
 set new bytestream capacity without keeping old data
 
TByteStreamset_pos (const size_t p)
 set new position in bytestream
 
TByteStreamset_stream (void *data, const size_t size)
 set internal stream to data and size without copying
 
TByteStreamcopy_stream (void *data, const size_t size)
 set internal stream to data and size with copying
 
TByteStreamto_start ()
 set internal pointer to start of stream
 
TByteStreamto_end ()
 set internal pointer to end of stream
 
uchar * data ()
 directly access internal stream data
 
void put (const void *buf, const size_t n)
 put n bytes to current position in stream
 
template<typename T >
void put (const T &buf)
 directly put given data into stream
 
template<typename T >
void dput (const T *buf, const size_t nelem)
 directly put nelem elements of data into stream
 
void get (void *buf, const size_t n)
 get n bytes from current position in stream
 
template<typename T >
void get (T &buf)
 directly get data from stream
 
template<typename T >
void dget (T *buf, const size_t nelem)
 directly get nelem elements of data from stream
 
void save (const std::string &filename) const
 write stream into file filename
 
void load (const std::string &filename)
 load stream from file filename
 
uint checksum () const
 return checksum of content
 
void print (const bool show_content=false) const
 print information/content of stream
 

Protected Attributes

uchar * _data
 array holding the actual stream
 
size_t _pos
 current position in stream
 
bool _extern
 indicates, that stream memory is handled outside of class