This project has retired. For details please refer to its Attic page.
Clownfish::StringIterator – C API Documentation
Apache Lucy™

Clownfish::StringIterator

parcel Clownfish
class variable CFISH_STRINGITERATOR
struct symbol cfish_StringIterator
class nickname cfish_StrIter
header file Clownfish/String.h

Name

Clownfish::StringIterator – Iterate Unicode code points in a String.

Functions

crop
cfish_String* // incremented
cfish_StrIter_crop(
    cfish_StringIterator *top,
    cfish_StringIterator *tail
);

Return the substring between the top and tail iterators.

top

Top iterator. Use start of string if NULL.

tail

Tail iterator. Use end of string if NULL.

Methods

Clone
cfish_StringIterator* // incremented
cfish_StrIter_Clone(
    cfish_StringIterator *self
);

Return a clone of the object.

Assign
void
cfish_StrIter_Assign(
    cfish_StringIterator *self,
    cfish_StringIterator *other
);

Assign the source string and current position of other to self.

Equals
bool
cfish_StrIter_Equals(
    cfish_StringIterator *self,
    cfish_Obj *other
);

Equality test.

Returns: true if other is a StringIterator with the same source string and character position as self.

Compare_To
int32_t
cfish_StrIter_Compare_To(
    cfish_StringIterator *self,
    cfish_Obj *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
bool
cfish_StrIter_Has_Next(
    cfish_StringIterator *self
);

Return true if the iterator is not at the end of the string.

Has_Prev
bool
cfish_StrIter_Has_Prev(
    cfish_StringIterator *self
);

Return true if the iterator is not at the start of the string.

Next
int32_t
cfish_StrIter_Next(
    cfish_StringIterator *self
);

Return the code point after the current position and advance the iterator. Return CFISH_STR_OOB at the end of the string.

Prev
int32_t
cfish_StrIter_Prev(
    cfish_StringIterator *self
);

Return the code point before the current position and go one step back. Return CFISH_STR_OOB at the start of the string.

Advance
size_t
cfish_StrIter_Advance(
    cfish_StringIterator *self,
    size_t 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
size_t
cfish_StrIter_Recede(
    cfish_StringIterator *self,
    size_t 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
size_t
cfish_StrIter_Skip_Whitespace(
    cfish_StringIterator *self
);

Skip whitespace. Whitespace is any character that has the Unicode property White_Space.

Returns: the number of code points skipped.

Skip_Whitespace_Back
size_t
cfish_StrIter_Skip_Whitespace_Back(
    cfish_StringIterator *self
);

Skip whitespace backward. Whitespace is any character that has the Unicode property White_Space.

Returns: the number of code points skipped.

Starts_With
bool
cfish_StrIter_Starts_With(
    cfish_StringIterator *self,
    cfish_String *prefix
);

Test whether the content after the iterator starts with prefix.

Starts_With_Utf8
bool
cfish_StrIter_Starts_With_Utf8(
    cfish_StringIterator *self,
    char *utf8,
    size_t size
);

Test whether the content after the iterator starts with a prefix supplied as raw UTF-8.

utf8

Pointer to UTF-8 character data.

size

Size of UTF-8 character data in bytes.

Ends_With
bool
cfish_StrIter_Ends_With(
    cfish_StringIterator *self,
    cfish_String *suffix
);

Test whether the content before the iterator ends with suffix.

Ends_With_Utf8
bool
cfish_StrIter_Ends_With_Utf8(
    cfish_StringIterator *self,
    char *utf8,
    size_t size
);

Test whether the content before the iterator ends with a suffix supplied as raw UTF-8.

utf8

Pointer to UTF-8 character data.

size

Size of UTF-8 character data in bytes.

Inheritance

Clownfish::StringIterator is a Clownfish::Obj.