-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathutf8_string_iterator.hpp
More file actions
71 lines (44 loc) · 1.89 KB
/
utf8_string_iterator.hpp
File metadata and controls
71 lines (44 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// Created by Marek on 30.9.2019.
//
#pragma once
#include <iterator>
#include "common.hpp"
namespace unidecode {
// TODO: make const and non-const version !
class Utf8StringIterator {
public:
typedef ptrdiff_t difference_type; //almost always ptrdiff_t
typedef unicode_char value_type; //almost always T
typedef const unicode_char& reference; //almost always T& or const T&
typedef const unicode_char* pointer; //almost always T* or const T*
typedef std::bidirectional_iterator_tag iterator_category; //usually std::forward_iterator_tag or similar
Utf8StringIterator(const char* data);
Utf8StringIterator();
Utf8StringIterator(const Utf8StringIterator& it);
~Utf8StringIterator();
Utf8StringIterator& operator=(const Utf8StringIterator& it);
friend void swap(Utf8StringIterator& lhs, Utf8StringIterator& rhs);
Utf8StringIterator& operator++();
Utf8StringIterator operator++(int);
value_type operator*() const;
// pointer operator->() const;
friend bool operator==(const Utf8StringIterator&, const Utf8StringIterator&);
friend bool operator!=(const Utf8StringIterator&, const Utf8StringIterator&);
Utf8StringIterator& operator--();
Utf8StringIterator operator--(int);
private:
const char* it_;
void StepForward();
void StepBackward();
};
}
namespace std {
template<> struct iterator_traits<unidecode::Utf8StringIterator> {
typedef unidecode::Utf8StringIterator::difference_type difference_type;
typedef unidecode::Utf8StringIterator::value_type value_type;
typedef unidecode::Utf8StringIterator::reference reference;
typedef unidecode::Utf8StringIterator::pointer pointer;
typedef unidecode::Utf8StringIterator::iterator_category iterator_category;
};
}