Public Member Functions | List of all members
Xapian::Utf8Iterator Class Reference

An iterator which returns Unicode character values from a UTF-8 encoded string. More...

Public Types

typedef std::input_iterator_tag iterator_category
 We implement the semantics of an STL input_iterator.
 
typedef unsigned value_type
 We implement the semantics of an STL input_iterator.
 
typedef size_t difference_type
 We implement the semantics of an STL input_iterator.
 
typedef const unsigned * pointer
 We implement the semantics of an STL input_iterator.
 
typedef const unsigned & reference
 We implement the semantics of an STL input_iterator.
 

Public Member Functions

const char * raw () const
 Return the raw const char * pointer for the current position. More...
 
size_t left () const
 Return the number of bytes left in the iterator's buffer. More...
 
void assign (const char *p_, size_t len)
 Assign a new string to the iterator. More...
 
void assign (const std::string &s)
 Assign a new string to the iterator. More...
 
 Utf8Iterator (const char *p_)
 Create an iterator given a pointer to a null terminated string. More...
 
 Utf8Iterator (const char *p_, size_t len)
 Create an iterator given a pointer and a length. More...
 
 Utf8Iterator (const std::string &s)
 Create an iterator given a string. More...
 
 Utf8Iterator ()
 Create an iterator which is at the end of its iteration. More...
 
unsigned operator* () const
 Get the current Unicode character value pointed to by the iterator. More...
 
Utf8Iterator operator++ (int)
 Move forward to the next Unicode character. More...
 
Utf8Iteratoroperator++ ()
 Move forward to the next Unicode character. More...
 
bool operator== (const Utf8Iterator &other) const
 Test two Utf8Iterators for equality. More...
 
bool operator!= (const Utf8Iterator &other) const
 Test two Utf8Iterators for inequality. More...
 

Detailed Description

An iterator which returns Unicode character values from a UTF-8 encoded string.

Constructor & Destructor Documentation

◆ Utf8Iterator() [1/4]

Xapian::Utf8Iterator::Utf8Iterator ( const char *  p_)
explicit

Create an iterator given a pointer to a null terminated string.

The iterator will return characters from the start of the string when next called. The string is not copied into the iterator, so it must remain valid while the iteration is in progress.

Parameters
p_A pointer to the start of the null terminated string to read.

◆ Utf8Iterator() [2/4]

Xapian::Utf8Iterator::Utf8Iterator ( const char *  p_,
size_t  len 
)
inline

Create an iterator given a pointer and a length.

The iterator will return characters from the start of the string when next called. The string is not copied into the iterator, so it must remain valid while the iteration is in progress.

Parameters
p_A pointer to the start of the string to read.
lenThe length of the string to read.

◆ Utf8Iterator() [3/4]

Xapian::Utf8Iterator::Utf8Iterator ( const std::string &  s)
inline

Create an iterator given a string.

The iterator will return characters from the start of the string when next called. The string is not copied into the iterator, so it must remain valid while the iteration is in progress.

Parameters
sThe string to read. Must not be modified while the iteration is in progress.

◆ Utf8Iterator() [4/4]

Xapian::Utf8Iterator::Utf8Iterator ( )
inline

Create an iterator which is at the end of its iteration.

This can be compared to another iterator to check if the other iterator has reached its end.

Member Function Documentation

◆ assign() [1/2]

void Xapian::Utf8Iterator::assign ( const char *  p_,
size_t  len 
)
inline

Assign a new string to the iterator.

The iterator will forget the string it was iterating through, and return characters from the start of the new string when next called. The string is not copied into the iterator, so it must remain valid while the iteration is in progress.

Parameters
p_A pointer to the start of the string to read.
lenThe length of the string to read.

◆ assign() [2/2]

void Xapian::Utf8Iterator::assign ( const std::string &  s)
inline

Assign a new string to the iterator.

The iterator will forget the string it was iterating through, and return characters from the start of the new string when next called. The string is not copied into the iterator, so it must remain valid while the iteration is in progress.

Parameters
sThe string to read. Must not be modified while the iteration is in progress.

References assign().

Referenced by assign().

◆ left()

size_t Xapian::Utf8Iterator::left ( ) const
inline

Return the number of bytes left in the iterator's buffer.

◆ operator!=()

bool Xapian::Utf8Iterator::operator!= ( const Utf8Iterator other) const
inline

Test two Utf8Iterators for inequality.

Parameters
otherThe Utf8Iterator to compare this one with.
Returns
true iff the iterators do not point to the same position.

◆ operator*()

unsigned Xapian::Utf8Iterator::operator* ( ) const

Get the current Unicode character value pointed to by the iterator.

If an invalid UTF-8 sequence is encountered, then the byte values comprising it are returned until valid UTF-8 or the end of the input is reached.

Returns unsigned(-1) if the iterator has reached the end of its buffer.

◆ operator++() [1/2]

Utf8Iterator Xapian::Utf8Iterator::operator++ ( int  )
inline

Move forward to the next Unicode character.

Returns
An iterator pointing to the position before the move.

◆ operator++() [2/2]

Utf8Iterator& Xapian::Utf8Iterator::operator++ ( )
inline

Move forward to the next Unicode character.

Returns
A reference to this object.

◆ operator==()

bool Xapian::Utf8Iterator::operator== ( const Utf8Iterator other) const
inline

Test two Utf8Iterators for equality.

Parameters
otherThe Utf8Iterator to compare this one with.
Returns
true iff the iterators point to the same position.

◆ raw()

const char* Xapian::Utf8Iterator::raw ( ) const
inline

Return the raw const char * pointer for the current position.


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

Documentation for Xapian (version 1.4.9).
Generated on Sat Nov 3 2018 by Doxygen 1.8.13.