NAME
Clownfish::StringIterator - Iterate Unicode code points in a String.
SYNOPSIS
my $iter = $string->top;
while (my $code_point = $iter->next) {
...
}
DESCRIPTION
METHODS
clone
$string_iterator->clone();
Return a clone of the object.
assign
$string_iterator->assign($other);
Assign the source string and current position of other
to self
.
compare_to
$string_iterator->compare_to($other);
Indicate whether one StringIterator is less than, equal to, or greater than another by comparing their character positions. Throws an exception if other
is not a StringIterator pointing to the same source string as self
.
Returns: 0 if the StringIterators are equal, a negative number if self
is less than other
, and a positive number if self
is greater than other
.
has_next
$string_iterator->has_next();
Return true if the iterator is not at the end of the string.
has_prev
$string_iterator->has_prev();
Return true if the iterator is not at the start of the string.
next
my $code_point = $iter->next;
Return the code point after the current position and advance the iterator. Returns undef at the end of the string. Returns zero but true for U+0000.
prev
my $code_point = $iter->prev;
Return the code point before the current position and go one step back. Returns undef at the start of the string. Returns zero but true for U+0000.
advance
$string_iterator->advance($num);
Skip code points.
num - The number of code points to skip.
Returns: the number of code points actually skipped. This can be less than the requested number if the end of the string is reached.
recede
$string_iterator->recede($num);
Skip code points backward.
num - The number of code points to skip.
Returns: the number of code points actually skipped. This can be less than the requested number if the start of the string is reached.
skip_whitespace
$string_iterator->skip_whitespace();
Skip whitespace. Whitespace is any character that has the Unicode property White_Space
.
Returns: the number of code points skipped.
skip_whitespace_back
$string_iterator->skip_whitespace_back();
Skip whitespace backward. Whitespace is any character that has the Unicode property White_Space
.
Returns: the number of code points skipped.
starts_with
$string_iterator->starts_with($prefix);
Test whether the content after the iterator starts with prefix
.
ends_with
$string_iterator->ends_with($suffix);
Test whether the content before the iterator ends with suffix
.
INHERITANCE
Clownfish::StringIterator isa Clownfish::Obj.