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). More... | |
void | enableRawCharReads () |
This permits true char by char reads (including space and newline chars). More... | |
InputTextStream () | |
Connects the stream to an input device. More... | |
InputTextStream< Device > & | operator>> (char &c) |
Reads an unformatted char to the stream. More... | |
InputTextStream< Device > & | operator>> (std::string &s) |
Reads an unformatted string from the stream. More... | |
InputTextStream< Device > & | operator>> (short &i) |
Converts a value from the stream to a short. If there is an error at any part of the conversion (non-digit, too large) it will leave the input argument unchanged and set the fail() response to true. More... | |
InputTextStream< Device > & | operator>> (int &i) |
Converts a value from the stream to an int. If there is an error at any part of the conversion (non-digit, too large) it will leave the input argument unchanged and set the fail() response to true. More... | |
InputTextStream< Device > & | operator>> (long &i) |
Converts a value from the stream to a long. If there is an error at any part of the conversion (non-digit, too large) it will leave the input argument unchanged and set the fail() response to true. More... | |
InputTextStream< Device > & | operator>> (unsigned char &c) |
Converts a value from the stream to an unsigned char. More... | |
InputTextStream< Device > & | operator>> (unsigned short &i) |
Converts a value from the stream to an unsigned short. If there is an error at any part of the conversion (non-digit, too large) it will leave the input argument unchanged and set the fail() response to true. More... | |
InputTextStream< Device > & | operator>> (unsigned int &i) |
Converts a value from the stream to an unsigned int. If there is an error at any part of the conversion (non-digit, too large) it will leave the input argument unchanged and set the fail() response to true. More... | |
InputTextStream< Device > & | operator>> (unsigned long &i) |
Converts a value from the stream to an unsigned long. If there is an error at any part of the conversion (non-digit, too large) it will leave the input argument unchanged and set the fail() response to true. More... | |
InputTextStream< Device > & | operator>> (float &f) |
Converts a value from the stream to a float. If there is an error at any part of the conversion it will leave the input argument unchanged and set the fail() response to true. More... | |
InputTextStream< Device > & | operator>> (double &d) |
Converts a value from the stream to a float. If there is an error at any part of the conversion it will leave the input argument unchanged and set the fail() response to true. More... | |
InputTextStream< Device > & | operator>> (long long &i) |
Converts a value from the stream to a long long. If there is an error at any part of the conversion (non-digit, too large) it will leave the input argument unchanged and set the fail() response to true. More... | |
InputTextStream< Device > & | operator>> (unsigned long long &i) |
Converts a value from the stream to an unsigned long long. If there is an error at any part of the conversion (non-digit, too large) it will leave the input argument unchanged and set the fail() response to true. More... | |
InputTextStream< Device > & | operator>> (bool &b) |
Converts a value from the stream to a bool. If there is an error at any part of the conversion it will leave the input argument unchanged and set the fail() response to true. Valid text input for a bool value includes 'true', 'TRUE', 'false', 'FALSE'. More... | |
virtual | ~InputTextStream () |
Public Member Functions inherited from ecl::interfaces::BaseTextStream< Device > | |
BaseTextStream () | |
Device & | device () |
Provides access to the underlying output device. More... | |
const ecl::Error & | errorStatus () const |
Enumeration indicating the exit status of the last read operation. More... | |
bool | fail () const |
Denotes the status of the last device operation. More... | |
virtual | ~BaseTextStream () |
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. More... | |
Private Attributes | |
bool | raw_char_reads |
Additional Inherited Members | |
Protected Attributes inherited from ecl::interfaces::BaseTextStream< Device > | |
ecl::Error | error |
Device | io_device |
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:
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.
Definition at line 148 of file input_text_stream.hpp.
|
inlinevirtual |
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.
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 475 of file input_text_stream.hpp.
|
private |
Definition at line 650 of file input_text_stream.hpp.
|
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.
InputTextStream< Device > & ecl::interfaces::InputTextStream< Device, true >::operator>> | ( | char & | c | ) |
Reads an unformatted char to the stream.
Reads an unformatted char from the stream. Note, this will absolutely read every character in the device.
c | : input value being read from the stream. |
ecl::StandardException | : throws if the underlying device has not been opened [debug mode only]. |
Definition at line 166 of file input_text_stream.hpp.
InputTextStream< Device > & ecl::interfaces::InputTextStream< Device, true >::operator>> | ( | std::string & | s | ) |
Reads an unformatted string from the stream.
Reads an unformatted string from the stream. Essentially, this reads characters into a string until either a space or a newline char is reached, that is, it reads whole words at a time and removes any leading or trailing space/newline entities.
s | : input being read from the stream. |
ecl::StandardException | : throws if the underlying device has not been opened [debug mode only]. |
Definition at line 198 of file input_text_stream.hpp.
InputTextStream< Device > & ecl::interfaces::InputTextStream< Device, true >::operator>> | ( | short & | i | ) |
Converts a value from the stream to a short. If there is an error at any part of the conversion (non-digit, too large) it will leave the input argument unchanged and set the fail() response to true.
i | : input value to be filled. |
ecl::StandardException | : throws if the underlying device has not been opened [debug mode only]. |
Definition at line 233 of file input_text_stream.hpp.
InputTextStream< Device > & ecl::interfaces::InputTextStream< Device, true >::operator>> | ( | int & | i | ) |
Converts a value from the stream to an int. If there is an error at any part of the conversion (non-digit, too large) it will leave the input argument unchanged and set the fail() response to true.
i | : input value to be filled. |
ecl::StandardException | : throws if the underlying device has not been opened [debug mode only]. |
Definition at line 253 of file input_text_stream.hpp.
InputTextStream< Device > & ecl::interfaces::InputTextStream< Device, true >::operator>> | ( | long & | i | ) |
Converts a value from the stream to a long. If there is an error at any part of the conversion (non-digit, too large) it will leave the input argument unchanged and set the fail() response to true.
i | : input value to be filled. |
ecl::StandardException | : throws if the underlying device has not been opened [debug mode only]. |
Definition at line 271 of file input_text_stream.hpp.
InputTextStream< Device > & ecl::interfaces::InputTextStream< Device, true >::operator>> | ( | unsigned char & | uc | ) |
Converts a value from the stream to an unsigned char.
If there is an error at any part of the conversion (non-digit, too large) it will leave the input argument unchanged and set the fail() response to true.
uc | : input value to be filled. |
ecl::StandardException | : throws if the underlying device has not been opened [debug mode only]. |
Definition at line 307 of file input_text_stream.hpp.
InputTextStream< Device > & ecl::interfaces::InputTextStream< Device, true >::operator>> | ( | unsigned short & | i | ) |
Converts a value from the stream to an unsigned short. If there is an error at any part of the conversion (non-digit, too large) it will leave the input argument unchanged and set the fail() response to true.
i | : input value to be filled. |
ecl::StandardException | : throws if the underlying device has not been opened [debug mode only]. |
Definition at line 325 of file input_text_stream.hpp.
InputTextStream< Device > & ecl::interfaces::InputTextStream< Device, true >::operator>> | ( | unsigned int & | i | ) |
Converts a value from the stream to an unsigned int. If there is an error at any part of the conversion (non-digit, too large) it will leave the input argument unchanged and set the fail() response to true.
i | : input value to be filled. |
ecl::StandardException | : throws if the underlying device has not been opened [debug mode only]. |
Definition at line 343 of file input_text_stream.hpp.
InputTextStream< Device > & ecl::interfaces::InputTextStream< Device, true >::operator>> | ( | unsigned long & | i | ) |
Converts a value from the stream to an unsigned long. If there is an error at any part of the conversion (non-digit, too large) it will leave the input argument unchanged and set the fail() response to true.
i | : input value to be filled. |
ecl::StandardException | : throws if the underlying device has not been opened [debug mode only]. |
Definition at line 361 of file input_text_stream.hpp.
InputTextStream< Device > & ecl::interfaces::InputTextStream< Device, true >::operator>> | ( | float & | f | ) |
Converts a value from the stream to a float. If there is an error at any part of the conversion it will leave the input argument unchanged and set the fail() response to true.
f | : input value to be filled. |
ecl::StandardException | : throws if the underlying device has not been opened [debug mode only]. |
Definition at line 398 of file input_text_stream.hpp.
InputTextStream< Device > & ecl::interfaces::InputTextStream< Device, true >::operator>> | ( | double & | d | ) |
Converts a value from the stream to a float. If there is an error at any part of the conversion it will leave the input argument unchanged and set the fail() response to true.
d | : input value to be filled. |
ecl::StandardException | : throws if the underlying device has not been opened [debug mode only]. |
Definition at line 416 of file input_text_stream.hpp.
InputTextStream< Device > & ecl::interfaces::InputTextStream< Device, true >::operator>> | ( | long long & | i | ) |
Converts a value from the stream to a long long. If there is an error at any part of the conversion (non-digit, too large) it will leave the input argument unchanged and set the fail() response to true.
i | : input value to be filled. |
ecl::StandardException | : throws if the underlying device has not been opened [debug mode only]. |
Definition at line 288 of file input_text_stream.hpp.
InputTextStream< Device > & ecl::interfaces::InputTextStream< Device, true >::operator>> | ( | unsigned long long & | i | ) |
Converts a value from the stream to an unsigned long long. If there is an error at any part of the conversion (non-digit, too large) it will leave the input argument unchanged and set the fail() response to true.
i | : input value to be filled. |
ecl::StandardException | : throws if the underlying device has not been opened [debug mode only]. |
Definition at line 379 of file input_text_stream.hpp.
InputTextStream< Device > & ecl::interfaces::InputTextStream< Device, true >::operator>> | ( | bool & | b | ) |
Converts a value from the stream to a bool. If there is an error at any part of the conversion it will leave the input argument unchanged and set the fail() response to true. Valid text input for a bool value includes 'true', 'TRUE', 'false', 'FALSE'.
b | : input value to be filled. |
ecl::StandardException | : throws if the underlying device has not been opened [debug mode only]. |
Definition at line 436 of file input_text_stream.hpp.
|
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.
|
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.
|
private |
Definition at line 120 of file input_text_stream.hpp.