binio is the general base class, containing important method,
type and variable declarations. As a user, you normally do not need it
directly, expect for scoping types and variables to it.
- The constructor.
- The destructor.
void setFlag(Flag f, bool set = true)
- Is used to set or erase flags to change the behaviour of the
stream. Available flags and their meaning are listed in the types
table for this class, below. The optional argument
set is used
to set or erase the specified flag. If it is not specified, it
true, setting (activating) the specified flag.
bool getFlag(Flag f)
- Returns whether the specified flag is set (active) or not. Refer to
setFlag, above, for more information.
- Returns the current error status of the stream. A status of no error
is always indicated with a value of
0, as to allow easy error
checks with a simple
true if the last access to the stream was unsuccessful
because the stream pointer was already past the end of the
false is returned otherwise. Synonymous to checking if
the return value of a call to
error() sets the
virtual void seek(long, Offset = Set)
- Abstract virtual method for seeking into streams. Implemented by the
stream layer. The first argument specifies the relative position to
seek to. Use a negative value to seek backwards. The optional second
argument specifies from where to start seeking.
the beginning of a stream,
Add specifies the current position
End specifies the end of the stream. If it is omitted, it
Set, seeking from the beginning of the stream.
virtual long pos()
- Abstract virtual method that returns the current position inside the
stream. Implemented by the stream layer.
Float pow(Float base, signed int exp)
- Is a stripped-down version of the
pow() function from the
math.h standard C math library include file. It is used during
conversion between floating-point formats and can calculate powers of
a floating-point base argument, using a signed integer exponent.
Public data types and variables:
- Enumeration of all defined stream flags that can be set using the
getFlag() methods. This type defines the
- If set, sets the stream's byte-ordering to big endian
notation. Otherwise, little endian notation is used.
- If set, all floating-point access to the stream will assume
IEEE-754 standardized floating-point numbers. Only this type
of data is expected from and written to the stream.
If your architecture does not support IEEE-754
floating-point numbers, the value will be converted. Various
conversion errors can occur and sometimes the conversion is not
possible at all. In this case, the
Unsupported error is issued
and a specific value is returned. The following table summarizes all
possible return codes for certain problematic values:
|Real value ||Return value
Not a Number (NaN)
Both positive and negative zero (
0) are mapped to the same zero
value, if your architecture does not support both positive and
negative zeroes. There is no way to distinguish between the two values
in this case.
- Enumeration of all possible error values. This type defines the
- No error at all. This is always mapped to an integer value of
- An unspecified, fatal error occured. This error is issued only if
something really strange happened (i.e. on internal logic errors in
the library, or if something else, undefined happens, etc.). It is
advised to immediately terminate any binary stream I/O activity and
fail with an error message to the application user, maybe even
terminate the application completely.
- You tried to access stream data in an unsupported way. This error is
issued whenever an (explicit or implicit) conversion between two types
of data storage is requested, that isn't supported by libbinio yet.
- The stream you tried to access is not open yet.
- Access to this stream is denied. This error is normally issued when
you try to open a file on a filesystem, but you have insufficient
rights to access it.
- The stream you tried to access was not found. This is mostly issued
on a file not found error, when accessing normal files on a
- The end of the stream has been passed. Issued when you tried to read
past the last byte of a stream.
- Specifies the position inside a stream, from where a seek is started
seek() method. This type defines the following values:
- Start seeking at the beginning of the stream.
- Start seeking from the current position in the stream.
- Start seeking from the end of the stream.
- Specifies what type of floating-point number is to be accessed next,
writeFloat() methods. Most
floating-point formats specify multiple data types to support a
broader range of precision. libbinio generalizes the idea by
categorizing them only into single and double precision numbers. This
type defines the following values:
- Access a single precision floating-point number.
- Access a double precision floating-point number.
- This integer holds a bit field of all error values for a
stream. Returned by
error(). A status of "no error" is always
indicated when the whole field is set to
0 (zero), i.e. the
0. Test for an error by binary or'ing this integer
with one of the error values from
Protected data types and variables:
- The largest integer type supported by the architecture.
- The largest floating-point type supported by the architecture.
- This type is always one byte (8 bits) wide.
- Type to hold a flag variable, containing the status of all flags of a
- This variable holds the current status of all flags for the stream.
static const Flags system_flags
- This variable holds the status of the flags, defining the standard
behaviour of the system. This is determined once at runtime, at
startup of the library.
- This variable holds the error status of a stream.