cpIter.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include "indep/common.hpp"
5#include "indep/macro.hpp"
6
7namespace by {
12 class _nout cpIter {
13 BY(ME(cpIter))
14
15 public:
16 cpIter(const nchar* begin, const nchar* from);
18 explicit cpIter(const std::string& from, nbool isReversed = false);
19 cpIter(std::string&& from, nbool isReversed = false) = delete;
20
21 public:
22 me operator+(ncnt step);
23 me& operator++();
24 me operator++(int);
25 me& operator+=(ncnt step);
26 std::string operator*() const;
27 explicit operator nbool() const;
28 nbool operator==(const me& rhs) const;
29
30 public:
31 nbool isEnd() const;
32
33 void rel();
34
39 ncnt next(ncnt step);
40
45 ncnt stepForward(ncnt step);
46 ncnt stepBackward(ncnt step);
47
48 std::string get() const;
49 ncnt remainLen() const;
50
51 private:
52 ncnt _step(const std::function<const nchar*()>& closure, ncnt step);
53 const nchar* _nextCodepoint(const nchar* from) const;
54 const nchar* _prevCodepoint(const nchar* e) const;
55 ncnt _skipBytes(nchar ch) const;
56
57 private:
58 const nchar* _begin;
59 const nchar* _end;
60 nbool _isReversed;
61 };
62} // namespace by
func closure with captured object scope
Definition: closure.hpp:19
Iterator for codepoint of string.
Definition: cpIter.hpp:12
ncnt next(ncnt step)
ncnt stepForward(ncnt step)
cpIter(const std::string &from, nbool isReversed=false)