arsa  2.7
Public Types | Public Member Functions | Protected Attributes | List of all members
irr::core::ustring16< TAlloc >::_ustring16_const_iterator Class Reference

Iterator to iterate through a UTF-16 string. More...

#include <irrUString.h>

Inheritance diagram for irr::core::ustring16< TAlloc >::_ustring16_const_iterator:
irr::core::ustring16< TAlloc >::_ustring16_iterator

Public Types

typedef _ustring16_const_iterator _Iter
 
typedef const access const_pointer
 
typedef const access const_reference
 
typedef access value_type
 
typedef size_t difference_type
 
typedef size_t distance_type
 
typedef const_pointer pointer
 
typedef const_reference reference
 

Public Member Functions

 _ustring16_const_iterator (const _Iter &i)
 Constructors. More...
 
 _ustring16_const_iterator (const ustring16< TAlloc > &s)
 
 _ustring16_const_iterator (const ustring16< TAlloc > &s, const size_t p)
 
bool operator== (const _Iter &iter) const
 Test for equalness. More...
 
bool operator!= (const _Iter &iter) const
 Test for unequalness. More...
 
_Iteroperator++ ()
 Switch to the next full character in the string. More...
 
_Iter operator++ (int)
 Switch to the next full character in the string, returning the previous position. More...
 
_Iteroperator-- ()
 Switch to the previous full character in the string. More...
 
_Iter operator-- (int)
 Switch to the previous full character in the string, returning the previous position. More...
 
_Iteroperator+= (const difference_type v)
 
_Iteroperator-= (const difference_type v)
 
_Iter operator+ (const difference_type v) const
 Return a new iterator that is a variable number of full characters forward from the current position. More...
 
_Iter operator- (const difference_type v) const
 Return a new iterator that is a variable number of full characters backward from the current position. More...
 
difference_type operator- (const _Iter &iter) const
 Returns the distance between two iterators. More...
 
const_reference operator * () const
 Accesses the full character at the iterator's position. More...
 
reference operator * ()
 Accesses the full character at the iterator's position. More...
 
const_pointer operator-> () const
 Accesses the full character at the iterator's position. More...
 
pointer operator-> ()
 Accesses the full character at the iterator's position. More...
 
bool atStart () const
 Is the iterator at the start of the string? More...
 
bool atEnd () const
 Is the iterator at the end of the string? More...
 
void toStart ()
 Moves the iterator to the start of the string. More...
 
void toEnd ()
 Moves the iterator to the end of the string. More...
 
size_t getPos () const
 

Protected Attributes

const ustring16< TAlloc > * ref
 
size_t pos
 

Detailed Description

template<typename TAlloc = irrAllocator<uchar16_t>>
class irr::core::ustring16< TAlloc >::_ustring16_const_iterator

Iterator to iterate through a UTF-16 string.

Definition at line 448 of file irrUString.h.

Member Typedef Documentation

◆ _Iter

template<typename TAlloc = irrAllocator<uchar16_t>>
typedef _ustring16_const_iterator irr::core::ustring16< TAlloc >::_ustring16_const_iterator::_Iter

Definition at line 452 of file irrUString.h.

◆ const_pointer

template<typename TAlloc = irrAllocator<uchar16_t>>
typedef const access irr::core::ustring16< TAlloc >::_ustring16_const_iterator::const_pointer

Definition at line 454 of file irrUString.h.

◆ const_reference

template<typename TAlloc = irrAllocator<uchar16_t>>
typedef const access irr::core::ustring16< TAlloc >::_ustring16_const_iterator::const_reference

Definition at line 455 of file irrUString.h.

◆ difference_type

template<typename TAlloc = irrAllocator<uchar16_t>>
typedef size_t irr::core::ustring16< TAlloc >::_ustring16_const_iterator::difference_type

Definition at line 466 of file irrUString.h.

◆ distance_type

template<typename TAlloc = irrAllocator<uchar16_t>>
typedef size_t irr::core::ustring16< TAlloc >::_ustring16_const_iterator::distance_type

Definition at line 467 of file irrUString.h.

◆ pointer

template<typename TAlloc = irrAllocator<uchar16_t>>
typedef const_pointer irr::core::ustring16< TAlloc >::_ustring16_const_iterator::pointer

Definition at line 468 of file irrUString.h.

◆ reference

template<typename TAlloc = irrAllocator<uchar16_t>>
typedef const_reference irr::core::ustring16< TAlloc >::_ustring16_const_iterator::reference

Definition at line 469 of file irrUString.h.

◆ value_type

template<typename TAlloc = irrAllocator<uchar16_t>>
typedef access irr::core::ustring16< TAlloc >::_ustring16_const_iterator::value_type

Definition at line 465 of file irrUString.h.

Constructor & Destructor Documentation

◆ _ustring16_const_iterator() [1/3]

template<typename TAlloc = irrAllocator<uchar16_t>>
irr::core::ustring16< TAlloc >::_ustring16_const_iterator::_ustring16_const_iterator ( const _Iter i)
inline

Constructors.

Definition at line 473 of file irrUString.h.

◆ _ustring16_const_iterator() [2/3]

template<typename TAlloc = irrAllocator<uchar16_t>>
irr::core::ustring16< TAlloc >::_ustring16_const_iterator::_ustring16_const_iterator ( const ustring16< TAlloc > &  s)
inline

Definition at line 474 of file irrUString.h.

474 : ref(&s), pos(0) {}
GLdouble s
Definition: SDL_opengl.h:2063

◆ _ustring16_const_iterator() [3/3]

template<typename TAlloc = irrAllocator<uchar16_t>>
irr::core::ustring16< TAlloc >::_ustring16_const_iterator::_ustring16_const_iterator ( const ustring16< TAlloc > &  s,
const size_t  p 
)
inline

Definition at line 475 of file irrUString.h.

475  : ref(&s), pos(0)
476  {
477  if (ref->size_raw() == 0 || p == 0)
478  return;
479 
480  // Go to the appropriate position.
481  size_t i = p;
482  size_t sr = ref->size_raw();
483  const uchar16_t* a = ref->c_str();
484  while (i != 0 && pos < sr)
485  {
487  pos += 2;
488  else ++pos;
489  --i;
490  }
491  }
u16 uchar16_t
Definition: irrUString.h:86
GLfloat GLfloat p
#define UTF16_IS_SURROGATE_HI(c)
Definition: irrUString.h:72
GLdouble s
Definition: SDL_opengl.h:2063
GLboolean GLboolean GLboolean GLboolean a
GLenum GLint ref

Member Function Documentation

◆ atEnd()

template<typename TAlloc = irrAllocator<uchar16_t>>
bool irr::core::ustring16< TAlloc >::_ustring16_const_iterator::atEnd ( ) const
inline

Is the iterator at the end of the string?

Definition at line 696 of file irrUString.h.

697  {
698  const uchar16_t* a = ref->c_str();
699  if (UTF16_IS_SURROGATE(a[pos]))
700  return (pos + 1) >= ref->size_raw();
701  else return pos >= ref->size_raw();
702  }
u16 uchar16_t
Definition: irrUString.h:86
GLboolean GLboolean GLboolean GLboolean a
GLenum GLint ref
#define UTF16_IS_SURROGATE(c)
Is a UTF-16 code point a surrogate?
Definition: irrUString.h:71

◆ atStart()

template<typename TAlloc = irrAllocator<uchar16_t>>
bool irr::core::ustring16< TAlloc >::_ustring16_const_iterator::atStart ( ) const
inline

Is the iterator at the start of the string?

Definition at line 690 of file irrUString.h.

691  {
692  return pos == 0;
693  }

◆ getPos()

template<typename TAlloc = irrAllocator<uchar16_t>>
size_t irr::core::ustring16< TAlloc >::_ustring16_const_iterator::getPos ( ) const
inline

Returns the iterator's position.

Returns
The iterator's position.

Definition at line 719 of file irrUString.h.

720  {
721  return pos;
722  }

◆ operator *() [1/2]

template<typename TAlloc = irrAllocator<uchar16_t>>
const_reference irr::core::ustring16< TAlloc >::_ustring16_const_iterator::operator * ( ) const
inline

Accesses the full character at the iterator's position.

Definition at line 646 of file irrUString.h.

647  {
648  if (pos >= ref->size_raw())
649  {
650  const uchar16_t* a = ref->c_str();
651  size_t p = ref->size_raw();
652  if (UTF16_IS_SURROGATE_LO(a[p]))
653  --p;
654  reference ret(ref, p);
655  return ret;
656  }
657  const_reference ret(ref, pos);
658  return ret;
659  }
u16 uchar16_t
Definition: irrUString.h:86
GLint reference
#define UTF16_IS_SURROGATE_LO(c)
Definition: irrUString.h:73
GLfloat GLfloat p
GLboolean GLboolean GLboolean GLboolean a
GLenum GLint ref

◆ operator *() [2/2]

template<typename TAlloc = irrAllocator<uchar16_t>>
reference irr::core::ustring16< TAlloc >::_ustring16_const_iterator::operator * ( )
inline

Accesses the full character at the iterator's position.

Definition at line 662 of file irrUString.h.

663  {
664  if (pos >= ref->size_raw())
665  {
666  const uchar16_t* a = ref->c_str();
667  size_t p = ref->size_raw();
668  if (UTF16_IS_SURROGATE_LO(a[p]))
669  --p;
670  reference ret(ref, p);
671  return ret;
672  }
673  reference ret(ref, pos);
674  return ret;
675  }
u16 uchar16_t
Definition: irrUString.h:86
GLint reference
#define UTF16_IS_SURROGATE_LO(c)
Definition: irrUString.h:73
GLfloat GLfloat p
GLboolean GLboolean GLboolean GLboolean a
GLenum GLint ref

◆ operator!=()

template<typename TAlloc = irrAllocator<uchar16_t>>
bool irr::core::ustring16< TAlloc >::_ustring16_const_iterator::operator!= ( const _Iter iter) const
inline

Test for unequalness.

Definition at line 502 of file irrUString.h.

503  {
504  if (ref != iter.ref || pos != iter.pos)
505  return true;
506  return false;
507  }
GLenum GLint ref

◆ operator+()

template<typename TAlloc = irrAllocator<uchar16_t>>
_Iter irr::core::ustring16< TAlloc >::_ustring16_const_iterator::operator+ ( const difference_type  v) const
inline

Return a new iterator that is a variable number of full characters forward from the current position.

Definition at line 600 of file irrUString.h.

601  {
602  _Iter ret(*this);
603  ret += v;
604  return ret;
605  }
const GLdouble * v
Definition: SDL_opengl.h:2064

◆ operator++() [1/2]

template<typename TAlloc = irrAllocator<uchar16_t>>
_Iter& irr::core::ustring16< TAlloc >::_ustring16_const_iterator::operator++ ( )
inline

Switch to the next full character in the string.

Definition at line 510 of file irrUString.h.

511  { // ++iterator
512  if (pos == ref->size_raw()) return *this;
513  const uchar16_t* a = ref->c_str();
515  pos += 2; // TODO: check for valid low surrogate?
516  else ++pos;
517  if (pos > ref->size_raw()) pos = ref->size_raw();
518  return *this;
519  }
u16 uchar16_t
Definition: irrUString.h:86
#define UTF16_IS_SURROGATE_HI(c)
Definition: irrUString.h:72
GLboolean GLboolean GLboolean GLboolean a
GLenum GLint ref

◆ operator++() [2/2]

template<typename TAlloc = irrAllocator<uchar16_t>>
_Iter irr::core::ustring16< TAlloc >::_ustring16_const_iterator::operator++ ( int  )
inline

Switch to the next full character in the string, returning the previous position.

Definition at line 522 of file irrUString.h.

523  { // iterator++
524  _Iter _tmp(*this);
525  ++*this;
526  return _tmp;
527  }

◆ operator+=()

template<typename TAlloc = irrAllocator<uchar16_t>>
_Iter& irr::core::ustring16< TAlloc >::_ustring16_const_iterator::operator+= ( const difference_type  v)
inline

Advance a specified number of full characters in the string.

Returns
Myself.

Definition at line 550 of file irrUString.h.

551  {
552  if (v == 0) return *this;
553  if (v < 0) return operator-=(v * -1);
554 
555  if (pos >= ref->size_raw())
556  return *this;
557 
558  // Go to the appropriate position.
559  difference_type i = v;
560  size_t sr = ref->size_raw();
561  const uchar16_t* a = ref->c_str();
562  while (i != 0 && pos < sr)
563  {
565  pos += 2;
566  else ++pos;
567  --i;
568  }
569  if (pos > sr)
570  pos = sr;
571 
572  return *this;
573  }
u16 uchar16_t
Definition: irrUString.h:86
#define UTF16_IS_SURROGATE_HI(c)
Definition: irrUString.h:72
const GLdouble * v
Definition: SDL_opengl.h:2064
_Iter & operator-=(const difference_type v)
Definition: irrUString.h:577
GLboolean GLboolean GLboolean GLboolean a
GLenum GLint ref

◆ operator-() [1/2]

template<typename TAlloc = irrAllocator<uchar16_t>>
_Iter irr::core::ustring16< TAlloc >::_ustring16_const_iterator::operator- ( const difference_type  v) const
inline

Return a new iterator that is a variable number of full characters backward from the current position.

Definition at line 608 of file irrUString.h.

609  {
610  _Iter ret(*this);
611  ret -= v;
612  return ret;
613  }
const GLdouble * v
Definition: SDL_opengl.h:2064

◆ operator-() [2/2]

template<typename TAlloc = irrAllocator<uchar16_t>>
difference_type irr::core::ustring16< TAlloc >::_ustring16_const_iterator::operator- ( const _Iter iter) const
inline

Returns the distance between two iterators.

Definition at line 616 of file irrUString.h.

617  {
618  // Make sure we reference the same object!
619  if (ref != iter.ref)
620  return difference_type();
621 
622  _Iter i = iter;
623  difference_type ret;
624 
625  // Walk up.
626  if (pos > i.pos)
627  {
628  while (pos > i.pos)
629  {
630  ++i;
631  ++ret;
632  }
633  return ret;
634  }
635 
636  // Walk down.
637  while (pos < i.pos)
638  {
639  --i;
640  --ret;
641  }
642  return ret;
643  }
GLenum GLint ref

◆ operator--() [1/2]

template<typename TAlloc = irrAllocator<uchar16_t>>
_Iter& irr::core::ustring16< TAlloc >::_ustring16_const_iterator::operator-- ( )
inline

Switch to the previous full character in the string.

Definition at line 530 of file irrUString.h.

531  { // --iterator
532  if (pos == 0) return *this;
533  const uchar16_t* a = ref->c_str();
534  --pos;
535  if (UTF16_IS_SURROGATE_LO(a[pos]) && pos != 0) // low surrogate, go back one more.
536  --pos;
537  return *this;
538  }
u16 uchar16_t
Definition: irrUString.h:86
#define UTF16_IS_SURROGATE_LO(c)
Definition: irrUString.h:73
GLboolean GLboolean GLboolean GLboolean a
GLenum GLint ref

◆ operator--() [2/2]

template<typename TAlloc = irrAllocator<uchar16_t>>
_Iter irr::core::ustring16< TAlloc >::_ustring16_const_iterator::operator-- ( int  )
inline

Switch to the previous full character in the string, returning the previous position.

Definition at line 541 of file irrUString.h.

542  { // iterator--
543  _Iter _tmp(*this);
544  --*this;
545  return _tmp;
546  }

◆ operator-=()

template<typename TAlloc = irrAllocator<uchar16_t>>
_Iter& irr::core::ustring16< TAlloc >::_ustring16_const_iterator::operator-= ( const difference_type  v)
inline

Go back a specified number of full characters in the string.

Returns
Myself.

Definition at line 577 of file irrUString.h.

578  {
579  if (v == 0) return *this;
580  if (v > 0) return operator+=(v * -1);
581 
582  if (pos == 0)
583  return *this;
584 
585  // Go to the appropriate position.
586  difference_type i = v;
587  const uchar16_t* a = ref->c_str();
588  while (i != 0 && pos != 0)
589  {
590  --pos;
591  if (UTF16_IS_SURROGATE_LO(a[pos]) != 0 && pos != 0)
592  --pos;
593  --i;
594  }
595 
596  return *this;
597  }
u16 uchar16_t
Definition: irrUString.h:86
#define UTF16_IS_SURROGATE_LO(c)
Definition: irrUString.h:73
const GLdouble * v
Definition: SDL_opengl.h:2064
GLboolean GLboolean GLboolean GLboolean a
GLenum GLint ref
_Iter & operator+=(const difference_type v)
Definition: irrUString.h:550

◆ operator->() [1/2]

template<typename TAlloc = irrAllocator<uchar16_t>>
const_pointer irr::core::ustring16< TAlloc >::_ustring16_const_iterator::operator-> ( ) const
inline

Accesses the full character at the iterator's position.

Definition at line 678 of file irrUString.h.

679  {
680  return operator*();
681  }
const_reference operator *() const
Accesses the full character at the iterator's position.
Definition: irrUString.h:646

◆ operator->() [2/2]

template<typename TAlloc = irrAllocator<uchar16_t>>
pointer irr::core::ustring16< TAlloc >::_ustring16_const_iterator::operator-> ( )
inline

Accesses the full character at the iterator's position.

Definition at line 684 of file irrUString.h.

685  {
686  return operator*();
687  }
const_reference operator *() const
Accesses the full character at the iterator's position.
Definition: irrUString.h:646

◆ operator==()

template<typename TAlloc = irrAllocator<uchar16_t>>
bool irr::core::ustring16< TAlloc >::_ustring16_const_iterator::operator== ( const _Iter iter) const
inline

Test for equalness.

Definition at line 494 of file irrUString.h.

495  {
496  if (ref == iter.ref && pos == iter.pos)
497  return true;
498  return false;
499  }
GLenum GLint ref

◆ toEnd()

template<typename TAlloc = irrAllocator<uchar16_t>>
void irr::core::ustring16< TAlloc >::_ustring16_const_iterator::toEnd ( )
inline

Moves the iterator to the end of the string.

Definition at line 711 of file irrUString.h.

712  {
713  const uchar16_t* a = ref->c_str();
714  pos = ref->size_raw();
715  }
u16 uchar16_t
Definition: irrUString.h:86
GLboolean GLboolean GLboolean GLboolean a
GLenum GLint ref

◆ toStart()

template<typename TAlloc = irrAllocator<uchar16_t>>
void irr::core::ustring16< TAlloc >::_ustring16_const_iterator::toStart ( )
inline

Moves the iterator to the start of the string.

Definition at line 705 of file irrUString.h.

706  {
707  pos = 0;
708  }

Member Data Documentation

◆ pos

template<typename TAlloc = irrAllocator<uchar16_t>>
size_t irr::core::ustring16< TAlloc >::_ustring16_const_iterator::pos
protected

Definition at line 726 of file irrUString.h.

◆ ref

template<typename TAlloc = irrAllocator<uchar16_t>>
const ustring16<TAlloc>* irr::core::ustring16< TAlloc >::_ustring16_const_iterator::ref
protected

Definition at line 725 of file irrUString.h.


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