binistream
provides an input-only binary stream.
binio.h
binistream()
~binistream()
Int readInt(unsigned int size)
size
(in bytes) from the stream and
returns it. The return value is undefined if an error occured. The
maximum number of bytes that can be read at once equals the size (in
bytes) of the largest integer type, supported by the system.
Float readFloat(FType ft)
ft
. Refer to
the list of public types of the binio
class for information
about what floating-point formats are supported. The return value is
undefined if an error occured. The value from the stream is always
rendered to the biggest floating-point type, supported by the system.
If your architecture is incompatible with the floating-point number
that has just been read, readFloat()
tries to convert it. This
is sometimes not possible or not as accurate as the original value and
an error will be issued in these cases. Refer to the list of public
types of the binio
class for information about what errors
could be issued.
unsigned long readString(char *str, unsigned long maxlen, char delim)
std::string readString(char delim = '\0')
string
objects are
supported.
The ASCIIZ version takes a pointer to the pre-allocated
string buffer as the str
argument. maxlen
specifies the
maximum number of characters to be read from the stream (not
including the trailing \0
that is always appended to the string
buffer). The optional argument delim
is a delimiter
character. If this character is encountered in the stream, no more
characters will be read. The delimiter character itself is
discarded. It will not appear in the final string. If the delim
argument is omitted, always up to maxlen
characters are read.
The string
object version just takes one optional argument, the
delimiter character, explained above. Characters are always read until
the delimiter character or the end of the stream is encountered. If
delim
is omitted, it defaults to \0
. It returns a
string
object, containing the final string.
Int peekInt(unsigned int size)
readInt()
, but doesn't modify the stream position, so any
later access to the stream will appear as if peekInt()
has
never been called.
Float peekFloat(FType ft)
readFloat()
, but doesn't modify the stream position, so
any later access to the stream will appear as if peekFloat()
has never been called.
bool ateof()
true
if the current stream position is at the last byte
of the stream. false
is returned otherwise.
void ignore(unsigned long amount = 1)
amount
is omitted, it
defaults to 1
, ignoring exactly 1 byte from the stream.
virtual Byte getByte()