Public Member Functions | Private Attributes
BoStream Class Reference

The binary output stream class. Overloads the << operator for all data types. More...

List of all members.

Public Member Functions

 BoStream ()
 Default constructor, need to open.
 BoStream (const char *s)
 Constructor takes name of input file.
 BoStream (const char *s, std::ios_base::openmode mode)
 Constructor takes name of input file, mode.
 ~BoStream ()
 Destructor, calls xdr_destroy to delete xdr stream.
BoStreamoperator<< (const String &ds)
 Binary Output stream operator<<.
BoStreamoperator<< (const char *s)
 Output operator, writes char* TO binary stream BoStream.
BoStreamoperator<< (const char &c)
 Output operator, writes char to binary stream BoStream.
BoStreamoperator<< (const int &i)
 Output operator, writes int to binary stream BoStream.
BoStreamoperator<< (const long &l)
 Output operator, writes long to binary stream BoStream.
BoStreamoperator<< (const short &s)
 Output operator, writes short to binary stream BoStream.
BoStreamoperator<< (const bool &b)
 Output operator, writes bool to binary stream BoStream.
BoStreamoperator<< (const double &d)
 Output operator, writes double to binary stream BoStream.
BoStreamoperator<< (const float &f)
 Output operator, writes float to binary stream BoStream.
BoStreamoperator<< (const unsigned char &c)
 Output operator, writes unsigned char to binary stream BoStream.
BoStreamoperator<< (const unsigned int &i)
 Output operator, writes unsigned int to binary stream BoStream.
BoStreamoperator<< (const unsigned long &l)
 Output operator, writes unsigned long to binary stream BoStream.
BoStreamoperator<< (const unsigned short &s)
 Output operator, writes unsigned short to binary stream BoStream.

Private Attributes

XDR xdrOutBuf
 XDR output stream buffer.
char outBuf [MAX_NETOBJ_SZ]
 Buffer to hold converted data before it is written.

Detailed Description

The binary output stream class. Overloads the << operator for all data types.

The Dakota::BoStream class is a binary output classes which overloads the << operator for all standard data types (int, char, float, etc). The class relies on the built in write methods within the ostream base classes. Dakota::BoStream inherits from the ofstream class. The motivation to develop this class was to replace the Rogue wave class which Dakota historically used for binary I/O. If available, the class utilize rpc/xdr to construct machine independent binary files. These Dakota restart files can be moved between hosts.


Constructor & Destructor Documentation

BoStream ( )

Default constructor, need to open.

Default constructor allocates the xdr stream but does not call the open() method. The open() method must be called before stream can be written to.

References BoStream::outBuf, and BoStream::xdrOutBuf.

BoStream ( const char *  s)

Constructor takes name of input file.

Constructor, takes char * filename as argument. Calls base class open method with filename and no other arguments. Also allocates xdr stream

References BoStream::outBuf, and BoStream::xdrOutBuf.

BoStream ( const char *  s,
std::ios_base::openmode  mode 
)

Constructor takes name of input file, mode.

Constructor, takes char * filename and int flags as arguments. Calls base class open method with filename and flags as arguments. Also allocates xdr stream. Note : If no rpc/xdr support xdr calls are #ifdef'd out.

References BoStream::outBuf, and BoStream::xdrOutBuf.


Member Function Documentation

BoStream & operator<< ( const String ds)

Binary Output stream operator<<.

The String operator<< must first write the xdr buffer size and the original string size to the stream. The input operator needs this information to be able to correctly read and convert the String.

References String::data(), BoStream::outBuf, and BoStream::xdrOutBuf.

BoStream & operator<< ( const char *  s)

Output operator, writes char* TO binary stream BoStream.

The output of char* is the same as the output of the String. The size of the xdr buffer and the size of the string must be written first, then the string itself.

References BoStream::outBuf, and BoStream::xdrOutBuf.


The documentation for this class was generated from the following files: