The binary input stream class. Overloads the >> operator for all data types. More...
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. | |
BiStream & | operator>> (String &ds) |
Binary Input stream operator>> | |
BiStream & | operator>> (char *s) |
Input operator, reads char* from binary stream BiStream. | |
BiStream & | operator>> (char &c) |
Input operator, reads char from binary stream BiStream. | |
BiStream & | operator>> (int &i) |
Input operator, reads int* from binary stream BiStream. | |
BiStream & | operator>> (long &l) |
Input operator, reads long from binary stream BiStream. | |
BiStream & | operator>> (short &s) |
Input operator, reads short from binary stream BiStream. | |
BiStream & | operator>> (bool &b) |
Input operator, reads bool from binary stream BiStream. | |
BiStream & | operator>> (double &d) |
Input operator, reads double from binary stream BiStream. | |
BiStream & | operator>> (float &f) |
Input operator, reads float from binary stream BiStream. | |
BiStream & | operator>> (unsigned char &c) |
Input operator, reads unsigned char* from binary stream BiStream. | |
BiStream & | operator>> (unsigned int &i) |
Input operator, reads unsigned int from binary stream BiStream. | |
BiStream & | operator>> (unsigned long &l) |
Input operator, reads unsigned long from binary stream BiStream. | |
BiStream & | operator>> (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. |
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.
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.
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.