ICU 78.2 78.2

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 UTFIterator & | operator= (UTFIterator &&src) noexcept=default
| Move assignment operator. More...
U_FORCE_INLINE | UTFIterator (const UTFIterator &other)=default
| Copy constructor. More...
U_FORCE_INLINE UTFIterator & | operator= (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 UTFIterator & | operator++ ()
| 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 >, UTFIterator > | operator-- (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

  CP32 | Code point type: UChar32 (=int32_t) or char32_t or uint32_t; should be signed if UTF_BEHAVIOR_NEGATIVE
  behavior | How to handle ill-formed Unicode strings
  UnitIter | An 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
  LimitIter | Either 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 1094 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 1117 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 1119 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 1115 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 1113 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 1111 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

  start | Start of the range
  p | Initial position inside the range
  limit | Limit (exclusive end) of the range

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

Definition at line 1137 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

  p | Start of the range, and the initial position
  limit | Limit (exclusive end) of the range

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

Definition at line 1150 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 | ) |
| inline explicit

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

  p | Range start or limit

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

Definition at line 1163 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 1169 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 | ) |
| default noexcept

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

  other | Another 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 1194 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 1260 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 1292 of file utfiterator.h.

## ◆ 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 1314 of file utfiterator.h.

## ◆ 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 1346 of file utfiterator.h.

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 1366 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 1277 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= | ( | 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=() [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= | ( | UTFIterator< CP32, behavior, UnitIter, LimitIter, typename > && | src | ) |
| default noexcept

Move 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

  other | Another 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 1186 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 Sentinel & | s,
|  | const UTFIterator< CP32, behavior, UnitIter, LimitIter, typename > & | iter
| ) |  |
| friend

Parameters

  s | A unit iterator sentinel
  iter | A 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 1251 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 UTFIterator< CP32, behavior, UnitIter, LimitIter, typename > & | iter,
|  | const Sentinel & | s
| ) |  |
| friend

Parameters

  iter | A UTFIterator
  s | A 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 1240 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 Sentinel & | s,
|  | const UTFIterator< CP32, behavior, UnitIter, LimitIter, typename > & | iter
| ) |  |
| friend

Parameters

  s | A unit iterator sentinel
  iter | A 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 1227 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 UTFIterator< CP32, behavior, UnitIter, LimitIter, typename > & | iter,
|  | const Sentinel & | s
| ) |  |
| friend

Parameters

  iter | A UTFIterator
  s | A 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 1208 of file utfiterator.h.

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

- common/unicode/utfiterator.h