Public Member Functions | Private Attributes
BiStream Class Reference

The binary input stream class. Overloads the >> operator for all data types. More...

List of all members.

Public Member Functions

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

Private Attributes

XDR xdrInBuf
 XDR input stream buffer.
char inBuf [MAX_NETOBJ_SZ]
 Buffer to hold data as it is read in.

Detailed Description

The binary input stream class. Overloads the >> operator for all data types.

The Dakota::BiStream class is a binary input class which overloads the >> operator for all standard data types (int, char, float, etc). The class relies on the methods within the ifstream base class. The Dakota::BiStream class inherits from the ifstream class. If available, the class utilize rpc/xdr to construct machine independent binary files. These Dakota restart files can be moved from host to host. The motivation to develop these classes was to replace the Rogue wave classes which Dakota historically used for binary I/O.


Constructor & Destructor Documentation

BiStream ( )

Default constructor, need to open.

Default constructor, allocates xdr stream , but does not call the open method. The open method must be called before stream can be read.

References BiStream::inBuf, and BiStream::xdrInBuf.

BiStream ( const char *  s)

Constructor takes name of input file.

Constructor which takes a char* filename. Calls the base class open method with the filename and no other arguments. Also allocates the xdr stream.

References BiStream::inBuf, and BiStream::xdrInBuf.

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

Constructor takes name of input file, mode.

Constructor which takes a char* filename and int flags. Calls the base class open method with the filename and flags as arguments. Also allocates xdr stream.

References BiStream::inBuf, and BiStream::xdrInBuf.

~BiStream ( )

Destructor, calls xdr_destroy to delete xdr stream.

Destructor, destroys the xdr stream allocated in constructor

References BiStream::xdrInBuf.


Member Function Documentation

BiStream & operator>> ( String ds)

Binary Input stream operator>>

The String input operator must first read both the xdr buffer size and the size of the string written. Once these our read it can then read and convert the String correctly.

References BiStream::inBuf, and BiStream::xdrInBuf.

BiStream & operator>> ( char *  s)

Input operator, reads char* from binary stream BiStream.

Reading char array is a special case. The method has no way of knowing if the length to the input array is large enough, it assumes it is one char longer than actual string, (Null terminator added). As with the String the size of the xdr buffer as well as the char array size written must be read from the stream prior to reading and converting the char array.

References BiStream::inBuf, and BiStream::xdrInBuf.


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