Lines

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.

Constructors

this
this(InputStream stream)

Construct an uninitialized iterator. For example:

Members

Functions

readln
bool readln(cstring content)

Read a line of text, and return false when there's no further content available.

scan
size_t scan(const(void)[] data)

Scanner implementation for this iterator. Find a '\n', and eat any immediately preceeding '\r'.

Inherited Members

From Iterator

slice
cstring slice;
delim
cstring delim;
Undocumented in source.
scan
size_t scan(const(void)[] data)

The pattern scanner, implemented via subclasses.

set
Iterator set(InputStream stream)

Set the provided stream as the scanning source.

get
cstring get()

Return the current token as a slice of the content.

opApply
int opApply(int delegate(ref cstring) dg)

Iterate over the set of tokens. This should really provide read-only access to the tokens, but D does not support that at this time.

opApply
int opApply(int delegate(ref int, ref cstring) dg)

Iterate over a set of tokens, exposing a token count starting at zero.

opApply
int opApply(int delegate(ref int, ref cstring, ref cstring) dg)

Iterate over a set of tokens and delimiters, exposing a token count starting at zero.

next
cstring next()

Locate the next token. Returns the token if found, null otherwise. Null indicates an end of stream condition. To sweep a conduit for lines using method next():

set
size_t set(const(char)* content, size_t start, size_t end)

Set the content of the current slice to the provided start and end points.

set
size_t set(const(char)* content, size_t start, size_t end, size_t next)

Set the content of the current slice to the provided start and end points, and delimiter to the segment between end & next (inclusive.)

notFound
size_t notFound()

Called when a scanner fails to find a matching pattern. This may cause more content to be loaded, and a rescan initiated.

found
size_t found(size_t i)

Invoked when a scanner matches a pattern. The provided value should be the index of the last element of the matching pattern, which is converted back to a void[] index.

has
bool has(cstring set, char match)

See if set of characters holds a particular instance.

Meta