ICU 78.1  78.1
Data Structures | Public Types | Public Member Functions | Friends
U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, typename > Class Template Reference

Non-validating iterator over the code points in a Unicode string. More...

#include <utfiterator.h>

Public Types

using value_type = UnsafeCodeUnits< 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 UnsafeUTFIterator (UnitIter p)
 Constructor; the iterator/pointer should be at a code point boundary. More...
 
U_FORCE_INLINE UnsafeUTFIterator ()
 Default constructor. More...
 
U_FORCE_INLINE UnsafeUTFIterator (UnsafeUTFIterator &&src) noexcept=default
 Move constructor. More...
 
U_FORCE_INLINE UnsafeUTFIteratoroperator= (UnsafeUTFIterator &&src) noexcept=default
 Move assignment operator. More...
 
U_FORCE_INLINE UnsafeUTFIterator (const UnsafeUTFIterator &other)=default
 Copy constructor. More...
 
U_FORCE_INLINE UnsafeUTFIteratoroperator= (const UnsafeUTFIterator &other)=default
 Copy assignment operator. More...
 
U_FORCE_INLINE bool operator== (const UnsafeUTFIterator &other) const
 
U_FORCE_INLINE bool operator!= (const UnsafeUTFIterator &other) const
 
U_FORCE_INLINE UnsafeCodeUnits< 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 UnsafeUTFIteratoroperator++ ()
 Pre-increment operator. More...
 
U_FORCE_INLINE UnsafeUTFIterator operator++ (int)
 Post-increment operator. More...
 
template<typename Iter = UnitIter>
U_FORCE_INLINE std::enable_if_t< prv::bidirectional_iterator< Iter >, UnsafeUTFIterator & > operator-- ()
 Pre-decrement operator. More...
 
template<typename Iter = UnitIter>
U_FORCE_INLINE std::enable_if_t< prv::bidirectional_iterator< Iter >, UnsafeUTFIteratoroperator-- (int)
 Post-decrement operator. More...
 

Friends

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

Detailed Description

template<typename CP32, typename UnitIter, typename = void>
class U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, typename >

Non-validating iterator over the code points in a Unicode string.

The string must be well-formed.

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 unsafeUTFIterator() to have the compiler deduce the UnitIter type.

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
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
Draft:
This API may be changed in the future versions and was introduced in ICU 78
See also
unsafeUTFIterator

Definition at line 1920 of file utfiterator.h.

Member Typedef Documentation

◆ difference_type

template<typename CP32 , typename UnitIter , typename = void>
using U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, 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 1943 of file utfiterator.h.

◆ iterator_category

template<typename CP32 , typename UnitIter , typename = void>
using U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, 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 1945 of file utfiterator.h.

◆ pointer

template<typename CP32 , typename UnitIter , typename = void>
using U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, typename >::pointer = Proxy

C++ iterator boilerplate.

Internal:
Do not use.

This API is for internal use only.

Definition at line 1941 of file utfiterator.h.

◆ reference

template<typename CP32 , typename UnitIter , typename = void>
using U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, typename >::reference = value_type

C++ iterator boilerplate.

Internal:
Do not use.

This API is for internal use only.

Definition at line 1939 of file utfiterator.h.

◆ value_type

template<typename CP32 , typename UnitIter , typename = void>
using U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, typename >::value_type = UnsafeCodeUnits<CP32, UnitIter>

C++ iterator boilerplate.

Internal:
Do not use.

This API is for internal use only.

Definition at line 1937 of file utfiterator.h.

Constructor & Destructor Documentation

◆ UnsafeUTFIterator() [1/4]

template<typename CP32 , typename UnitIter , typename = void>
U_FORCE_INLINE U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, typename >::UnsafeUTFIterator ( UnitIter  p)
inlineexplicit

Constructor; the iterator/pointer should be at a code point boundary.

When using a code unit sentinel, then that sentinel also works as a sentinel for this code point iterator.

Parameters
pInitial position inside the range, or a range sentinel
Draft:
This API may be changed in the future versions and was introduced in ICU 78

Definition at line 1959 of file utfiterator.h.

◆ UnsafeUTFIterator() [2/4]

template<typename CP32 , typename UnitIter , typename = void>
U_FORCE_INLINE U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, typename >::UnsafeUTFIterator ( )
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 1965 of file utfiterator.h.

◆ UnsafeUTFIterator() [3/4]

template<typename CP32 , typename UnitIter , typename = void>
U_FORCE_INLINE U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, typename >::UnsafeUTFIterator ( UnsafeUTFIterator< CP32, UnitIter, typename > &&  src)
defaultnoexcept

Move constructor.

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

◆ UnsafeUTFIterator() [4/4]

template<typename CP32 , typename UnitIter , typename = void>
U_FORCE_INLINE U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, typename >::UnsafeUTFIterator ( const UnsafeUTFIterator< CP32, UnitIter, 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 , typename UnitIter , typename = void>
U_FORCE_INLINE bool U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, typename >::operator!= ( const UnsafeUTFIterator< CP32, UnitIter, 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 1990 of file utfiterator.h.

References U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, typename >::operator==().

◆ operator*()

template<typename CP32 , typename UnitIter , typename = void>
U_FORCE_INLINE UnsafeCodeUnits<CP32, UnitIter> U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, 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 2050 of file utfiterator.h.

◆ operator++() [1/2]

template<typename CP32 , typename UnitIter , typename = void>
U_FORCE_INLINE UnsafeUTFIterator& U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, 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 2082 of file utfiterator.h.

◆ operator++() [2/2]

template<typename CP32 , typename UnitIter , typename = void>
U_FORCE_INLINE UnsafeUTFIterator U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, 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 2104 of file utfiterator.h.

◆ operator--() [1/2]

template<typename CP32 , typename UnitIter , typename = void>
template<typename Iter = UnitIter>
U_FORCE_INLINE std::enable_if_t<prv::bidirectional_iterator<Iter>, UnsafeUTFIterator &> U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, 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 2136 of file utfiterator.h.

Referenced by U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, typename >::operator--().

◆ operator--() [2/2]

template<typename CP32 , typename UnitIter , typename = void>
template<typename Iter = UnitIter>
U_FORCE_INLINE std::enable_if_t<prv::bidirectional_iterator<Iter>, UnsafeUTFIterator> U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, 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 2156 of file utfiterator.h.

References U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, typename >::operator--().

◆ operator->()

template<typename CP32 , typename UnitIter , typename = void>
U_FORCE_INLINE Proxy U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, 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 2067 of file utfiterator.h.

◆ operator=() [1/2]

template<typename CP32 , typename UnitIter , typename = void>
U_FORCE_INLINE UnsafeUTFIterator& U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, typename >::operator= ( const UnsafeUTFIterator< CP32, UnitIter, 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 , typename UnitIter , typename = void>
U_FORCE_INLINE UnsafeUTFIterator& U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, typename >::operator= ( UnsafeUTFIterator< CP32, UnitIter, typename > &&  src)
defaultnoexcept

Move assignment operator.

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

◆ operator==()

template<typename CP32 , typename UnitIter , typename = void>
U_FORCE_INLINE bool U_HEADER_ONLY_NAMESPACE::UnsafeUTFIterator< CP32, UnitIter, typename >::operator== ( const UnsafeUTFIterator< CP32, UnitIter, 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 1982 of file utfiterator.h.

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

Friends And Related Function Documentation

◆ operator!= [1/2]

template<typename CP32 , typename UnitIter , typename = void>
template<typename Sentinel >
U_FORCE_INLINE friend std::enable_if_t< !std::is_same_v<Sentinel, UnsafeUTFIterator> && !std::is_same_v<Sentinel, UnitIter>, bool> operator!= ( const Sentinel &  s,
const UnsafeUTFIterator< CP32, UnitIter, typename > &  iter 
)
friend
Parameters
sA unit iterator sentinel
iterAn UnsafeUTFIterator
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 2041 of file utfiterator.h.

◆ operator!= [2/2]

template<typename CP32 , typename UnitIter , typename = void>
template<typename Sentinel >
U_FORCE_INLINE friend std::enable_if_t< !std::is_same_v<Sentinel, UnsafeUTFIterator> && !std::is_same_v<Sentinel, UnitIter>, bool> operator!= ( const UnsafeUTFIterator< CP32, UnitIter, typename > &  iter,
const Sentinel &  s 
)
friend
Parameters
iterAn UnsafeUTFIterator
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 2030 of file utfiterator.h.

◆ operator== [1/2]

template<typename CP32 , typename UnitIter , typename = void>
template<typename Sentinel >
U_FORCE_INLINE friend std::enable_if_t< !std::is_same_v<Sentinel, UnsafeUTFIterator> && !std::is_same_v<Sentinel, UnitIter>, bool> operator== ( const Sentinel &  s,
const UnsafeUTFIterator< CP32, UnitIter, typename > &  iter 
)
friend
Parameters
sA unit iterator sentinel
iterAn UnsafeUTFIterator
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 2017 of file utfiterator.h.

◆ operator== [2/2]

template<typename CP32 , typename UnitIter , typename = void>
template<typename Sentinel >
U_FORCE_INLINE friend std::enable_if_t< !std::is_same_v<Sentinel, UnsafeUTFIterator> && !std::is_same_v<Sentinel, UnitIter>, bool> operator== ( const UnsafeUTFIterator< CP32, UnitIter, typename > &  iter,
const Sentinel &  s 
)
friend
Parameters
iterAn UnsafeUTFIterator
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 2002 of file utfiterator.h.


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