From dd275a6865cdb7f5a8f87cbaceaac486b7e58b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Prost=20Fr=C3=A9d=C3=A9ric?= Date: Wed, 23 Oct 2019 22:25:41 +0200 Subject: [PATCH] change name : iterator2 becomes iterator8. iterator8 base class name is now iterator_base --- source/utf8/checked.h | 22 +++++++++++----------- source/utf8/core.h | 22 +++++++++++----------- source/utf8/unchecked.h | 31 ++++++++++++++++--------------- 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/source/utf8/checked.h b/source/utf8/checked.h index 247147d..13c8ac0 100644 --- a/source/utf8/checked.h +++ b/source/utf8/checked.h @@ -318,25 +318,25 @@ namespace utf8 } }; // class iterator - //the iterator2 class + //the iterator8 class template - class iterator2 : public utf8::internal::iterator2 { - + class iterator8 : public utf8::internal::iterator_base { + public: - using Base = utf8::internal::iterator2; - iterator2 () {} - iterator2 (octet_iterator begin, octet_iterator end): Base{begin, end, utf8::next} {} - }; // class iterator2 + using Base = utf8::internal::iterator_base; + iterator8 () {} + iterator8 (octet_iterator begin, octet_iterator end): Base{begin, end, utf8::next} {} + }; // class iterator8 template - inline bool operator==(const iterator2& a, const iterator2& b) + inline bool operator==(const iterator8& a, const iterator8& b) { - return a.equals(b); + return a.equals(b); } template - inline bool operator!=(const iterator2& a, const iterator2& b) + inline bool operator!=(const iterator8& a, const iterator8& b) { - return !a.equals(b); + return !a.equals(b); } } // namespace utf8 diff --git a/source/utf8/core.h b/source/utf8/core.h index bb3de60..940e6fc 100644 --- a/source/utf8/core.h +++ b/source/utf8/core.h @@ -298,17 +298,17 @@ namespace internal return utf8::internal::validate_next(it, end, ignored); } - //the iterator2 class + //the iterator_base class template - class iterator2 : public std::iterator { - public: + class iterator_base : public std::iterator { + protected: using function = std::function; 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 diff --git a/source/utf8/unchecked.h b/source/utf8/unchecked.h index b88d287..6f9ad70 100644 --- a/source/utf8/unchecked.h +++ b/source/utf8/unchecked.h @@ -261,31 +261,32 @@ namespace utf8 } }; // class iterator - //the iterator2 class + //the iterator8 class template - class iterator2 : public utf8::internal::iterator2 { + class iterator8 : public utf8::internal::iterator_base { private: - template - struct N { - uint32_t operator()(T& o, T) const { - return utf8::unchecked::next(o); - } - }; - constexpr static N NEXT{}; + template + struct N { + uint32_t operator()(T& o, T) const { + return utf8::unchecked::next(o); + } + }; + + constexpr static N NEXT{}; public: - using Base = utf8::internal::iterator2; - iterator2 () {} - iterator2 (octet_iterator begin, octet_iterator end): Base{begin, end, NEXT} {} - }; // class iterator2 + using Base = utf8::internal::iterator_base; + iterator8 () {} + iterator8 (octet_iterator begin, octet_iterator end): Base{begin, end, NEXT} {} + }; // class iterator8 template - inline bool operator==(const iterator2& a, const iterator2& b) + inline bool operator==(const iterator8& a, const iterator8& b) { return a.equals(b); } template - inline bool operator!=(const iterator2& a, const iterator2& b) + inline bool operator!=(const iterator8& a, const iterator8& b) { return !a.equals(b); }