#include <inputStream.h>
Public Types | |
| typedef std::istream::char_type | char_type |
| This typedef simply mirrors std::istream::char_type. | |
| typedef unsigned int | FormatFlag |
| These bit flag constants are used to control InputStream behavior. | |
Public Member Functions | |
| InputStream (std::istream &inputStream, FormatFlag flags=NO_FLAG) | |
| This constructor pretends it's copying an input stream. | |
| ~InputStream () | |
| The destructor does nothing. | |
| operator void * () const | |
| This operator converts to void* by dispatching to the std::istream conversion operator. | |
| operator std::istream & () const | |
| This operator converts to std::istream reference. | |
| template<class Type> | |
| InputStream & | operator>> (Type &typeInstance) |
| This operator simply dispatches to the corresponding std::istream operator. | |
| bool | bad () |
| This member function simply dispatches to the corresponding std::istream member function. | |
| void | clear (std::istream::iostate state=std::istream::goodbit) |
| This member function simply dispatches to the corresponding std::istream member function. | |
| bool | eof () |
| This member function simply dispatches to the corresponding std::istream member function. | |
| bool | fail () |
| This member function simply dispatches to the corresponding std::istream member function. | |
| std::istream::int_type | get () |
| This member function simply dispatches to the corresponding std::istream member function. | |
| InputStream | getline (char_type *inputBuffer, std::streamsize numberOfCharacters) |
This member function reads no more than the (numberOfCharacters
| |
| std::istream::int_type | peek () |
| This member function simply dispatches to the corresponding std::istream member function. | |
| InputStream & | expect (std::istream::char_type inputChar) |
| This member function reads one character from the input and sets failbit if doesn't match the specified value. | |
| InputStream & | expect (const std::string &inputString) |
| This member function reads characters from the input and sets failbit if they don't match the specified string. | |
| InputStream & | expect (const char *inputCString, size_t stringSize=0) |
| This member function reads characters from the input and sets failbit if they don't match the specified string. | |
| void | skipWhiteSpace () |
| This member function skips characters up to the next non-whitespace. | |
Static Public Attributes | |
| static const FormatFlag | NO_FLAG = 0x00 |
| NO_FLAG is the default state. | |
| static const FormatFlag | SKIP_WHITESPACE = 0x01 |
| SKIP_WHITESPACE indicates that expect() member function calls should remove any preceding whitespace from the stream input before comparing against the expected input. | |
| static const FormatFlag | SLOPPY_EXPECT = 0x02 |
| SLOPPY_EXPECT indicates that expect() member function calls should simply read the correct number of bytes from the input stream, but not actually verify the that the bytes have the right value. | |
For example, it provides the expect() member function which helps with reading strictly formatted input. Ideally, this would inherit most of its member functions from std::istream, but alas that requires access to stuff which isn't in the istream interface.
Definition at line 32 of file inputStream.h.
| typedef std::istream::char_type dlr::common::InputStream::char_type |
| typedef unsigned int dlr::common::InputStream::FormatFlag |
These bit flag constants are used to control InputStream behavior.
You pass them as constructor arguments, or else as arguments to the (not yet implemented) setFlags member function.
Definition at line 48 of file inputStream.h.
| dlr::common::InputStream::InputStream | ( | std::istream & | inputStream, | |
| FormatFlag | flags = NO_FLAG | |||
| ) | [inline] |
This constructor pretends it's copying an input stream.
Unfortunately, the istream copy constructor is private, so instead we just take a reference. You might use this constructor like this:
InputStream myStream(std::cin, (InputStream::SKIP_WHITESPACE | InputStream::SLOPPY_EXPECT));
| inputStream | This is the stream to be copied. | |
| flags | This argument specifies flags which influence the behavior of the InputStream instance. |
Definition at line 89 of file inputStream.h.
| dlr::common::InputStream::~InputStream | ( | ) | [inline] |
| dlr::common::InputStream::operator void * | ( | ) | const [inline] |
This operator converts to void* by dispatching to the std::istream conversion operator.
Definition at line 108 of file inputStream.h.
| dlr::common::InputStream::operator std::istream & | ( | ) | const [inline] |
This operator converts to std::istream reference.
Definition at line 119 of file inputStream.h.
| InputStream& dlr::common::InputStream::operator>> | ( | Type & | typeInstance | ) | [inline] |
This operator simply dispatches to the corresponding std::istream operator.
| typeInstance | This argument is passed directly to the corresponding istream operator. |
Definition at line 136 of file inputStream.h.
| bool dlr::common::InputStream::bad | ( | ) | [inline] |
This member function simply dispatches to the corresponding std::istream member function.
Definition at line 152 of file inputStream.h.
| void dlr::common::InputStream::clear | ( | std::istream::iostate | state = std::istream::goodbit |
) | [inline] |
This member function simply dispatches to the corresponding std::istream member function.
| state | This argument is passed directly to the corresponding istream member function. |
Definition at line 165 of file inputStream.h.
| bool dlr::common::InputStream::eof | ( | ) | [inline] |
This member function simply dispatches to the corresponding std::istream member function.
Definition at line 178 of file inputStream.h.
| bool dlr::common::InputStream::fail | ( | ) | [inline] |
This member function simply dispatches to the corresponding std::istream member function.
Definition at line 191 of file inputStream.h.
| std::istream::int_type dlr::common::InputStream::get | ( | ) | [inline] |
This member function simply dispatches to the corresponding std::istream member function.
Definition at line 204 of file inputStream.h.
| InputStream dlr::common::InputStream::getline | ( | char_type * | inputBuffer, | |
| std::streamsize | numberOfCharacters | |||
| ) | [inline] |
This member function reads no more than the (numberOfCharacters
| inputBuffer | This argument specifies buffer into which characters will be read. | |
| numberOfCharacters | This argument specifies the size of the buffer. |
Definition at line 223 of file inputStream.h.
| std::istream::int_type dlr::common::InputStream::peek | ( | ) | [inline] |
This member function simply dispatches to the corresponding std::istream member function.
Definition at line 236 of file inputStream.h.
| InputStream& dlr::common::InputStream::expect | ( | std::istream::char_type | inputChar | ) | [inline] |
This member function reads one character from the input and sets failbit if doesn't match the specified value.
| inputChar | This argument defines what the upcoming stream input character should be. |
Definition at line 253 of file inputStream.h.
| InputStream& dlr::common::InputStream::expect | ( | const std::string & | inputString | ) | [inline] |
This member function reads characters from the input and sets failbit if they don't match the specified string.
| inputString | This argument defines what the upcoming stream input characters should be. |
Definition at line 273 of file inputStream.h.
| InputStream& dlr::common::InputStream::expect | ( | const char * | inputCString, | |
| size_t | stringSize = 0 | |||
| ) | [inline] |
This member function reads characters from the input and sets failbit if they don't match the specified string.
The second argument is optional. If it is not provided, the number of characters to read and compare will be determined by calling strlen() on the first argument. If the second argument is provided, then it specifies the number of characters to read and compare. Note that this second mode does not respect '' termination of the input string, so this call:
inputStream.expect("hello world", 240); // Catastrophe!
will likely cause problems by reading past the end of the input string.
| inputCString | This argument defines what the upcoming stream input characters should be. | |
| stringSize | This argument, if specified, indicates how many characters to read and compare. |
Definition at line 302 of file inputStream.h.
| void dlr::common::InputStream::skipWhiteSpace | ( | ) | [inline] |
This member function skips characters up to the next non-whitespace.
Definition at line 363 of file inputStream.h.
const FormatFlag dlr::common::InputStream::NO_FLAG = 0x00 [static] |
const FormatFlag dlr::common::InputStream::SKIP_WHITESPACE = 0x01 [static] |
SKIP_WHITESPACE indicates that expect() member function calls should remove any preceding whitespace from the stream input before comparing against the expected input.
Definition at line 62 of file inputStream.h.
const FormatFlag dlr::common::InputStream::SLOPPY_EXPECT = 0x02 [static] |
SLOPPY_EXPECT indicates that expect() member function calls should simply read the correct number of bytes from the input stream, but not actually verify the that the bytes have the right value.
Definition at line 71 of file inputStream.h.
1.5.2