A position inside a fixed range [start, end)
of UTF code points.
More...
#include <StringIterator.h>
Public Types | |
using | CodeUnit = char |
using | CodePoint = StringCodePoint |
Public Member Functions | |
constexpr void | setToStart () |
Rewind current position to start of iterator range. | |
constexpr void | setToEnd () |
Set current position to end of iterator range. | |
constexpr bool | isAtEnd () const |
Check if current position is at end of iterator range. | |
constexpr bool | isAtStart () const |
Check if current position is at start of iterator range. | |
constexpr bool | advanceUntilMatches (CodePoint c) |
Advances position towards end until it matches CodePoint c or position == end | |
bool | reverseAdvanceUntilMatches (CodePoint c) |
Moves position towards start until CodePoint c is found or position == end | |
bool | advanceAfterFinding (StringIterator other) |
Advances position towards end until a matching range of character equal to other[it, end) is found. | |
bool | advanceBeforeFinding (StringIterator other) |
Advances position towards end until a matching range of character equal to other[it, end) is found. | |
bool | advanceByLengthOf (StringIterator other) |
Advances position by the same number of code points as other. | |
bool | advanceUntilMatchesAny (Span< const CodePoint > items, CodePoint &matched) |
Advances position until any CodePoint in the given Span is found. | |
bool | reverseAdvanceUntilMatchesAny (Span< const CodePoint > items, CodePoint &matched) |
Moves position towards start until any CodePoint in the given Span is found. | |
bool | advanceUntilDifferentFrom (CodePoint c, CodePoint *optionalReadChar=nullptr) |
Advances position until a code point different from c is found or end is reached. | |
constexpr bool | advanceIfMatches (CodePoint c) |
Advance position only if next code point matches c . | |
bool | advanceBackwardIfMatches (CodePoint c) |
Move position by one code point towards start if previous code point matches c | |
bool | advanceIfMatchesAny (Span< const CodePoint > items) |
Advance position only if any of the code points in given Span is matched. | |
bool | advanceIfMatchesRange (CodePoint first, CodePoint last) |
Advance position if any code point in the range [first, last] is matched. | |
bool | match (CodePoint c) |
Check if code unit at current position matches CodePoint c | |
constexpr bool | advanceRead (CodePoint &c) |
Decode code unit at current position and advance. | |
bool | read (CodePoint &c) |
Read code unit at current position. | |
bool | advanceBackwardRead (CodePoint &c) |
Move to previous position and read code unit. | |
constexpr bool | stepForward () |
Move position to next code point. | |
constexpr bool | stepBackward () |
Move position to previous code point. | |
constexpr bool | advanceCodePoints (size_t numCodePoints) |
Move position forward (towards end ) by variable number of code points. | |
bool | reverseAdvanceCodePoints (size_t numCodePoints) |
Move position backwards (towards start ) by variable number of code pints. | |
constexpr bool | isFollowedBy (CodePoint c) |
Check if next code point is c | |
constexpr bool | isPrecededBy (CodePoint c) |
Check if previous code point is c | |
constexpr StringIterator | sliceFromStartUntil (StringIterator otherPoint) const |
Returns another StringIterator range, starting from start to otherPoint position. | |
constexpr ssize_t | bytesDistanceFrom (StringIterator other) const |
Get distance in bytes from current position to another StringIterator current position. | |
bool | endsWithAnyOf (Span< const CodePoint > codePoints) const |
Check if this Iterator ends with any code point in the given span. | |
bool | startsWithAnyOf (Span< const CodePoint > codePoints) const |
Check if this Iterator starts with any code point in the given span. | |
template<typename IteratorType > | |
bool | endsWith (IteratorType other) const |
Check if this Iterator at its end matches entirely another Iterator's range. | |
template<typename IteratorType > | |
bool | startsWith (IteratorType other) const |
Check if this Iterator at its start matches entirely another Iterator's range. | |
Static Public Member Functions | |
static constexpr StringEncoding | getEncoding () |
Protected Member Functions | |
bool | advanceOfBytes (ssize_t bytesLength) |
constexpr | StringIterator (const CodeUnit *it, const CodeUnit *end) |
Static Protected Member Functions | |
static constexpr const CodeUnit * | getNextOf (const CodeUnit *src) |
static constexpr const CodeUnit * | getPreviousOf (const CodeUnit *src) |
Protected Attributes | |
const CodeUnit * | it |
const CodeUnit * | start |
const CodeUnit * | end |
Friends | |
struct | StringView |
A position inside a fixed range [start, end)
of UTF code points.
It's a range of bytes (start and end pointers) with a current pointer pointing at a specific code point of the range. There are three classes derived from it (SC::StringIteratorASCII, SC::StringIteratorUTF8 and SC::StringIteratorUTF16) and they allow doing operations along the string view in UTF code points.
CharIterator | StringIteratorASCII, StringIteratorUTF8 or StringIteratorUTF16 |
|
nodiscard |
Advances position towards end
until a matching range of character equal to other[it, end)
is found.
Position pointer is advanced additional after the matching range.
other | The range of character to be found [it, end) |
true
if other was found, false
if end was reached
|
nodiscard |
Move position by one code point towards start if previous code point matches c
c | The CodePoint being searched |
true
if next code point matches c
, false
otherwise or if position is already at end
|
nodiscard |
Move to previous position and read code unit.
c | output code point read |
true
if position is at start
before decoding code unit
|
nodiscard |
Advances position towards end
until a matching range of character equal to other[it, end)
is found.
Position pointer is stopped before the first matching character of the range.
other | The range of character to be found [it, end) |
true
if other was found, false
if end was reached
|
inlinenodiscard |
Advances position by the same number of code points as other.
other | The other range of character |
true
if advance succeeded, false
if end
was reached
|
nodiscardconstexpr |
Move position forward (towards end
) by variable number of code points.
numCodePoints | number of code points to move forward |
true
if it's possible advancing numCodePoints
before reaching end
|
nodiscardconstexpr |
Advance position only if next code point matches c
.
c | The CodePoint being searched |
true
if next code point matches c
, false
otherwise or if position is already at end
|
nodiscard |
|
nodiscard |
Advance position if any code point in the range [first, last] is matched.
first | The initial CodePoint defining the range to be checked |
last | The final CodePoint defining the range to be checked |
true
if a code point in the given range was matched
|
nodiscardconstexpr |
Decode code unit at current position and advance.
c | output code point read |
true
if position is at end
before decoding code unit
|
nodiscard |
Advances position until a code point different from c
is found or end
is reached.
c | The CodePoint to be compared |
optionalReadChar | The CodePoint that was found, different from c |
true
if it finds at least one code point different from c, false
if iterator ends before finding it
|
nodiscardconstexpr |
Advances position towards end
until it matches CodePoint c
or position == end
c | The CodePoint to be searched |
true
if c was found, false
if end was reached
|
nodiscard |
|
nodiscardconstexpr |
Get distance in bytes from current position to another StringIterator current position.
other | The StringIterator from which to compute distance |
|
nodiscard |
Check if this Iterator at its end matches entirely another Iterator's range.
other | The other iterator to match |
true
if this Iterator matches entire other
Iterator at its end
|
nodiscard |
Check if this Iterator ends with any code point in the given span.
codePoints | A span of code points to check for |
true
if at least one code point of codepoints
exists at the end of the range
|
inlinenodiscardconstexpr |
Check if current position is at end of iterator range.
true
if position is at end of iterator range
|
inlinenodiscardconstexpr |
Check if current position is at start of iterator range.
true
if position is at start of iterator range
|
nodiscardconstexpr |
Check if next code point is c
c | the code point |
true
if next code point is c
|
nodiscardconstexpr |
Check if previous code point is c
c | the code point |
true
if previous code point is c
|
inlinenodiscard |
Check if code unit at current position matches CodePoint c
c | code point to match |
true
if code unit at current position matches c
, false
if there is no match or position is at end
|
nodiscard |
Read code unit at current position.
c | output code point read |
true
if position is at end
before decoding code unit
|
nodiscard |
Move position backwards (towards start
) by variable number of code pints.
numCodePoints | number of code points to move backwards |
true
if it's possible moving numCodePoints
backwards before reaching start
|
nodiscard |
Moves position towards start until CodePoint c
is found or position == end
c | The CodePoint to be searched |
true
if c
was found, false
if start
was reached
|
nodiscard |
|
inlineconstexpr |
Set current position to end of iterator range.
|
inlineconstexpr |
Rewind current position to start of iterator range.
|
nodiscardconstexpr |
Returns another StringIterator range, starting from start
to otherPoint
position.
otherPoint | The StringIterator containing the ending position to slice to |
[start, otherPoint.position]
|
nodiscard |
Check if this Iterator at its start matches entirely another Iterator's range.
other | The other iterator to match |
true
if this Iterator matches entire other
at its start
|
nodiscard |
Check if this Iterator starts with any code point in the given span.
codePoints | A span of code points to check for |
true
if at least one code point of codepoints
exists at the start of the range
|
nodiscardconstexpr |
Move position to previous code point.
true
if position is not at start
before trying to move backwards
|
nodiscardconstexpr |
Move position to next code point.
true
if position is not at end
before trying to move forward