1#ifndef NEFORCE_CORE_STRING_UTF_ITERATOR_HPP__
2#define NEFORCE_CORE_STRING_UTF_ITERATOR_HPP__
13NEFORCE_BEGIN_NAMESPACE__
40 const byte_t* data_ =
nullptr;
41 size_t remaining_ = 0;
45 void decode_current() noexcept {
46 if ((data_ !=
nullptr) && remaining_ > 0) {
69 remaining_(remaining) {
90 if ((data_ !=
nullptr) && remaining_ > 0) {
92 remaining_ -= _NEFORCE
min(remaining_, consumed_);
114 if (remaining_ == 0 && other.remaining_ == 0) {
117 return data_ == other.data_ && remaining_ == other.remaining_;
144 data_(
reinterpret_cast<const byte_t*
>(sv.data())),
166NEFORCE_END_NAMESPACE__
static codepoint decode_utf8(const byte_t *data, size_t &i, size_t len) noexcept
从UTF-8字节流解码一个码点,并推进索引
static constexpr codepoint null() noexcept
构造空字符U+0000
UTF-8前向迭代器,遍历字符串中的Unicode码点
forward_iterator_tag iterator_category
迭代器类别
utf8_iterator operator++(int) noexcept
后置递增操作符
const codepoint & reference
引用类型
bool operator!=(const utf8_iterator &other) const noexcept
不等比较操作符
ptrdiff_t difference_type
差值类型
pointer operator->() const noexcept
成员访问操作符
const codepoint * pointer
指针类型
reference operator*() const noexcept
解引用操作符
bool operator==(const utf8_iterator &other) const noexcept
相等比较操作符
utf8_iterator() noexcept=default
默认构造函数,构造结束迭代器
utf8_iterator & operator++() noexcept
前置递增操作符
utf8_iterator end() const noexcept
获取结束迭代器
utf8_range(const string_view sv) noexcept
构造函数
utf8_iterator begin() const noexcept
获取起始迭代器
constexpr const T & min(const T &a, const T &b, Compare comp) noexcept(noexcept(comp(b, a)))
返回两个值中的较小者
unsigned char byte_t
字节类型,定义为无符号字符
constexpr Iterator2 move(Iterator1 first, Iterator1 last, Iterator2 result) noexcept(noexcept(inner::__move_aux(first, last, result)))
移动范围元素
basic_string_view< char > string_view
字符字符串视图
constexpr decltype(auto) size(const Container &cont) noexcept(noexcept(cont.size()))
获取容器的大小
constexpr decltype(auto) data(Container &cont) noexcept(noexcept(cont.data()))
获取容器的底层数据指针