ICU 78.3  78.3
Data Structures | Public Types | Public Member Functions | Friends
U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename > Class Template Reference

Validating iterator over the code points in a Unicode string. More...

#include <utfiterator.h>

Public Types

using value_type = CodeUnits< CP32, UnitIter >
 C++ iterator boilerplate. More...
 
using reference = value_type
 C++ iterator boilerplate. More...
 
using pointer = Proxy
 C++ iterator boilerplate. More...
 
using difference_type = prv::iter_difference_t< UnitIter >
 C++ iterator boilerplate. More...
 
using iterator_category = std::conditional_t< prv::bidirectional_iterator< UnitIter >, std::bidirectional_iterator_tag, std::forward_iterator_tag >
 C++ iterator boilerplate. More...
 

Public Member Functions

U_FORCE_INLINE UTFIterator (UnitIter start, UnitIter p, LimitIter limit)
 Constructor with start <= p < limit. More...
 
U_FORCE_INLINE UTFIterator (UnitIter p, LimitIter limit)
 Constructor with start == p < limit. More...
 
U_FORCE_INLINE UTFIterator (UnitIter p)
 Constructs an iterator start or limit sentinel. More...
 
U_FORCE_INLINE UTFIterator ()
 Default constructor. More...
 
U_FORCE_INLINE UTFIterator (UTFIterator &&src) noexcept=default
 Move constructor. More...
 
U_FORCE_INLINE UTFIteratoroperator= (UTFIterator &&src) noexcept=default
 Move assignment operator. More...
 
U_FORCE_INLINE UTFIterator (const UTFIterator &other)=default
 Copy constructor. More...
 
U_FORCE_INLINE UTFIteratoroperator= (const UTFIterator &other)=default
 Copy assignment operator. More...
 
U_FORCE_INLINE bool operator== (const UTFIterator &other) const
 
U_FORCE_INLINE bool operator!= (const UTFIterator &other) const
 
U_FORCE_INLINE CodeUnits< CP32, UnitIter > operator* () const
 Decodes the code unit sequence at the current position. More...
 
U_FORCE_INLINE Proxy operator-> () const
 Decodes the code unit sequence at the current position. More...
 
U_FORCE_INLINE UTFIteratoroperator++ ()
 Pre-increment operator. More...
 
U_FORCE_INLINE UTFIterator operator++ (int)
 Post-increment operator. More...
 
template<typename Iter = UnitIter>
U_FORCE_INLINE std::enable_if_t< prv::bidirectional_iterator< Iter >, UTFIterator & > operator-- ()
 Pre-decrement operator. More...
 
template<typename Iter = UnitIter>
U_FORCE_INLINE std::enable_if_t< prv::bidirectional_iterator< Iter >, UTFIteratoroperator-- (int)
 Post-decrement operator. More...
 

Friends

class std::reverse_iterator< UTFIterator< CP32, behavior, UnitIter > >
 
template<typename Sentinel >
U_FORCE_INLINE friend std::enable_if_t< !std::is_same_v< Sentinel, UTFIterator > &&!std::is_same_v< Sentinel, UnitIter >, bool > operator== (const UTFIterator &iter, const Sentinel &s)
 
template<typename Sentinel >
U_FORCE_INLINE friend std::enable_if_t< !std::is_same_v< Sentinel, UTFIterator > &&!std::is_same_v< Sentinel, UnitIter >, bool > operator== (const Sentinel &s, const UTFIterator &iter)
 
template<typename Sentinel >
U_FORCE_INLINE friend std::enable_if_t< !std::is_same_v< Sentinel, UTFIterator > &&!std::is_same_v< Sentinel, UnitIter >, bool > operator!= (const UTFIterator &iter, const Sentinel &s)
 
template<typename Sentinel >
U_FORCE_INLINE friend std::enable_if_t< !std::is_same_v< Sentinel, UTFIterator > &&!std::is_same_v< Sentinel, UnitIter >, bool > operator!= (const Sentinel &s, const UTFIterator &iter)
 

Detailed Description

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
class U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >

Validating iterator over the code points in a Unicode string.

The UnitIter can be an input_iterator, a forward_iterator, or a bidirectional_iterator (including a pointer). The UTFIterator will have the corresponding iterator_category.

Call utfIterator() to have the compiler deduce the UnitIter and LimitIter types.

For reverse iteration, either use this iterator directly as in *–iter or wrap it using std::make_reverse_iterator(iter).

Template Parameters
CP32Code point type: UChar32 (=int32_t) or char32_t or uint32_t; should be signed if UTF_BEHAVIOR_NEGATIVE
behaviorHow to handle ill-formed Unicode strings
UnitIterAn iterator (often a pointer) that returns a code unit type: UTF-8: char or char8_t or uint8_t; UTF-16: char16_t or uint16_t or (on Windows) wchar_t; UTF-32: char32_t or UChar32=int32_t or (on Linux) wchar_t
LimitIterEither the same as UnitIter, or an iterator sentinel type.
Draft:
This API may be changed in the future versions and was introduced in ICU 78
See also
utfIterator

Definition at line 1102 of file utfiterator.h.

Member Typedef Documentation

◆ difference_type

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
using U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::difference_type = prv::iter_difference_t<UnitIter>

C++ iterator boilerplate.

Internal:
Do not use.

This API is for internal use only.

Definition at line 1125 of file utfiterator.h.

◆ iterator_category

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
using U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::iterator_category = std::conditional_t< prv::bidirectional_iterator<UnitIter>, std::bidirectional_iterator_tag, std::forward_iterator_tag>

C++ iterator boilerplate.

Internal:
Do not use.

This API is for internal use only.

Definition at line 1130 of file utfiterator.h.

◆ pointer

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
using U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::pointer = Proxy

C++ iterator boilerplate.

Internal:
Do not use.

This API is for internal use only.

Definition at line 1123 of file utfiterator.h.

◆ reference

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
using U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::reference = value_type

C++ iterator boilerplate.

Internal:
Do not use.

This API is for internal use only.

Definition at line 1121 of file utfiterator.h.

◆ value_type

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
using U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::value_type = CodeUnits<CP32, UnitIter>

C++ iterator boilerplate.

Internal:
Do not use.

This API is for internal use only.

Definition at line 1119 of file utfiterator.h.

Constructor & Destructor Documentation

◆ UTFIterator() [1/6]

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
U_FORCE_INLINE U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::UTFIterator ( UnitIter  start,
UnitIter  p,
LimitIter  limit 
)
inline

Constructor with start <= p < limit.

All of these iterators/pointers should be at code point boundaries. Only enabled if UnitIter is a (multi-pass) forward_iterator or better.

When using a code unit sentinel (UnitIter≠LimitIter), then that sentinel also works as a sentinel for this code point iterator.

Parameters
startStart of the range
pInitial position inside the range
limitLimit (exclusive end) of the range
Draft:
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 1145 of file utfiterator.h.

◆ UTFIterator() [2/6]

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
U_FORCE_INLINE U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::UTFIterator ( UnitIter  p,
LimitIter  limit 
)
inline

Constructor with start == p < limit.

All of these iterators/pointers should be at code point boundaries.

When using a code unit sentinel (UnitIter≠LimitIter), then that sentinel also works as a sentinel for this code point iterator.

Parameters
pStart of the range, and the initial position
limitLimit (exclusive end) of the range
Draft:
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 1158 of file utfiterator.h.

◆ UTFIterator() [3/6]

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
U_FORCE_INLINE U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::UTFIterator ( UnitIter  p)
inlineexplicit

Constructs an iterator start or limit sentinel.

The iterator/pointer should be at a code point boundary. Requires UnitIter to be copyable.

When using a code unit sentinel (UnitIter≠LimitIter), then that sentinel also works as a sentinel for this code point iterator.

Parameters
pRange start or limit
Draft:
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 1171 of file utfiterator.h.

◆ UTFIterator() [4/6]

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
U_FORCE_INLINE U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::UTFIterator ( )
inline

Default constructor.

Makes a non-functional iterator.

Draft:
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 1177 of file utfiterator.h.

◆ UTFIterator() [5/6]

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
U_FORCE_INLINE U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::UTFIterator ( UTFIterator< CP32, behavior, UnitIter, LimitIter, typename > &&  src)
defaultnoexcept

Move constructor.

Draft:
This API may be changed in the future versions and was introduced in ICU 78

◆ UTFIterator() [6/6]

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
U_FORCE_INLINE U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::UTFIterator ( const UTFIterator< CP32, behavior, UnitIter, LimitIter, typename > &  other)
default

Copy constructor.

Draft:
This API may be changed in the future versions and was introduced in ICU 78

Member Function Documentation

◆ operator!=()

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
U_FORCE_INLINE bool U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::operator!= ( const UTFIterator< CP32, behavior, UnitIter, LimitIter, typename > &  other) const
inline
Parameters
otherAnother iterator
Returns
true if this iterator is not at the same position as the other one
Draft:
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 1202 of file utfiterator.h.

References U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::operator==().

◆ operator*()

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
U_FORCE_INLINE CodeUnits<CP32, UnitIter> U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::operator* ( ) const
inline

Decodes the code unit sequence at the current position.

Returns
CodeUnits with the decoded code point etc.
Draft:
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 1268 of file utfiterator.h.

◆ operator++() [1/2]

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
U_FORCE_INLINE UTFIterator& U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::operator++ ( )
inline

Pre-increment operator.

Returns
this iterator
Draft:
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 1300 of file utfiterator.h.

References U_HEADER_ONLY_NAMESPACE::UnsafeCodeUnits< CP32, UnitIter, typename >::end().

◆ operator++() [2/2]

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
U_FORCE_INLINE UTFIterator U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::operator++ ( int  )
inline

Post-increment operator.

Returns
a copy of this iterator from before the increment. If UnitIter is a single-pass input_iterator, then this function returns an opaque proxy object so that *iter++ still works.
Draft:
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 1322 of file utfiterator.h.

References U_HEADER_ONLY_NAMESPACE::UnsafeCodeUnits< CP32, UnitIter, typename >::end().

◆ operator--() [1/2]

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
template<typename Iter = UnitIter>
U_FORCE_INLINE std::enable_if_t<prv::bidirectional_iterator<Iter>, UTFIterator &> U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::operator-- ( )
inline

Pre-decrement operator.

Only enabled if UnitIter is a bidirectional_iterator (including a pointer).

Returns
this iterator
Draft:
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 1354 of file utfiterator.h.

References U_HEADER_ONLY_NAMESPACE::UnsafeCodeUnits< CP32, UnitIter, typename >::begin().

Referenced by U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::operator--().

◆ operator--() [2/2]

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
template<typename Iter = UnitIter>
U_FORCE_INLINE std::enable_if_t<prv::bidirectional_iterator<Iter>, UTFIterator> U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::operator-- ( int  )
inline

Post-decrement operator.

Only enabled if UnitIter is a bidirectional_iterator (including a pointer).

Returns
a copy of this iterator from before the decrement.
Draft:
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 1374 of file utfiterator.h.

References U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::operator--().

◆ operator->()

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
U_FORCE_INLINE Proxy U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::operator-> ( ) const
inline

Decodes the code unit sequence at the current position.

Used like iter->codePoint() or iter->stringView() etc.

Returns
CodeUnits with the decoded code point etc., wrapped into an opaque proxy object so that iter->codePoint() etc. works.
Draft:
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 1285 of file utfiterator.h.

◆ operator=() [1/2]

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
U_FORCE_INLINE UTFIterator& U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::operator= ( UTFIterator< CP32, behavior, UnitIter, LimitIter, typename > &&  src)
defaultnoexcept

Move assignment operator.

Draft:
This API may be changed in the future versions and was introduced in ICU 78

◆ operator=() [2/2]

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
U_FORCE_INLINE UTFIterator& U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::operator= ( const UTFIterator< CP32, behavior, UnitIter, LimitIter, typename > &  other)
default

Copy assignment operator.

Draft:
This API may be changed in the future versions and was introduced in ICU 78

◆ operator==()

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
U_FORCE_INLINE bool U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::operator== ( const UTFIterator< CP32, behavior, UnitIter, LimitIter, typename > &  other) const
inline
Parameters
otherAnother iterator
Returns
true if this iterator is at the same position as the other one
Draft:
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 1194 of file utfiterator.h.

Referenced by U_HEADER_ONLY_NAMESPACE::UTFIterator< CP32, behavior, UnitIter, LimitIter, typename >::operator!=().

Friends And Related Function Documentation

◆ operator!= [1/2]

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
template<typename Sentinel >
U_FORCE_INLINE friend std::enable_if_t< !std::is_same_v<Sentinel, UTFIterator> && !std::is_same_v<Sentinel, UnitIter>, bool> operator!= ( const UTFIterator< CP32, behavior, UnitIter, LimitIter, typename > &  iter,
const Sentinel &  s 
)
friend
Parameters
iterA UTFIterator
sA unit iterator sentinel
Returns
true if the iterator’s position is not equal to the sentinel
Internal:
Do not use. This API is for internal use only.

Definition at line 1248 of file utfiterator.h.

◆ operator!= [2/2]

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
template<typename Sentinel >
U_FORCE_INLINE friend std::enable_if_t< !std::is_same_v<Sentinel, UTFIterator> && !std::is_same_v<Sentinel, UnitIter>, bool> operator!= ( const Sentinel &  s,
const UTFIterator< CP32, behavior, UnitIter, LimitIter, typename > &  iter 
)
friend
Parameters
sA unit iterator sentinel
iterA UTFIterator
Returns
true if the iterator’s position is not equal to the sentinel
Internal:
Do not use. This API is for internal use only.

Definition at line 1259 of file utfiterator.h.

◆ operator== [1/2]

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
template<typename Sentinel >
U_FORCE_INLINE friend std::enable_if_t< !std::is_same_v<Sentinel, UTFIterator> && !std::is_same_v<Sentinel, UnitIter>, bool> operator== ( const UTFIterator< CP32, behavior, UnitIter, LimitIter, typename > &  iter,
const Sentinel &  s 
)
friend
Parameters
iterA UTFIterator
sA unit iterator sentinel
Returns
true if the iterator’s position is equal to the sentinel
Draft:
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 1216 of file utfiterator.h.

◆ operator== [2/2]

template<typename CP32, UTFIllFormedBehavior behavior, typename UnitIter, typename LimitIter = UnitIter, typename = void>
template<typename Sentinel >
U_FORCE_INLINE friend std::enable_if_t< !std::is_same_v<Sentinel, UTFIterator> && !std::is_same_v<Sentinel, UnitIter>, bool> operator== ( const Sentinel &  s,
const UTFIterator< CP32, behavior, UnitIter, LimitIter, typename > &  iter 
)
friend
Parameters
sA unit iterator sentinel
iterA UTFIterator
Returns
true if the iterator’s position is equal to the sentinel
Internal:
Do not use. This API is for internal use only.

Definition at line 1235 of file utfiterator.h.


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