mirror of
https://github.com/nemtrif/utfcpp.git
synced 2025-04-06 14:05:06 +00:00
change name : iterator2 becomes iterator8. iterator8 base class name is now iterator_base
This commit is contained in:
parent
7e42ceb42f
commit
dd275a6865
3 changed files with 38 additions and 37 deletions
|
@ -318,25 +318,25 @@ namespace utf8
|
|||
}
|
||||
}; // class iterator
|
||||
|
||||
//the iterator2 class
|
||||
//the iterator8 class
|
||||
template <typename octet_iterator>
|
||||
class iterator2 : public utf8::internal::iterator2<octet_iterator> {
|
||||
|
||||
class iterator8 : public utf8::internal::iterator_base<octet_iterator> {
|
||||
|
||||
public:
|
||||
using Base = utf8::internal::iterator2<octet_iterator>;
|
||||
iterator2 () {}
|
||||
iterator2 (octet_iterator begin, octet_iterator end): Base{begin, end, utf8::next<octet_iterator>} {}
|
||||
}; // class iterator2
|
||||
using Base = utf8::internal::iterator_base<octet_iterator>;
|
||||
iterator8 () {}
|
||||
iterator8 (octet_iterator begin, octet_iterator end): Base{begin, end, utf8::next<octet_iterator>} {}
|
||||
}; // class iterator8
|
||||
|
||||
template <typename octet_iterator>
|
||||
inline bool operator==(const iterator2<octet_iterator>& a, const iterator2<octet_iterator>& b)
|
||||
inline bool operator==(const iterator8<octet_iterator>& a, const iterator8<octet_iterator>& b)
|
||||
{
|
||||
return a.equals(b);
|
||||
return a.equals(b);
|
||||
}
|
||||
template <typename octet_iterator>
|
||||
inline bool operator!=(const iterator2<octet_iterator>& a, const iterator2<octet_iterator>& b)
|
||||
inline bool operator!=(const iterator8<octet_iterator>& a, const iterator8<octet_iterator>& b)
|
||||
{
|
||||
return !a.equals(b);
|
||||
return !a.equals(b);
|
||||
}
|
||||
|
||||
} // namespace utf8
|
||||
|
|
|
@ -298,17 +298,17 @@ namespace internal
|
|||
return utf8::internal::validate_next(it, end, ignored);
|
||||
}
|
||||
|
||||
//the iterator2 class
|
||||
//the iterator_base class
|
||||
template <typename octet_iterator>
|
||||
class iterator2 : public std::iterator <std::input_iterator_tag, uint32_t> {
|
||||
public:
|
||||
class iterator_base : public std::iterator <std::input_iterator_tag, uint32_t> {
|
||||
protected:
|
||||
using function = std::function<uint32_t(octet_iterator&, octet_iterator)>;
|
||||
private:
|
||||
uint32_t cp{};
|
||||
octet_iterator p{};
|
||||
const octet_iterator end{};
|
||||
bool ok{};
|
||||
const function func{};
|
||||
const function func{};
|
||||
|
||||
void read()
|
||||
{
|
||||
|
@ -319,12 +319,12 @@ namespace internal
|
|||
}
|
||||
}
|
||||
public:
|
||||
iterator2 () {}
|
||||
iterator2 (octet_iterator begin_, octet_iterator end_, function f): p{begin_}, end{end_}, func{f} { read(); }
|
||||
iterator_base () {}
|
||||
iterator_base (octet_iterator begin_, octet_iterator end_, function f): p{begin_}, end{end_}, func{f} { read(); }
|
||||
uint32_t operator * () const { return cp; }
|
||||
uint32_t* operator -> () const { return &cp; }
|
||||
|
||||
iterator2& operator ++ ()
|
||||
iterator_base& operator ++ ()
|
||||
{
|
||||
if(!ok)
|
||||
{
|
||||
|
@ -333,22 +333,22 @@ namespace internal
|
|||
read();
|
||||
return *this;
|
||||
}
|
||||
iterator2 operator ++ (int)
|
||||
iterator_base operator ++ (int)
|
||||
{
|
||||
if(!ok)
|
||||
{
|
||||
throw std::runtime_error("no such element");
|
||||
}
|
||||
iterator2 tmp = *this;
|
||||
iterator_base tmp = *this;
|
||||
read();
|
||||
return tmp;
|
||||
}
|
||||
|
||||
bool equals(const iterator2& a) const
|
||||
bool equals(const iterator_base& a) const
|
||||
{
|
||||
return ok == a.ok && (!ok || p == a.p);
|
||||
}
|
||||
}; // class iterator2
|
||||
}; // class iterator_base
|
||||
|
||||
} // namespace internal
|
||||
|
||||
|
|
|
@ -261,31 +261,32 @@ namespace utf8
|
|||
}
|
||||
}; // class iterator
|
||||
|
||||
//the iterator2 class
|
||||
//the iterator8 class
|
||||
template <typename octet_iterator>
|
||||
class iterator2 : public utf8::internal::iterator2<octet_iterator> {
|
||||
class iterator8 : public utf8::internal::iterator_base<octet_iterator> {
|
||||
private:
|
||||
template <typename T>
|
||||
struct N {
|
||||
uint32_t operator()(T& o, T) const {
|
||||
return utf8::unchecked::next(o);
|
||||
}
|
||||
};
|
||||
constexpr static N<octet_iterator> NEXT{};
|
||||
template <typename T>
|
||||
struct N {
|
||||
uint32_t operator()(T& o, T) const {
|
||||
return utf8::unchecked::next(o);
|
||||
}
|
||||
};
|
||||
|
||||
constexpr static N<octet_iterator> NEXT{};
|
||||
|
||||
public:
|
||||
using Base = utf8::internal::iterator2<octet_iterator>;
|
||||
iterator2 () {}
|
||||
iterator2 (octet_iterator begin, octet_iterator end): Base{begin, end, NEXT} {}
|
||||
}; // class iterator2
|
||||
using Base = utf8::internal::iterator_base<octet_iterator>;
|
||||
iterator8 () {}
|
||||
iterator8 (octet_iterator begin, octet_iterator end): Base{begin, end, NEXT} {}
|
||||
}; // class iterator8
|
||||
|
||||
template <typename octet_iterator>
|
||||
inline bool operator==(const iterator2<octet_iterator>& a, const iterator2<octet_iterator>& b)
|
||||
inline bool operator==(const iterator8<octet_iterator>& a, const iterator8<octet_iterator>& b)
|
||||
{
|
||||
return a.equals(b);
|
||||
}
|
||||
template <typename octet_iterator>
|
||||
inline bool operator!=(const iterator2<octet_iterator>& a, const iterator2<octet_iterator>& b)
|
||||
inline bool operator!=(const iterator8<octet_iterator>& a, const iterator8<octet_iterator>& b)
|
||||
{
|
||||
return !a.equals(b);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue