SourcePro® API Reference Guide

Product Documentation:
   SourcePro
Documentation Home
List of all members | Public Member Functions
RWbostream Class Reference

Stores variables in binary format. More...

#include <rw/bstream.h>

Inheritance diagram for RWbostream:
RWvostream RWvios RWeostream

Public Member Functions

 RWbostream (std::ostream &str)
 
 RWbostream (std::streambuf *sb)
 
virtual int bad ()
 
virtual void clear (int v=0)
 
virtual int eof ()
 
virtual int fail ()
 
virtual RWvostreamflush ()
 
virtual int good ()
 
virtual RWvostreamput (char c)
 
virtual RWvostreamput (signed char c)
 
virtual RWvostreamput (unsigned char c)
 
virtual RWvostreamput (wchar_t wc)
 
virtual RWvostreamput (bool)
 
virtual RWvostreamput (short i)
 
virtual RWvostreamput (unsigned short i)
 
virtual RWvostreamput (int i)
 
virtual RWvostreamput (unsigned int i)
 
virtual RWvostreamput (long i)
 
virtual RWvostreamput (unsigned long i)
 
virtual RWvostreamput (long long i)
 
virtual RWvostreamput (unsigned long long i)
 
virtual RWvostreamput (float f)
 
virtual RWvostreamput (double d)
 
virtual RWvostreamput (long double d)
 
virtual RWvostreamput (const char *v, size_t n)
 
virtual RWvostreamput (const signed char *v, size_t n)
 
virtual RWvostreamput (const unsigned char *v, size_t n)
 
virtual RWvostreamput (const wchar_t *v, size_t n)
 
virtual RWvostreamput (const bool *v, size_t n)
 
virtual RWvostreamput (const short *v, size_t n)
 
virtual RWvostreamput (const unsigned short *v, size_t n)
 
virtual RWvostreamput (const int *v, size_t n)
 
virtual RWvostreamput (const unsigned int *v, size_t n)
 
virtual RWvostreamput (const long *v, size_t n)
 
virtual RWvostreamput (const unsigned long *v, size_t n)
 
virtual RWvostreamput (const long long *v, size_t n)
 
virtual RWvostreamput (const unsigned long long *v, size_t n)
 
virtual RWvostreamput (const float *v, size_t n)
 
virtual RWvostreamput (const double *v, size_t n)
 
virtual RWvostreamput (const long double *v, size_t n)
 
virtual RWvostreamputChar (char c)
 
virtual RWvostreamputChar (signed char c)
 
virtual RWvostreamputChar (unsigned char c)
 
virtual RWvostreamputChar (wchar_t wc)
 
virtual RWvostreamputChars (const char *s, size_t n)
 
virtual RWvostreamputSizeT (size_t sz)
 
virtual RWvostreamputString (const char *s, size_t n)
 
virtual int rdstate ()
 
- Public Member Functions inherited from RWvostream
virtual ~RWvostream ()
 
void version (unsigned v)
 
unsigned version () const
 
- Public Member Functions inherited from RWvios
 operator void * ()
 

Additional Inherited Members

Detailed Description

Class RWbostream specializes the abstract base class RWvostream to store variables in binary format. The results can be restored by using its counterpart RWbistream.

You can think of it as a binary veneer over an associated std::streambuf. Because the RWbostream retains no information about the state of its associated std::streambuf, its use can be freely exchanged with other users of the std::streambuf (such as std::ostream or std::ofstream).

Note
Variables should not be separated with white space. Such white space would be interpreted literally and would have to be read back in as a character string.

RWbostream can be interrogated as to the stream state using member functions good(), bad(), eof(), etc.

Synopsis
#include <rw/bstream.h>
RWbostream bstr(std::cout); // Construct an RWbostream using cout's streambuf
Persistence
None
Example
#include <iostream>
#include <fstream>
#include <rw/bstream.h>
int main()
{
// Open an output file
std::ofstream fstr("data.dat");
// Construct a RWbostream from it
RWbostream bstr(fstr);
int i = 5;
float f = 22.1f;
double d = -0.05;
std::cout << "An integer, a float and a double sent out on a RWbostream!\n";
// Store a float & double
bstr << i << f << d;
return 0;
}

Program output:

An integer, a float and a double sent out on an RWbostream!

Constructor & Destructor Documentation

RWbostream::RWbostream ( std::ostream &  str)

Constructs an RWbostream from the std::streambuf associated with the std::ostream str. For DOS, the std::streambuf must have been opened in binary mode.

RWbostream::RWbostream ( std::streambuf *  sb)

Constructs an RWbostream from the std::streambuf sb. For DOS, the std::streambuf must have been opened in binary mode.

Member Function Documentation

virtual int RWbostream::bad ( )
inlinevirtual

Returns a nonzero integer if the bad bit has been set. Normally this indicates that a severe error has occurred from which recovery is probably impossible.

Implements RWvostream.

virtual void RWbostream::clear ( int  v = 0)
inlinevirtual

Sets the current error state to v. If v is zero, then this clears the error state.

Implements RWvostream.

virtual int RWbostream::eof ( )
inlinevirtual

Returns a nonzero integer if an EOF is encountered.

Implements RWvostream.

virtual int RWbostream::fail ( )
inlinevirtual

Returns a nonzero integer if the failed or bad bit has been set. Normally, this indicates that some storage or retrieval has failed, but that the stream is still in a usable state.

Implements RWvostream.

virtual RWvostream& RWbostream::flush ( )
virtual

Sends the contents of the stream buffer to output immediately.

Implements RWvostream.

Reimplemented in RWeostream.

virtual int RWbostream::good ( )
inlinevirtual

Returns a nonzero integer if no error bits have been set.

Implements RWvostream.

virtual RWvostream& RWbostream::put ( char  c)
virtual

Stores the char c to the output stream, preserving its value.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( signed char  c)
virtual

Stores the signed char c to the output stream, preserving its value.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( unsigned char  c)
virtual

Stores the unsigned char c to the output stream, preserving its value.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( wchar_t  wc)
virtual

Stores the wchar_t wc to the output stream, preserving its value.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( bool  b)
virtual

Stores the bool b to the output stream.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( short  i)
virtual

Stores the short i to the output stream.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( unsigned short  i)
virtual

Stores the unsigned short i to the output stream.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( int  i)
virtual

Stores the int i to the output stream.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( unsigned int  i)
virtual

Stores the unsigned int i to the output stream.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( long  i)
virtual

Stores the long i to the output stream.

Implements RWvostream.

Reimplemented in RWeostream, and RWeostream.

virtual RWvostream& RWbostream::put ( unsigned long  i)
virtual

Stores the unsigned long i to the output stream.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( long long  i)
virtual

Stores the long long i to the output stream.

Note
This operator function is available only if your compiler supports the long long type.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( unsigned long long  i)
virtual

Stores the unsigned long long i to the output stream.

Note
This operator function is available only if your compiler supports the unsigned long long type.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( float  f)
virtual

Stores the float f to the output stream.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( double  d)
virtual

Stores the double d to the output stream.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( long double  d)
virtual

Stores the long double d to the output stream.

Note
This operator function is available only if your compiler supports the long double type.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( const char *  v,
size_t  n 
)
virtual

Stores the vector of n char starting at v to the output stream. The characters should be treated as literal numbers (i.e., not as a character string).

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( const signed char *  v,
size_t  n 
)
virtual

Stores the vector of n signed char starting at v to the output stream. The characters should be treated as literal numbers (i.e., not as a character string).

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( const unsigned char *  v,
size_t  n 
)
virtual

Stores the vector of n unsigned char starting at v to the output stream. The characters should be treated as literal numbers (i.e., not as a character string).

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( const wchar_t *  v,
size_t  n 
)
virtual

Stores the vector of n wchar_t starting at v to the output stream. The characters should be treated as literal numbers (i.e., not as a character string).

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( const bool *  v,
size_t  n 
)
virtual

Stores the vector of n bool starting at v to the output stream.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( const short *  v,
size_t  n 
)
virtual

Stores the vector of n short starting at v to the output stream.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( const unsigned short *  v,
size_t  n 
)
virtual

Stores the vector of n unsigned short starting at v to the output stream.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( const int *  v,
size_t  n 
)
virtual

Stores the vector of n int starting at v to the output stream.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( const unsigned int *  v,
size_t  n 
)
virtual

Stores the vector of n unsigned int starting at v to the output stream.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( const long *  v,
size_t  n 
)
virtual

Stores the vector of n long starting at v to the output stream.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( const unsigned long *  v,
size_t  n 
)
virtual

Stores the vector of n unsigned long starting at v to the output stream.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( const long long *  v,
size_t  n 
)
virtual

Stores the vector of n long long starting at v to the output stream.

Note
This operator function is available only if your compiler supports the long long type.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( const unsigned long long *  v,
size_t  n 
)
virtual

Stores the vector of n unsigned long long starting at v to the output stream.

Note
This operator function is available only if your compiler supports the unsigned long long type.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( const float *  v,
size_t  n 
)
virtual

Stores the vector of n float starting at v to the output stream.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( const double *  v,
size_t  n 
)
virtual

Stores the vector of n double starting at v to the output stream.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::put ( const long double *  v,
size_t  n 
)
virtual

Stores the vector of n long double starting at v to the output stream.

Note
This operator function is available only if your compiler supports the long double type.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::putChar ( char  c)
virtual

Stores the char c to the output stream, preserving its meaning. c is treated as a character.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::putChar ( signed char  c)
virtual

Stores the signed char c to the output stream, preserving its meaning. c is treated as a character.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::putChar ( unsigned char  c)
virtual

Stores the unsigned char c to the output stream, preserving its meaning. c is treated as a character.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::putChar ( wchar_t  wc)
virtual

Stores the wchar_t wc to the output stream, preserving its value. wc is treated as a character.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::putChars ( const char *  s,
size_t  n 
)
virtual

Stores n char starting at s to the output stream.

Reimplemented from RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::putSizeT ( size_t  sz)
virtual

Stores the size_t sz to the output stream.

Implements RWvostream.

Reimplemented in RWeostream.

virtual RWvostream& RWbostream::putString ( const char *  s,
size_t  n 
)
virtual

Stores the character string, including embedded nulls, starting at s to the output stream.

Implements RWvostream.

Reimplemented in RWeostream.

virtual int RWbostream::rdstate ( )
inlinevirtual

Returns the current error state.

Implements RWvostream.

Copyright © 2021 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.