Template Class InputTextStream< Device, true >
Defined in File input_text_stream.hpp
Inheritance Relationships
Base Type
public ecl::interfaces::BaseTextStream< Device >
(Template Class BaseTextStream)
Class Documentation
-
template<typename Device>
class InputTextStream<Device, true> : public virtual ecl::interfaces::BaseTextStream<Device> Input text stream interface.
Defines the appropriate functionality required for input text streams.
Usage:
Instantiate
Open the underlying device
Stream
TextStream<IFile> ifstream; ifstream.device().open("dudes.txt"); char c; ifstream >> c;
Some notes - text streams support reading by one of three methods:
readln()
element by element (separated by whitespace or carriage returns
raw characters (by default this is disabled, enable with enableRawCharReads())
- Template Parameters:
Device – : this must be a class that satisfies the input device concept (refer to the documentation in ecl_concepts for details).
Public Functions
-
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;
-
inline virtual ~InputTextStream()
-
InputTextStream<Device> &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.
- Parameters:
c – : input value being read from the stream.
- Throws:
ecl::StandardException – : throws if the underlying device has not been opened [debug mode only].
- Returns:
InputTextStream : returns the stream for further manipulation.
-
InputTextStream<Device> &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.
- Parameters:
s – : input being read from the stream.
- Throws:
ecl::StandardException – : throws if the underlying device has not been opened [debug mode only].
- Returns:
InputTextStream : returns the stream for further manipulation.
-
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.
- Parameters:
i – : input value to be filled.
- Throws:
ecl::StandardException – : throws if the underlying device has not been opened [debug mode only].
- Returns:
InputTextStream : returns the stream for further manipulation.
-
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.
- Parameters:
i – : input value to be filled.
- Throws:
ecl::StandardException – : throws if the underlying device has not been opened [debug mode only].
- Returns:
InputTextStream : returns the stream for further manipulation.
-
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.
- Parameters:
i – : input value to be filled.
- Throws:
ecl::StandardException – : throws if the underlying device has not been opened [debug mode only].
- Returns:
InputTextStream : returns the stream for further manipulation.
-
InputTextStream<Device> &operator>>(unsigned char &c)
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.
- Parameters:
uc – : input value to be filled.
- Throws:
ecl::StandardException – : throws if the underlying device has not been opened [debug mode only].
- Returns:
InputTextStream : returns the stream for further manipulation.
-
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.
- Parameters:
i – : input value to be filled.
- Throws:
ecl::StandardException – : throws if the underlying device has not been opened [debug mode only].
- Returns:
InputTextStream : returns the stream for further manipulation.
-
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.
- Parameters:
i – : input value to be filled.
- Throws:
ecl::StandardException – : throws if the underlying device has not been opened [debug mode only].
- Returns:
InputTextStream : returns the stream for further manipulation.
-
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.
- Parameters:
i – : input value to be filled.
- Throws:
ecl::StandardException – : throws if the underlying device has not been opened [debug mode only].
- Returns:
InputTextStream : returns the stream for further manipulation.
-
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.
- Parameters:
f – : input value to be filled.
- Throws:
ecl::StandardException – : throws if the underlying device has not been opened [debug mode only].
- Returns:
InputTextStream : returns the stream for further manipulation.
-
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.
- Parameters:
d – : input value to be filled.
- Throws:
ecl::StandardException – : throws if the underlying device has not been opened [debug mode only].
- Returns:
InputTextStream : returns the stream for further manipulation.
-
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.
- Parameters:
i – : input value to be filled.
- Throws:
ecl::StandardException – : throws if the underlying device has not been opened [debug mode only].
- Returns:
InputTextStream : returns the stream for further manipulation.
-
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.
- Parameters:
i – : input value to be filled.
- Throws:
ecl::StandardException – : throws if the underlying device has not been opened [debug mode only].
- Returns:
InputTextStream : returns the stream for further manipulation.
-
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’.
- Parameters:
b – : input value to be filled.
- Throws:
ecl::StandardException – : throws if the underlying device has not been opened [debug mode only].
- Returns:
InputTextStream : returns the stream for further manipulation.
-
void 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.
See also
-
void 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.
See also