ChrSplitIterator

Splits a string by occurrences of a delimiter character

Constructors

this
this(char delim_)

Constructor

this
this(char delim_, cstring content)

Constructor

Members

Functions

locateDelim
size_t locateDelim(cstring str, size_t start)

Locates the first occurrence of delim in str starting with strstart.

skipDelim
size_t skipDelim(cstring str)

Skips the delimiter which str starts with. Note that the result is correct only if str really starts with a delimiter.

Variables

delim
char delim;

Delimiter character. Must be specified in the constructor but may be changed at any time, even during iteration.

Inherited Members

From ISplitIterator

collapse
bool collapse;

Set to true to collapse consecutive delimiter occurrences to a single one to prevent producing empty segments.

include_remaining
bool include_remaining;

Set to true to do a 'foreach' cycle with the remaining content after the last delimiter occurrence or when no delimiter is found.

IterationDelegate
union IterationDelegate

Union of the supported 'foreach' iteration delegate types

reset
typeof(this) reset(cstring content)

Sets the content string to split on next iteration.

opApply
int opApply(int delegate(ref cstring segment) dg_in)

'foreach' iteration over string slices between the current and the next delimiter. n() returns the number of 'foreach' loop cycles so far, remaining() the slice after the next delimiter to the content end. If no delimiter was found, n() is 0 after 'foreach' has finished and remaining() returns the content.

opApply
int opApply(int delegate(ref size_t pos, ref cstring segment) dg_in)

'foreach' iteration over string slices between the current and the next delimiter. n() returns the number of 'foreach' loop cycles so far, remaining() the slice after the next delimiter to the content end. If no delimiter was found, n() is 0 after 'foreach' has finished and remaining() returns the content.

n
uint n()
remaining
cstring remaining()
locateDelim
size_t locateDelim(cstring str, size_t start)

Locates the first delimiter occurrence in str starting from strstart.

locateDelim
size_t locateDelim(size_t start)

Locates the first delimiter occurrence in the current content string starting from contentstart.

skipLeadingDelims
cstring skipLeadingDelims()

Skips initial consecutive occurrences of the current delimiter in the currently remaining content.

next
cstring next()

Searches the next delimiter.

opApply_
int opApply_(bool with_pos, IterationDelegate dg)

'foreach' iteration over string slices between the current and the next delimiter.

skipDelim
size_t skipDelim(cstring str)

Skips the delimiter which str starts with. The return value is at most str.length. It is assured that str starts with a delimiter so a subclass may return an undefined result otherwise. Additionally, a subclass is encouraged to use an 'in' contract to ensure str starts with a delimiter and/or is long enought to skip a leading delimiter.

trim
cstring trim(cstring str)

Trims white space from str.

Meta