3.5 String streams

The string stream classes provide a means of turning arbitrary strings (or “blocks”) in memory into a binary stream, similary to what strstream does in the iostream library.

Unlike strstream from the iostream library, these streams do not support automatic enlarging of the memory area. If the user tries to write beyond the end of the stream, nothing is actually written and an Eof error is issued.

Header file: binstr.h

Public methods:

binsbase(void *str, unsigned long len)
binisstream(void *str, unsigned long len)
binosstream(void *str, unsigned long len)
binsstream(void *str, unsigned long len)

All constructors take two arguments. str is a pointer to a previously initialized data string in memory. len specifies the length in bytes of the string.

~binsbase()
~binisstream()
~binosstream()
~binsstream()

All deconstructors.

virtual void seek(long pos, Offset offs = Set)
virtual long pos()

Implementation of the abstract virtual methods, inherited from binio. Refer to the reference of that class for more information.

Protected data types and variables in binsbase:

Byte *data

This pointer is always pointing to the beginning of the initialized data string in memory, passed to the constructor.

Byte *spos

This pointer points to the current position in the string stream.

long length

Holds the length in bytes for the whole data string in memory, as passed to the constructor.