bstream |
A binary stream is an instance of os_bstream
. When an os_bstream is constructed, it is
associated with a particular I/O device via an intermediate adapter object
called an os_adapter . When an item is streamed to
an os_bstream , the item is converted into binary
format and sent to the I/O device via the adapter. This technique enables the
binary streaming mechanism to be fully decoupled from details of any particular
I/O device.
The output of os_bstream
is a stream of bytes sent via an os_adapter to a
specific device. Because many types of devices are supported, the reader of the
data stream can be on another machine. This commonly occurs when using sockets
or when sharing files among multiple machines. So that two different
architectures, such as Sparc and Intel, can communicate in these situations,
data portability must be assured.
The os_ndr
class is a helper class that is automatically used by os_bstream
to implement the NDR protocol. When you construct an os_bstream
, it automatically constructs os_ndr translators
and uses them to ensure your data stream is portable between machines.
The reader and writer of an os_bstream
exchange data format information by using a format label. Format labels are used
to synchronize the reader to the format of the writer. Format labels are managed
automatically by os_bstream , as follows.
os_bstream
and write to it the first time, a format label is automatically sent first.
After the first write, no additional format labels are sent unless you reset
the os_bstream using reset()
.os_bstream
and read from it for the first time, a format label is expected first. After
the first read, the os_bstream saves the format
of the writer and does not expect another format label unless you reset the os_bstream
using reset() . RULE The scope of the reader os_bstream
and writer os_bstream should be consistent. For
example, if you construct a single os_bstream and
write five objects to it, construct a single os_bstream
and read five objects from it. Do not construct five os_bstream
objects and read one object from each.
os_bstream , the os_ndr
object remembers the data type.os_bstream
, the os_ndr object determines whether extra
padding bytes are required to align the data correctly. If padding is
required, it is written prior to the data. Extra padding bytes are only
written when required. RULE Never connect two os_bstream
objects to the same device at the same time.
RULE If you seek on a device,
the os_bstream object connected to the device is no
longer valid. Construct a new os_bstream on the
device or reset the os_bstream objects using reset()
before reading or writing. Note that this action causes a new format
synchronization.
All read()
and write() functions return a bool
set to true on success or set to false
on failure.
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
false .true if the stream is at EOF.true if the stream is in a good state and not
at EOF.true if the stream is in a good state.true
if the stream experienced a precision loss conversion in a previous read. A
precision loss can occur when streaming integer values between machines with
dissimilar architectures.bool
into value . Throws: os_streaming_toolkit_error
char into value . Throws: os_streaming_toolkit_error
char* sequence into the heap and stores the
pointer to the memory region in buffer . Returns
the number of bytes read or returns -1 on
error. Throws: os_streaming_toolkit_error
double into value . Throws: os_streaming_toolkit_error
float into value . Throws: os_streaming_toolkit_error
int into value . Throws: os_streaming_toolkit_error
long into value . Throws: os_streaming_toolkit_error
long double into value
. Throws: os_streaming_toolkit_error
short into value . Throws: os_streaming_toolkit_error
signed
char into value . Throws: os_streaming_toolkit_error
os_int64_t into value
. Throws: os_streaming_toolkit_error
os_uint64_t into value
. Throws: os_streaming_toolkit_error
unsigned char into
value . Throws: os_streaming_toolkit_error
unsigned int into value
. Throws: os_streaming_toolkit_error
unsigned long into value
. Throws: os_streaming_toolkit_error
unsigned short into value
. Throws: os_streaming_toolkit_error
-1
on failure. Throws: os_streaming_toolkit_error
-1
on failure. Throws: os_streaming_toolkit_error
true
if this stream is currently adding type information tags to the primitive
data types it streams. Type-tagging is useful for debugging and
cross-platform data conversions; however, the stream size increases. Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
Throws: os_streaming_toolkit_error
The following STL containers can
be streamed in and out of an os_bstream , if you
declare the source macro for the container template instance in your code.
Adding binary streaming macros
to your classes automatically declares the non-member functions operator<<
and operator>> so they can be streamed in
and out of an os_bstream .
To determine if a particular
<ToolKit> class is enabled for use with os_bstream
, refer to the class entry in the class catalog for that <ToolKit>.
Copyright©1994-2026 Recursion
Software LLC
All Rights Reserved - For use by licensed users only.