Input text stream interface. More...
#include <input_text_stream.hpp>
Public Member Functions | |
void | disableRawCharReads () |
This ensures char reads are read element by element (not byte by byte). | |
InputTextStream () | |
Connects the stream to an input device. | |
virtual | ~InputTextStream () |
Public Attributes | |
InputTextStream< Device > &operator>>(char &c) ecl_assert_throw_decl(ecl InputTextStream< Device > &operator>>(std::string &s) ecl_assert_throw_decl(ecl InputTextStream< Device > &operator>>(short &i) ecl_assert_throw_decl(ecl InputTextStream< Device > &operator>>(int &i) ecl_assert_throw_decl(ecl InputTextStream< Device > &operator>>(long &i) ecl_assert_throw_decl(ecl InputTextStream< Device > &operator>>(unsigned char &c) ecl_assert_throw_decl(ecl InputTextStream< Device > &operator>>(unsigned short &i) ecl_assert_throw_decl(ecl InputTextStream< Device > &operator>>(unsigned int &i) ecl_assert_throw_decl(ecl InputTextStream< Device > &operator>>(unsigned long &i) ecl_assert_throw_decl(ecl InputTextStream< Device > &operator>>(float &f) ecl_assert_throw_decl(ecl InputTextStream< Device > &operator>>(double &d) ecl_assert_throw_decl(ecl InputTextStream< Device > &operator>>(long long &i) ecl_assert_throw_decl(ecl InputTextStream< Device > &operator>>(unsigned long long &i) ecl_assert_throw_decl(ecl InputTextStream< Device > &operator>>(bool &b) ecl_assert_throw_decl(ecl void | enableRawCharReads () |
This permits true char by char reads (including space and newline chars). | |
Private Member Functions | |
template<typename Number > | |
bool | getFloatFromStream (Number &f) |
template<typename Number > | |
bool | getIntegerFromStream (Number &i) |
template<typename Number > | |
bool | parseHexInteger (Number &i) |
bool | skipLeadingWhiteSpace (char &c) |
Private implementation that churns through any leading white space. | |
Private Attributes | |
bool | raw_char_reads |
Input text stream interface.
Defines the appropriate functionality required for input text streams.
Device | : this must be a class that satisfies the input device concept (refer to the documentation in ecl_concepts for details). |
Usage:
TextStream<IFile> ifstream; ifstream.device().open("dudes.txt"); char c; ifstream >> c;
Some notes - text streams support reading by one of three methods:
Definition at line 87 of file input_text_stream.hpp.
ecl::interfaces::InputTextStream< Device, true >::InputTextStream | ( | ) |
Connects the stream to an input device.
Connects the text stream to the associated input device. Use the device() handle to properly open the device, e.g.
InputTextStream<IFile> ifstream;
Definition at line 148 of file input_text_stream.hpp.
virtual ecl::interfaces::InputTextStream< Device, true >::~InputTextStream | ( | ) | [inline, virtual] |
Definition at line 93 of file input_text_stream.hpp.
void ecl::interfaces::InputTextStream< Device, true >::disableRawCharReads | ( | ) |
This ensures char reads are read element by element (not byte by byte).
This has the opposite functionality to enableRawCharReads(). See that method for more information.
Definition at line 486 of file input_text_stream.hpp.
bool ecl::interfaces::InputTextStream< Device, true >::getFloatFromStream | ( | Number & | f | ) | [private] |
Definition at line 650 of file input_text_stream.hpp.
bool ecl::interfaces::InputTextStream< Device, true >::getIntegerFromStream | ( | Number & | i | ) | [private] |
Parses a value from a stream into an integral type.
i | : the integral type variable to stream the value into. |
Definition at line 572 of file input_text_stream.hpp.
bool ecl::interfaces::InputTextStream< Device, true >::parseHexInteger | ( | Number & | i | ) | [private] |
Parses a hex number from a stream into an integral type.
i | : the integer to stream the value to. |
Definition at line 520 of file input_text_stream.hpp.
bool ecl::interfaces::InputTextStream< Device, true >::skipLeadingWhiteSpace | ( | char & | c | ) | [private] |
Private implementation that churns through any leading white space.
This checks for leading space and newline characters. If successful, it returns the first read character in its argument.
c | : if successful, the first legitimate character is returned here. |
Definition at line 503 of file input_text_stream.hpp.
void ecl::interfaces::InputTextStream< Device, true >::enableRawCharReads |
This permits true char by char reads (including space and newline chars).
By default, text streams read chars (via the operator>> (char &c)) method in the same way as every other operator is used, that is, element by element. As a result, any leading whitespace or newline characters are ignored. By calling this function, you can disable this functionality (for the operator>> (char&c) method only) so true byte by byte reads can be performed. This is usually only useful for things like serial devices - not so much for files or standard input style devices.
Definition at line 116 of file input_text_stream.hpp.
bool ecl::interfaces::InputTextStream< Device, true >::raw_char_reads [private] |
Definition at line 120 of file input_text_stream.hpp.