Public Member Functions | Private Member Functions | Private Attributes | List of all members
ecl::interfaces::InputTextStream< Device, true > Class Template Reference

Input text stream interface. More...

#include <input_text_stream.hpp>

Inheritance diagram for ecl::interfaces::InputTextStream< Device, true >:
Inheritance graph
[legend]

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>> (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...
 
InputTextStream< Device > & operator>> (char &c)
 Reads an unformatted char to the stream. 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>> (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>> (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>> (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>> (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>> (std::string &s)
 Reads an unformatted string from the stream. More...
 
InputTextStream< Device > & operator>> (unsigned char &c)
 Converts a value from the stream to an unsigned char. 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>> (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>> (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...
 
virtual ~InputTextStream ()
 
- Public Member Functions inherited from ecl::interfaces::BaseTextStream< Device >
 BaseTextStream ()
 
Device & device ()
 Provides access to the underlying output device. More...
 
const ecl::ErrorerrorStatus () 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
 

Detailed Description

template<typename Device>
class ecl::interfaces::InputTextStream< Device, true >

Input text stream interface.

Defines the appropriate functionality required for input text streams.

Template Parameters
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 99 of file input_text_stream.hpp.

Constructor & Destructor Documentation

◆ InputTextStream()

template<typename Device >
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 160 of file input_text_stream.hpp.

◆ ~InputTextStream()

template<typename Device >
virtual ecl::interfaces::InputTextStream< Device, true >::~InputTextStream ( )
inlinevirtual

Definition at line 105 of file input_text_stream.hpp.

Member Function Documentation

◆ disableRawCharReads()

template<typename Device >
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.

See also
enableRawCharReads().

Definition at line 498 of file input_text_stream.hpp.

◆ enableRawCharReads()

template<typename Device >
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.

See also
disableRawCharReads().

Definition at line 487 of file input_text_stream.hpp.

◆ getFloatFromStream()

template<typename Device >
template<typename Number >
bool ecl::interfaces::InputTextStream< Device, true >::getFloatFromStream ( Number &  f)
private

Definition at line 662 of file input_text_stream.hpp.

◆ getIntegerFromStream()

template<typename Device >
template<typename Number >
bool ecl::interfaces::InputTextStream< Device, true >::getIntegerFromStream ( Number &  i)
private

Parses a value from a stream into an integral type.

Parameters
i: the integral type variable to stream the value into.

Definition at line 584 of file input_text_stream.hpp.

◆ operator>>() [1/14]

template<typename Device >
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'.

Parameters
b: input value to be filled.
Exceptions
ecl::StandardException: throws if the underlying device has not been opened [debug mode only].
Returns
InputTextStream : returns the stream for further manipulation.

Definition at line 448 of file input_text_stream.hpp.

◆ operator>>() [2/14]

template<typename Device >
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.

Parameters
c: input value being read from the stream.
Exceptions
ecl::StandardException: throws if the underlying device has not been opened [debug mode only].
Returns
InputTextStream : returns the stream for further manipulation.

Definition at line 178 of file input_text_stream.hpp.

◆ operator>>() [3/14]

template<typename Device >
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.

Parameters
d: input value to be filled.
Exceptions
ecl::StandardException: throws if the underlying device has not been opened [debug mode only].
Returns
InputTextStream : returns the stream for further manipulation.

Definition at line 428 of file input_text_stream.hpp.

◆ operator>>() [4/14]

template<typename Device >
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.

Parameters
f: input value to be filled.
Exceptions
ecl::StandardException: throws if the underlying device has not been opened [debug mode only].
Returns
InputTextStream : returns the stream for further manipulation.

Definition at line 410 of file input_text_stream.hpp.

◆ operator>>() [5/14]

template<typename Device >
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.

Parameters
i: input value to be filled.
Exceptions
ecl::StandardException: throws if the underlying device has not been opened [debug mode only].
Returns
InputTextStream : returns the stream for further manipulation.

Definition at line 265 of file input_text_stream.hpp.

◆ operator>>() [6/14]

template<typename Device >
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.

Parameters
i: input value to be filled.
Exceptions
ecl::StandardException: throws if the underlying device has not been opened [debug mode only].
Returns
InputTextStream : returns the stream for further manipulation.

Definition at line 283 of file input_text_stream.hpp.

◆ operator>>() [7/14]

template<typename Device >
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.

Parameters
i: input value to be filled.
Exceptions
ecl::StandardException: throws if the underlying device has not been opened [debug mode only].
Returns
InputTextStream : returns the stream for further manipulation.

Definition at line 300 of file input_text_stream.hpp.

◆ operator>>() [8/14]

template<typename Device >
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.

Parameters
i: input value to be filled.
Exceptions
ecl::StandardException: throws if the underlying device has not been opened [debug mode only].
Returns
InputTextStream : returns the stream for further manipulation.

Definition at line 245 of file input_text_stream.hpp.

◆ operator>>() [9/14]

template<typename Device >
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.

Parameters
s: input being read from the stream.
Exceptions
ecl::StandardException: throws if the underlying device has not been opened [debug mode only].
Returns
InputTextStream : returns the stream for further manipulation.

Definition at line 210 of file input_text_stream.hpp.

◆ operator>>() [10/14]

template<typename Device >
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.

Parameters
uc: input value to be filled.
Exceptions
ecl::StandardException: throws if the underlying device has not been opened [debug mode only].
Returns
InputTextStream : returns the stream for further manipulation.

Definition at line 319 of file input_text_stream.hpp.

◆ operator>>() [11/14]

template<typename Device >
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.

Parameters
i: input value to be filled.
Exceptions
ecl::StandardException: throws if the underlying device has not been opened [debug mode only].
Returns
InputTextStream : returns the stream for further manipulation.

Definition at line 355 of file input_text_stream.hpp.

◆ operator>>() [12/14]

template<typename Device >
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.

Parameters
i: input value to be filled.
Exceptions
ecl::StandardException: throws if the underlying device has not been opened [debug mode only].
Returns
InputTextStream : returns the stream for further manipulation.

Definition at line 373 of file input_text_stream.hpp.

◆ operator>>() [13/14]

template<typename Device >
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.

Parameters
i: input value to be filled.
Exceptions
ecl::StandardException: throws if the underlying device has not been opened [debug mode only].
Returns
InputTextStream : returns the stream for further manipulation.

Definition at line 391 of file input_text_stream.hpp.

◆ operator>>() [14/14]

template<typename Device >
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.

Parameters
i: input value to be filled.
Exceptions
ecl::StandardException: throws if the underlying device has not been opened [debug mode only].
Returns
InputTextStream : returns the stream for further manipulation.

Definition at line 337 of file input_text_stream.hpp.

◆ parseHexInteger()

template<typename Device >
template<typename Number >
bool ecl::interfaces::InputTextStream< Device, true >::parseHexInteger ( Number &  i)
private

Parses a hex number from a stream into an integral type.

Parameters
i: the integer to stream the value to.

Definition at line 532 of file input_text_stream.hpp.

◆ skipLeadingWhiteSpace()

template<typename Device >
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.

Parameters
c: if successful, the first legitimate character is returned here.
Returns
bool : true if successful, false otherwise.

Definition at line 515 of file input_text_stream.hpp.

Member Data Documentation

◆ raw_char_reads

template<typename Device >
bool ecl::interfaces::InputTextStream< Device, true >::raw_char_reads
private

Definition at line 132 of file input_text_stream.hpp.


The documentation for this class was generated from the following file:


ecl_streams
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:48