KiCad PCB EDA Suite
UTF8::uni_iter Class Reference

uni_iter is a non-mutating iterator that walks through unicode code points in the UTF8 encoded string. More...

#include <utf8.h>

Public Member Functions

 uni_iter ()
 
 uni_iter (const uni_iter &o)
 
const uni_iteroperator++ ()
 pre-increment and return uni_iter at new position More...
 
uni_iter operator++ (int)
 post-increment and return uni_iter at initial position More...
 
unsigned operator-> () const
 return unicode at current position More...
 
unsigned operator * () const
 return unicode at current position More...
 
uni_iter operator- (int aVal) const
 
bool operator== (const uni_iter &other) const
 
bool operator!= (const uni_iter &other) const
 
bool operator< (const uni_iter &other) const
 Since the ++ operators advance more than one byte, this is your best loop termination test, < end(), not == end(). More...
 
bool operator<= (const uni_iter &other) const
 
bool operator> (const uni_iter &other) const
 
bool operator>= (const uni_iter &other) const
 

Private Member Functions

 uni_iter (const char *start)
 

Private Attributes

const unsigned char * it
 

Friends

class UTF8
 

Detailed Description

uni_iter is a non-mutating iterator that walks through unicode code points in the UTF8 encoded string.

The normal ++(), ++(int), ->(), and *() operators are all supported for read only access and some return an unsigned holding the unicode character appropriate for the respective operator.

Definition at line 203 of file utf8.h.

Constructor & Destructor Documentation

◆ uni_iter() [1/3]

UTF8::uni_iter::uni_iter ( )
inline

Definition at line 206 of file utf8.h.

207  {
208  it = nullptr;
209  }
const unsigned char * it
Definition: utf8.h:267

References it.

Referenced by operator-().

◆ uni_iter() [2/3]

UTF8::uni_iter::uni_iter ( const uni_iter o)
inline

Definition at line 211 of file utf8.h.

212  {
213  it = o.it;
214  }
const unsigned char * it
Definition: utf8.h:267

References it.

◆ uni_iter() [3/3]

UTF8::uni_iter::uni_iter ( const char *  start)
inlineprivate

Definition at line 270 of file utf8.h.

270  :
271  it( (const unsigned char*) start )
272  {
273  }
const unsigned char * it
Definition: utf8.h:267

Member Function Documentation

◆ operator *()

unsigned UTF8::uni_iter::operator * ( ) const
inline

return unicode at current position

Definition at line 243 of file utf8.h.

244  {
245  unsigned result;
246 
247  // grab the result, do not advance
248  uni_forward( it, &result );
249  return result;
250  }
const unsigned char * it
Definition: utf8.h:267
static int uni_forward(const unsigned char *aSequence, unsigned *aResult=nullptr)
Advance over a single UTF8 encoded multibyte character, capturing the Unicode character as it goes,...
Definition: utf8.cpp:68

References it, and UTF8::uni_forward().

◆ operator!=()

bool UTF8::uni_iter::operator!= ( const uni_iter other) const
inline

Definition at line 255 of file utf8.h.

255 { return it != other.it; }
const unsigned char * it
Definition: utf8.h:267

References it.

◆ operator++() [1/2]

const uni_iter& UTF8::uni_iter::operator++ ( )
inline

pre-increment and return uni_iter at new position

Definition at line 217 of file utf8.h.

218  {
219  it += uni_forward( it );
220  return *this;
221  }
const unsigned char * it
Definition: utf8.h:267
static int uni_forward(const unsigned char *aSequence, unsigned *aResult=nullptr)
Advance over a single UTF8 encoded multibyte character, capturing the Unicode character as it goes,...
Definition: utf8.cpp:68

References it, and UTF8::uni_forward().

◆ operator++() [2/2]

uni_iter UTF8::uni_iter::operator++ ( int  )
inline

post-increment and return uni_iter at initial position

Definition at line 224 of file utf8.h.

225  {
226  uni_iter ret = *this;
227 
228  it += uni_forward( it );
229  return ret;
230  }
const unsigned char * it
Definition: utf8.h:267
static int uni_forward(const unsigned char *aSequence, unsigned *aResult=nullptr)
Advance over a single UTF8 encoded multibyte character, capturing the Unicode character as it goes,...
Definition: utf8.cpp:68

References it, and UTF8::uni_forward().

◆ operator-()

uni_iter UTF8::uni_iter::operator- ( int  aVal) const
inline

Definition at line 252 of file utf8.h.

252 { return uni_iter( (char*) it - aVal ); }
const unsigned char * it
Definition: utf8.h:267

References it, and uni_iter().

◆ operator->()

unsigned UTF8::uni_iter::operator-> ( ) const
inline

return unicode at current position

Definition at line 233 of file utf8.h.

234  {
235  unsigned result;
236 
237  // grab the result, do not advance
238  uni_forward( it, &result );
239  return result;
240  }
const unsigned char * it
Definition: utf8.h:267
static int uni_forward(const unsigned char *aSequence, unsigned *aResult=nullptr)
Advance over a single UTF8 encoded multibyte character, capturing the Unicode character as it goes,...
Definition: utf8.cpp:68

References it, and UTF8::uni_forward().

◆ operator<()

bool UTF8::uni_iter::operator< ( const uni_iter other) const
inline

Since the ++ operators advance more than one byte, this is your best loop termination test, < end(), not == end().

Definition at line 259 of file utf8.h.

259 { return it < other.it; }
const unsigned char * it
Definition: utf8.h:267

References it.

◆ operator<=()

bool UTF8::uni_iter::operator<= ( const uni_iter other) const
inline

Definition at line 260 of file utf8.h.

260 { return it <= other.it; }
const unsigned char * it
Definition: utf8.h:267

References it.

◆ operator==()

bool UTF8::uni_iter::operator== ( const uni_iter other) const
inline

Definition at line 254 of file utf8.h.

254 { return it == other.it; }
const unsigned char * it
Definition: utf8.h:267

References it.

◆ operator>()

bool UTF8::uni_iter::operator> ( const uni_iter other) const
inline

Definition at line 261 of file utf8.h.

261 { return it > other.it; }
const unsigned char * it
Definition: utf8.h:267

References it.

◆ operator>=()

bool UTF8::uni_iter::operator>= ( const uni_iter other) const
inline

Definition at line 262 of file utf8.h.

262 { return it >= other.it; }
const unsigned char * it
Definition: utf8.h:267

References it.

Friends And Related Function Documentation

◆ UTF8

friend class UTF8
friend

Definition at line 265 of file utf8.h.

Member Data Documentation

◆ it

const unsigned char* UTF8::uni_iter::it
private

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