libzed 1.9.9
A general-purpose library for quick and simple data manipulation.
 
Loading...
Searching...
No Matches
z::core::stringIterator< E > Class Template Reference

A class for iterating over each character in a string. More...

#include <stringIterator.hpp>

Public Member Functions

 stringIterator (uint8_t *ptr, size_t offset) noexcept
 Constructor.
 
stringIterator operator++ () noexcept
 Increment the current character we're pointing to.
 
bool operator!= (const stringIterator &other) const noexcept
 Equality operator.
 
const uint32_toperator* () const noexcept
 Dereference operator.
 

Detailed Description

template<encoding E>
class z::core::stringIterator< E >

A class for iterating over each character in a string.

Since some string encoding schemes (i.e. UTF-8) have multi-character sequences That represent a single "character", this iterator allows for looping over each character in strings of different encoding identically.

Constructor & Destructor Documentation

◆ stringIterator()

template<encoding E>
z::core::stringIterator< E >::stringIterator ( uint8_t ptr,
size_t  offset 
)
noexcept

Constructor.

Parameters
ptrPointer to the string data.
offsetThe current index in the string data.

Member Function Documentation

◆ operator!=()

template<encoding E>
bool z::core::stringIterator< E >::operator!= ( const stringIterator< E > &  other) const
inlinenoexcept

Equality operator.

Parameters
otherThe object to compare to.
Returns
True if this and other are pointing to the same character in the same string, false otherwise.

◆ operator*()

template<encoding E>
const uint32_t & z::core::stringIterator< E >::operator* ( ) const
inlinenoexcept

Dereference operator.

Returns
The current character this iterator is pointing to, converted to UTF 32.

◆ operator++()

template<encoding E>
stringIterator z::core::stringIterator< E >::operator++ ( )
noexcept

Increment the current character we're pointing to.

Returns
A new iterator instance, incremented from the current position.

The documentation for this class was generated from the following file: