AuROXTL/Include/auROXTL/Iterators/auUTF8Iterator.hpp
2024-09-01 22:19:18 +01:00

79 lines
2.4 KiB
C++

/***
Copyright (C) 2024 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auUTF8Iterator.hpp
Date: 2024-08-31
Author: Reece
Notes: UTF8 iterator
***/
#pragma once
struct AuUTF8Iterator
{
using iterator_type = const char *;
using value_type = typename std::iterator_traits<const char *>::value_type;
using difference_type = typename std::iterator_traits<const char *>::difference_type;
using pointer = typename std::iterator_traits<const char *>::pointer;
using reference = typename std::iterator_traits<const char *>::reference;
inline constexpr AuUTF8Iterator();
inline constexpr AuUTF8Iterator(const AuUTF8Iterator &copy);
inline constexpr AuUTF8Iterator(AuUTF8Iterator &&copy);
inline constexpr AuUTF8Iterator &operator =(const AuUTF8Iterator &copy);
inline constexpr AuUTF8Iterator &operator =(AuUTF8Iterator &&move);
inline AuUTF8Iterator(const char *pStart);
inline AuUTF8Iterator(const AuROString &in, AuUInt uOffset = AuROString::npos);
cstatic AuUTF8Iterator FromStringView(AuROString in, AuUInt uOffset = AuROString::npos);
inline constexpr const char *base() const;
inline constexpr const char *Base() const;
inline constexpr AuUTF8Iterator end() const;
inline constexpr AuUTF8Iterator End() const;
inline constexpr AuOptional<AuUInt32> operator*() const;
inline constexpr pointer operator->() const;
inline constexpr AuUTF8Iterator &operator++();
inline constexpr AuUTF8Iterator operator++(int);
inline constexpr AuUTF8Iterator &operator--();
inline constexpr AuUTF8Iterator operator--(int);
inline constexpr AuUTF8Iterator operator+(const difference_type offset) const;
inline constexpr AuUTF8Iterator &operator+=(const difference_type offset);
inline constexpr AuUTF8Iterator operator-(const difference_type offset) const;
inline constexpr AuUTF8Iterator &operator-=(const difference_type offset);
inline constexpr AuOptional<AuUInt32> operator[](const difference_type offset) const;
inline constexpr friend bool operator!=(AuUTF8Iterator a, AuUTF8Iterator b)
{
return a.base() != b.base();
}
inline constexpr friend bool operator==(AuUTF8Iterator a, AuUTF8Iterator b)
{
return a.base() == b.base();
}
private:
AuROString baseView {};
const char *pCurrent {};
};