|
| constructor (string string, *string eol, bool trim=True) |
| creates the DataLineIterator based on the string given More...
|
|
| copy () |
| Creates a new DataLineIterator object, based on the same object being iterated in the original object. More...
|
|
string | getEncoding () |
| Returns the character encoding for the DataLineIterator. More...
|
|
string | getLine () |
| returns the current line in the data or throws an INVALID-ITERATOR exception if the iterator is invalid More...
|
|
int | getPos () |
| Returns the current data position as an integer giving the offset in bytes from the beginning of the data (starting from zero) More...
|
|
string | getValue () |
| returns the current line in the data or throws an INVALID-ITERATOR 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...
|
|
| reset () |
| Reset the iterator instance to its initial state. More...
|
|
bool | valid () |
| returns True if the iterator is currently pointing at a valid element, False if not More...
|
|
This class defines a line iterator for string data.
- Since
- Qore 0.8.12
- Example: DataLineIterator basic usage
my string $str = "a2ps-4.13-1332.1.x86_64
a2ps-devel-4.13-1332.1.x86_64
aaa_base-11.3-7.2.x86_64";
my DataLineIterator $it($str);
while ($it.next()) {
printf(
"line %d = %n\n", $it.index(), $it.getValue());
}
line 1 = "a2ps-4.13-1332.1.x86_64"
line 2 = "a2ps-devel-4.13-1332.1.x86_64"
line 3 = "aaa_base-11.3-7.2.x86_64"
- See also
- Qore::FileLineIterator
bool Qore::DataLineIterator::next |
( |
| ) |
|
|
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.
This method will return True again after it returns False once if data is not empty, otherwise it will always return False The iterator object should not be used after this method returns False
- Returns
- False if there are no more lines in the data (in which case the iterator object is invalid and should not be used); True if successful (meaning that the iterator object is valid)
- Example:
while ($i.next()) {
printf(
"line: %y\n", $i.getValue());
}
- Exceptions
-
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::AbstractIterator.