Initial release: January 2006
Kris
- class Lines(T) : Iterator!(T) ¶
-
Iterate across a set of text patterns.
Each pattern is exposed to the client as a slice of the original
content, where the slice is transient. If you need to retain the
exposed content, then you should .dup it appropriately.
The content exposed via an iterator is supposed to be entirely
read-only. All current iterators abide by this rule, but it is
possible a user could mutate the content through a get() slice.
To enforce the desired read-only aspect, the code would have to
introduce redundant copying or the compiler would have to support
read-only arrays.
See Delimiters, Patterns, Quotes.
- this(InputStream stream = null) ¶
-
Construct an uninitialized iterator. For example:
1
2
3
4
5
6
7
|
auto lines = new Lines!(char);
void somefunc (InputStream stream)
{
foreach (line; lines.set(stream))
Cout (line).newline;
}
|
Construct a streaming iterator upon a stream:
1
2
3
4
5
|
void somefunc (InputStream stream)
{
foreach (line; new Lines!(char) (stream))
Cout (line).newline;
}
|
Construct a streaming iterator upon a conduit:
1
2
|
foreach (line; new Lines!(char) (new File ("myfile")))
Cout (line).newline;
|
- bool readln(ref const(T)[] content) [final] ¶
-
Read a line of text, and return false when there's no
further content available.
- size_t scan(const(void)[] data) [protected, override] ¶
-
Scanner implementation for this iterator. Find a '\n',
and eat any immediately preceeding '\r'.