KiCad PCB EDA Suite
UTF8::uni_iter Class Reference

class uni_iter is a non-muting 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...
 
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

class uni_iter is a non-muting 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 137 of file utf8.h.

Constructor & Destructor Documentation

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

Definition at line 144 of file utf8.h.

144  :
145  it( (const unsigned char*) start )
146  {
147  // for the human: assert( sizeof(unsigned) >= 4 );
148  }
const unsigned char * it
Definition: utf8.h:141
UTF8::uni_iter::uni_iter ( )
inline

Definition at line 153 of file utf8.h.

154  {
155  it = NULL;
156  }
const unsigned char * it
Definition: utf8.h:141
UTF8::uni_iter::uni_iter ( const uni_iter o)
inline

Definition at line 158 of file utf8.h.

References it.

159  {
160  it = o.it;
161  }
const unsigned char * it
Definition: utf8.h:141

Member Function Documentation

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

Definition at line 202 of file utf8.h.

References it.

202 { return it != other.it; }
const unsigned char * it
Definition: utf8.h:141
unsigned UTF8::uni_iter::operator* ( ) const
inline

return unicode at current position

Definition at line 192 of file utf8.h.

References UTF8::uni_forward().

193  {
194  unsigned result;
195 
196  // grab the result, do not advance
197  uni_forward( it, &result );
198  return result;
199  }
static int uni_forward(const unsigned char *aSequence, unsigned *aResult=NULL)
Function uni_forward advances over a single UTF8 encoded multibyte character, capturing the unicode c...
Definition: utf8.cpp:66
const unsigned char * it
Definition: utf8.h:141
const uni_iter& UTF8::uni_iter::operator++ ( )
inline

pre-increment and return uni_iter at new position

Definition at line 164 of file utf8.h.

References UTF8::uni_forward().

165  {
166  it += uni_forward( it );
167  return *this;
168  }
static int uni_forward(const unsigned char *aSequence, unsigned *aResult=NULL)
Function uni_forward advances over a single UTF8 encoded multibyte character, capturing the unicode c...
Definition: utf8.cpp:66
const unsigned char * it
Definition: utf8.h:141
uni_iter UTF8::uni_iter::operator++ ( int  )
inline

post-increment and return uni_iter at initial position

Definition at line 171 of file utf8.h.

References UTF8::uni_forward().

172  {
173  uni_iter ret = *this;
174 
175  it += uni_forward( it );
176  return ret;
177  }
static int uni_forward(const unsigned char *aSequence, unsigned *aResult=NULL)
Function uni_forward advances over a single UTF8 encoded multibyte character, capturing the unicode c...
Definition: utf8.cpp:66
const unsigned char * it
Definition: utf8.h:141
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 206 of file utf8.h.

References it.

206 { return it < other.it; }
const unsigned char * it
Definition: utf8.h:141
bool UTF8::uni_iter::operator<= ( const uni_iter other) const
inline

Definition at line 207 of file utf8.h.

References it.

207 { return it <= other.it; }
const unsigned char * it
Definition: utf8.h:141
bool UTF8::uni_iter::operator== ( const uni_iter other) const
inline

Definition at line 201 of file utf8.h.

References it.

201 { return it == other.it; }
const unsigned char * it
Definition: utf8.h:141
bool UTF8::uni_iter::operator> ( const uni_iter other) const
inline

Definition at line 208 of file utf8.h.

References it.

208 { return it > other.it; }
const unsigned char * it
Definition: utf8.h:141
bool UTF8::uni_iter::operator>= ( const uni_iter other) const
inline

Definition at line 209 of file utf8.h.

References it.

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

Friends And Related Function Documentation

friend class UTF8
friend

Definition at line 139 of file utf8.h.

Member Data Documentation

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

Definition at line 141 of file utf8.h.

Referenced by operator!=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), and uni_iter().


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