StrSplitIterator

Splits a string by occurrences of a delimiter string.

Memory friendly, suitable for stack-allocated scope instances.

Constructors

this
this(cstring delim_)

Constructor

this
this(cstring delim_, cstring content)

Constructor

this
this(Search sf_in)

Constructor

Members

Aliases

Search
alias Search = typeof(.search(cstring.init))
Undocumented in source.

Functions

delim
cstring delim()
delim
cstring delim(cstring delim_)

Sets the delimiter string. delim_ may or may not be NUL-terminated; however, only the last character may be NUL.

locateDelim
size_t locateDelim(cstring str, size_t start)

Locates the first occurrence of the current delimiter string in str, starting from 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

sf
Search sf;

Contains the delimiter as match string and manages a table of indices to improve the search algorithm efficiency. May be modified at any time using its methods.

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