Qore Programming Language Reference Manual
1.7.0
|
This class defines a line iterator for input streams. More...
Public Member Methods | |
constructor (Qore::InputStream is, *string encoding, *string eol, bool trim=True, int bufsize=DefaultStreamBufferSize) | |
Creates a buffered InputStreamLineIterator object for iterating over the given InputStream . More... | |
constructor (Qore::StreamReader sr, *string eol, bool trim=True) | |
Creates the InputStreamLineIterator for iterating data from the given StreamReader . More... | |
string | getEncoding () |
Returns the character encoding for the InputStreamLineIterator. More... | |
string | getLine () |
Returns the current line in the data or throws an ITERATOR-ERROR exception if the iterator is invalid. More... | |
StreamReader | getStreamReader () |
Returns the StreamReader object used internally. More... | |
string | getValue () |
Returns the current line in the data or throws an ITERATOR-ERROR exception if the iterator is invalid. More... | |
int | index () |
Returns the current iterator line number in the data (the first line is line 1) or 0 if not pointing at a valid element. More... | |
bool | next () |
Moves the current position to the next line in the data; returns False if there are no more lines to read; if the iterator is not pointing at a valid element before this call, the iterator will be positioned to the beginning of the data. More... | |
bool | valid () |
Returns True if the iterator is currently pointing at a valid element, False if not. More... | |
Public Member Methods inherited from Qore::AbstractLineIterator | |
list< string > | getSplitLine (string sep, string quote, string eol="\n", bool trim_unquoted=False) |
Returns the current line and splits the string into a list of components based on a separator string and a quote character. More... | |
This class defines a line iterator for input streams.
Qore::InputStreamLineIterator::constructor | ( | Qore::InputStream | is, |
*string | encoding, | ||
*string | eol, | ||
bool | trim = True , |
||
int | bufsize = DefaultStreamBufferSize |
||
) |
Creates a buffered InputStreamLineIterator object for iterating over the given InputStream
.
is | the InputStream to iterate over |
encoding | character encoding of the data from input stream; if not ASCII-compatible, all data will be converted to UTF-8; if not present, the default character encoding is assumed |
eol | the optional end of line character(s) to use to detect lines in the data; if this string is not passed, then if the character-encoding is ASCII-compatible, the end of line character(s) are detected automatically from "\n" , "\r" , or "\r\n" ; if the stream uses a non-ASCII-compatible character encoding, then "\n" is assumed |
trim | if True the string return values for the lines iterated will be trimmed of the eol bytes |
bufsize | the size of the buffer for the internal BufferedStreamReader in bytes; must be a positive integer |
STREAM-BUFFER-ERROR | an invalid stream buffer size was specified; the buffer size must be a positive integer |
ENCODING-CONVERSION-ERROR | this exception could be thrown if the eol argument has a different character encoding from the data's and an error occurs during encoding conversion |
Qore::InputStreamLineIterator::constructor | ( | Qore::StreamReader | sr, |
*string | eol, | ||
bool | trim = True |
||
) |
Creates the InputStreamLineIterator for iterating data from the given StreamReader
.
sr | the StreamReader used as a source of data to iterate over |
eol | the optional end of line character(s) to use to detect lines in the data; if this string is not passed, then if the character-encoding is ASCII-compatible, the end of line character(s) are detected automatically from "\n" , "\r" , or "\r\n" ; if the stream uses a non-ASCII-compatible character encoding, then "\n" is assumed |
trim | if True the string return values for the lines iterated will be trimmed of the eol bytes |
ENCODING-CONVERSION-ERROR | this exception could be thrown if the eol argument has a different character encoding from the data's and an error occurs during encoding conversion |
string Qore::InputStreamLineIterator::getEncoding | ( | ) |
Returns the character encoding for the InputStreamLineIterator.
|
virtual |
Returns the current line in the data or throws an ITERATOR-ERROR
exception if the iterator is invalid.
ITERATOR-ERROR
exception if the iterator is invalidITERATOR-ERROR | the iterator is not pointing at a valid element |
ITERATOR-THREAD-ERROR | this exception is thrown if this method is called from any thread other than the thread that created the object |
Implements Qore::AbstractLineIterator.
StreamReader Qore::InputStreamLineIterator::getStreamReader | ( | ) |
Returns the StreamReader object used internally.
|
virtual |
Returns the current line in the data or throws an ITERATOR-ERROR
exception if the iterator is invalid.
ITERATOR-ERROR
exception if the iterator is invalidITERATOR-ERROR | the iterator is not pointing at a valid element |
ITERATOR-THREAD-ERROR | this exception is thrown if this method is called from any thread other than the thread that created the object |
Implements Qore::AbstractLineIterator.
|
virtual |
Returns the current iterator line number in the data (the first line is line 1) or 0 if not pointing at a valid element.
Implements Qore::AbstractLineIterator.
|
virtual |
Moves the current position to the next line in the data; returns False if there are no more lines to read; if the iterator is not pointing at a valid element before this call, the iterator will be positioned to the beginning of the data.
The iterator object should not be used after this method returns False.
ITERATOR-THREAD-ERROR | this exception is thrown if this method is called from any thread other than the thread that created the object |
Implements Qore::AbstractLineIterator.
|
virtual |