oeistream

class oeistream : public oestream

This class represents oeistream.

Defines the platform independent interface and implementation for a generic input data stream class.

The following methods are publicly inherited from oestream:

operator bool rewind tell
eof seek  
length size  
The following classes derive from this class:

Constructors

oeistream()

Creates an instance of an oeistream. This class is designed to provide an interface and some functionality; however, this class does not define a data source and therefore instances of this class have no independent functionality.

operator>>

oeistream &operator>>(oestream &(_f)(oestream &))
oeistream &operator>>(oeistream &(_f)(oeistream &))

Use of these operators executes the specified function (‘f’) on the stream in question. In order for proper compilation and execution, the specified function must be prototyped according to the API shown above.

oeistream &operator>>(oeostream &)

Sends all of the remaining input on the stream to the specified oeostream.

oeistream &operator>>(int &)
oeistream &operator>>(bool &)
oeistream &operator>>(long &)
oeistream &operator>>(char &)
oeistream &operator>>(float &)
oeistream &operator>>(short &)
oeistream &operator>>(double &)
oeistream &operator>>(std::string &)
oeistream &operator>>(signed char &)
oeistream &operator>>(unsigned int &)
oeistream &operator>>(unsigned long &)
oeistream &operator>>(unsigned char &)
oeistream &operator>>(unsigned short &)

These operators read the next whitespace-delimited token on the input stream, converts it into the appropriate data type, and stores that value in the specified parameter. The use of these operators on non-text streams is undefined.

close

void close()

Closes the input stream. All future attempts to read from this stream will fail until it is opened again with new input.

get

bool get(char &c)
bool get(signed char &c)
bool get(unsigned char &c)

Gets the next byte off of the stream and assigns its value to the parameter ‘c’. Returns whether or not the byte read equals EOF.

getbyte

int getbyte()

Returns the next byte off of the stream.

getline

bool getline(std::string &sbuffer)
bool getline(char *buffer, oesize_t max)
bool getline(signed char *buffer, oesize_t max)
bool getline(std::string &sbuffer, oesize_t max)
bool getline(unsigned char *buffer, oesize_t max)

Retrieves the next text line from the stream and directly copies its contents into the ‘buffer’ parameter. The newline character is not copied with the rest of the contents, though a null terminator, ‘0’, is placed at the end of the contents. The ‘max’ parameter specifies the maximum size of the memory passed in as the ‘buffer’ argument. If a newline character is not found within ‘max - 1’ characters, only the specified number of characters will be copied into the buffer and all the remaining characters in the stream before the next newline character will be discarded.

gettoken

bool gettoken(char *buffer, oesize_t max)
bool gettoken(signed char *buffer, oesize_t max)
bool gettoken(std::string &sbuffer, oesize_t max)
bool gettoken(unsigned char *buffer, oesize_t max)

Retrieves the next whitespace delimited token from the stream and directly copies its contents into the ‘buffer’ parameter. This function discards the whitespace characters read when searching for the next token. The ‘max’ parameter specifies the maximum number of characters allowed per token. If a whitespace character is not found within the specified number of characters, only the specified number of characters will be copied into the buffer and all the remaining characters in the stream before the next whitespace character will be discarded.

open

bool open(const char *name)
bool open(const std::string &name)
bool open(unsigned char *buffer, oesize_t len)

Opens the input stream with data from the specified sources. Passing a ‘name’ parameter will result in invocation of a protected virtual method to appropriate handle the specified input source. Passing a pointer to a character buffer along with the buffer’s size will result in the stream wrapping the ‘buffer’ and using that as the stream data source. Returns whether or not data can now be read from the stream.

peekbyte

int peekbyte()

Returns the value of the next byte without removing that byte from the input stream. Returns -1 if the stream is not valid.

read

oesize_t read(std::string &sbuffer)
oesize_t read(char *buffer, oesize_t len)
oesize_t read(signed char *buffer, oesize_t len)
oesize_t read(std::string &sbuffer, oesize_t len)
oesize_t read(unsigned char *buffer, oesize_t len)

Reads the next len number of bytes off of the stream, stores them in the specified ‘buffer’ and returns the number of bytes actually read. It is the user’s responsibility when using any of the three char * versions to make sure that the specified ‘buffer’ has been properly allocated and has enough room to store len bytes. This function does not add a NULL terminator to the end of the buffer.

The version that takes a std::string without a size will read the entire contents of the stream into the string, or until std::bad_alloc is thrown when the system runs out of memory.

skip

bool skip(oefpos_t len)

Discards the next number of bytes specified by ‘len’ in the stream. Returns whether or not there are any bytes left in the stream.

skipbyte

bool skipbyte()

Discards the next byte in the stream. Returns whether or not there are any bytes left in the stream.

skipline

bool skipline()

Discards the next text line in the stream. Returns whether or not there are any bytes left in the stream.