Public Types | Public Member Functions | List of all members
ustl::utf8in_iterator< Iterator, WChar > Class Template Reference

An iterator adaptor to character containers for reading UTF-8 encoded text. More...

#include <ustl.h>

Public Types

typedef iterator_traits< Iterator >::value_type value_type
 
typedef iterator_traits< Iterator >::difference_type difference_type
 
typedef iterator_traits< Iterator >::pointer pointer
 
typedef iterator_traits< Iterator >::reference reference
 

Public Member Functions

 utf8in_iterator (const Iterator &is)
 
 utf8in_iterator (const utf8in_iterator &i)
 
const utf8in_iteratoroperator= (const utf8in_iterator &i)
 
Iterator base (void) const
 
WChar operator* (void) const
 Reads and returns the next value.
 
utf8in_iteratoroperator++ (void)
 
utf8in_iterator operator++ (int)
 
utf8in_iteratoroperator+= (uoff_t n)
 
utf8in_iterator operator+ (uoff_t n)
 
bool operator== (const utf8in_iterator &i) const
 
bool operator< (const utf8in_iterator &i) const
 
difference_type operator- (const utf8in_iterator &i) const
 Returns the distance in characters (as opposed to the distance in bytes).
 

Detailed Description

template<typename Iterator, typename WChar = wchar_t>
class ustl::utf8in_iterator< Iterator, WChar >

An iterator adaptor to character containers for reading UTF-8 encoded text.

For example, you can copy from ustl::string to ustl::vector<wchar_t> with copy (utf8in (str.begin()), utf8in (str.end()), back_inserter(wvect)); There is no error handling; if the reading frame slips you'll get extra characters, one for every misaligned byte. Although it is possible to skip to the start of the next character, that would result in omitting the misformatted character and the one after it, making it very difficult to detect by the user. It is better to write some strange characters and let the user know his file is corrupted. Another problem is overflow on bad encodings (like a 0xFF on the end of a string). This is checked through the end-of-string nul character, which will always be there as long as you are using the string class.


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

Generated on Mon Sep 28 2015 17:58:50 for uSTL by Doxygen 1.8.10