[+] AuUTF8Iterator
[+] AuReverseIterator [*] Move AuRONString [*] Move AuROString
This commit is contained in:
parent
c522e9bf6a
commit
52f3ca8026
694
Include/auROXTL/Iterators/auRONString.hpp
Normal file
694
Include/auROXTL/Iterators/auRONString.hpp
Normal file
@ -0,0 +1,694 @@
|
||||
/***
|
||||
Copyright (C) 2024 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: auRONString.hpp
|
||||
Date: 2024-04-30
|
||||
Author: Reece
|
||||
Notes: Null terminated read only string view
|
||||
***/
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
/* read-only, null terminated, utf-8 *byte* view */
|
||||
struct AuRONString
|
||||
{
|
||||
using traits_type = typename AuROString::traits_type;
|
||||
using value_type = typename AuROString::value_type;
|
||||
using pointer = typename AuROString::pointer;
|
||||
using const_pointer = typename AuROString::const_pointer;
|
||||
using reference = typename AuROString::reference;
|
||||
using const_reference = typename AuROString::const_reference;
|
||||
using const_iterator = typename AuROString::const_iterator;
|
||||
using iterator = const_iterator;
|
||||
using const_reverse_iterator = typename AuROString::const_reverse_iterator;
|
||||
using reverse_iterator = const_reverse_iterator;
|
||||
using size_type = typename AuROString::size_type;
|
||||
using difference_type = typename AuROString::difference_type;
|
||||
|
||||
// using basic_string_view = AuROString;
|
||||
using basic_string_view = std::basic_string_view<char>;
|
||||
|
||||
cstatic constexpr size_type npos = size_type(-1);
|
||||
|
||||
|
||||
inline AuRONString(const AuString &str) :
|
||||
view(str)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline AuRONString(const std::string &str) :
|
||||
view(str)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline AuRONString(const char *str) :
|
||||
view(str)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline constexpr const_iterator begin() const noexcept
|
||||
{
|
||||
return this->cbegin();
|
||||
}
|
||||
|
||||
inline constexpr const_iterator cbegin() const noexcept
|
||||
{
|
||||
return this->view.cbegin();
|
||||
}
|
||||
|
||||
inline constexpr const_iterator end() const noexcept
|
||||
{
|
||||
return this->cend();
|
||||
}
|
||||
|
||||
inline constexpr const_iterator cend() const noexcept
|
||||
{
|
||||
return this->cbegin() + this->length();
|
||||
}
|
||||
|
||||
inline constexpr const_reverse_iterator rbegin() const noexcept
|
||||
{
|
||||
return this->crbegin();
|
||||
}
|
||||
|
||||
inline constexpr const_reverse_iterator crbegin() const noexcept
|
||||
{
|
||||
return const_reverse_iterator(this->cend());
|
||||
}
|
||||
|
||||
inline constexpr const_reverse_iterator rend() const noexcept
|
||||
{
|
||||
return this->crend();
|
||||
}
|
||||
|
||||
inline constexpr const_reverse_iterator crend() const noexcept
|
||||
{
|
||||
return const_reverse_iterator(this->cbegin());
|
||||
}
|
||||
|
||||
inline constexpr int compare(AuROString v) const noexcept
|
||||
{
|
||||
if (size() < v.size())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int iRet = AuMemcmp(data(), v.data(), v.size());
|
||||
|
||||
if (size() > v.size() &&
|
||||
iRet == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
inline constexpr int compare(size_type pos1, size_type count1,
|
||||
AuROString v) const
|
||||
{
|
||||
return this->view.substr(pos1, count1).compare(v);
|
||||
}
|
||||
|
||||
inline constexpr int compare(size_type pos1, size_type count1, AuROString v,
|
||||
size_type pos2, size_type count2) const
|
||||
{
|
||||
return this->view.substr(pos1, count1).compare(v.substr(pos2, count2));
|
||||
}
|
||||
|
||||
inline constexpr int compare(const char *s) const
|
||||
{
|
||||
return this->compare(AuROString(s));
|
||||
}
|
||||
|
||||
inline constexpr int compare(size_type pos1, size_type count1,
|
||||
const char *s) const
|
||||
{
|
||||
return this->view.substr(pos1, count1).compare(AuROString(s));
|
||||
}
|
||||
|
||||
inline constexpr int compare(size_type pos1, size_type count1,
|
||||
const char *s, size_type count2) const
|
||||
{
|
||||
return this->view.substr(pos1, count1).compare(AuROString(s, count2));
|
||||
}
|
||||
|
||||
inline constexpr bool starts_with(AuROString sv) const noexcept
|
||||
{
|
||||
return AuStartsWith(*this, sv);
|
||||
}
|
||||
|
||||
inline constexpr bool starts_with(char ch) const noexcept
|
||||
{
|
||||
return AuStartsWith(*this, AuROString(&ch, 1));
|
||||
}
|
||||
|
||||
inline constexpr bool starts_with(const char *s) const
|
||||
{
|
||||
return AuStartsWith(*this, s);
|
||||
}
|
||||
|
||||
inline constexpr bool ends_with(AuROString sv) const noexcept
|
||||
{
|
||||
return AuEndsWith(*this, sv);
|
||||
}
|
||||
|
||||
inline constexpr bool ends_with(char ch) const noexcept
|
||||
{
|
||||
return AuEndsWith(*this, AuROString(&ch, 1));
|
||||
}
|
||||
|
||||
inline constexpr bool ends_with(const char *s) const
|
||||
{
|
||||
return AuEndsWith(*this, s);
|
||||
}
|
||||
|
||||
inline constexpr bool contains(AuROString sv) const noexcept
|
||||
{
|
||||
#if 0
|
||||
return AuCodepointsContains(*this, sv);
|
||||
#else
|
||||
return AuCodepointsFindByteOffsetUnsafe(*this, sv, 0) != AuROString::npos;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline constexpr bool contains(char c) const noexcept
|
||||
{
|
||||
return this->contains(AuROString(&c, 1));
|
||||
}
|
||||
|
||||
inline constexpr bool contains(const char *s) const
|
||||
{
|
||||
return this->contains(AuROString(s));
|
||||
}
|
||||
|
||||
inline constexpr const_reference operator[](size_type pos) const
|
||||
{
|
||||
return *(this->begin() + pos);
|
||||
}
|
||||
|
||||
inline constexpr const_reference at(size_type pos) const
|
||||
{
|
||||
return this->view.at(pos);
|
||||
}
|
||||
|
||||
inline constexpr const_reference front() const
|
||||
{
|
||||
return this->operator[](0);
|
||||
}
|
||||
|
||||
inline constexpr const_reference back() const
|
||||
{
|
||||
return this->operator[](size() - 1);
|
||||
}
|
||||
|
||||
inline constexpr const_pointer data() const noexcept
|
||||
{
|
||||
return &this->operator[](0);
|
||||
}
|
||||
|
||||
inline constexpr const_pointer c_str() const noexcept
|
||||
{
|
||||
return this->data();
|
||||
}
|
||||
|
||||
inline constexpr size_type max_size() const noexcept
|
||||
{
|
||||
return this->view.max_size();
|
||||
}
|
||||
|
||||
inline constexpr size_type size() const noexcept
|
||||
{
|
||||
return this->view.size();
|
||||
}
|
||||
|
||||
inline constexpr size_type length() const noexcept
|
||||
{
|
||||
return this->size();
|
||||
}
|
||||
|
||||
inline constexpr bool empty() const noexcept
|
||||
{
|
||||
return this->size() == 0 || !this->view.data();
|
||||
}
|
||||
|
||||
inline constexpr AuROString substr(size_type pos1, size_type count1 = npos) const noexcept
|
||||
{
|
||||
if (pos1 >= this->size())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
if (count1 == npos)
|
||||
{
|
||||
return AuROString {this->data() + pos1, this->size() - pos1 };
|
||||
}
|
||||
|
||||
if (pos1 + count1 > this->size())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
return AuROString { this->data() + pos1, count1 };
|
||||
}
|
||||
|
||||
inline constexpr size_type find(AuROString v, size_type pos = 0) const noexcept
|
||||
{
|
||||
return AuCodepointsFindByteOffsetUnsafe(*this, v, pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type find(char ch, size_type pos = 0) const noexcept
|
||||
{
|
||||
return this->find(AuROString(&ch, 1), pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type find(const char *s, size_type pos, size_type count) const
|
||||
{
|
||||
return this->find(AuROString(s, count), pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type find(const char *s, size_type pos = 0) const
|
||||
{
|
||||
return this->find(AuROString(s), pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type rfind(AuROString v, size_type pos = npos) const noexcept
|
||||
{
|
||||
return this->view.rfind(v, pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type rfind(char ch, size_type pos = npos) const noexcept
|
||||
{
|
||||
return this->find(AuROString(&ch, 1), pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type rfind(const char *s, size_type pos, size_type count) const
|
||||
{
|
||||
return this->rfind(AuROString(s, count), pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type rfind(const char *s, size_type pos = npos) const
|
||||
{
|
||||
return this->rfind(AuROString(s), pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_first_not_of(AuROString right, const size_type offset = 0) const noexcept
|
||||
{
|
||||
return this->view.find_first_not_of(right, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_last_not_of(AuROString right, const size_type offset = npos) const noexcept
|
||||
{
|
||||
return this->view.find_last_not_of(right, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_last_of(AuROString right, const size_type offset = npos) const noexcept
|
||||
{
|
||||
return this->view.find_last_of(right, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_first_of(AuROString right, const size_type offset = 0) const noexcept
|
||||
{
|
||||
if (right.size() == 0)
|
||||
{
|
||||
return npos;
|
||||
}
|
||||
|
||||
return this->find(right, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_first_of(const char c, const size_type offset = 0) const noexcept
|
||||
{
|
||||
return this->find_first_of(AuROString(&c, 1), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_first_of(const char *const s, const size_type offset, const size_type count) const
|
||||
{
|
||||
return this->find_first_of(AuROString(s, count), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_first_of(const char *const s, const size_type offset = 0) const
|
||||
{
|
||||
return this->find_first_of(AuROString(s), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_last_of(const char c, const size_type offset = npos) const noexcept
|
||||
{
|
||||
return this->find_last_of(AuROString(&c, 1), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_last_of(const char *const s, const size_type offset, const size_type count) const
|
||||
{
|
||||
return this->find_last_of(AuROString(s, count), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_last_of(const char *const s, const size_type offset = npos) const
|
||||
{
|
||||
return this->find_last_of(AuROString(s), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_first_not_of(const char c, const size_type offset = 0) const noexcept
|
||||
{
|
||||
return this->find_first_not_of(AuROString(&c, 1), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_first_not_of(const char *const s, const size_type offset, const size_type count) const
|
||||
{
|
||||
return this->find_first_not_of(AuROString(s, count), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_first_not_of(const char *const s, const size_type offset = 0) const
|
||||
{
|
||||
return this->find_first_not_of(AuROString(s), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_last_not_of(const char c, const size_type offset = npos) const noexcept
|
||||
{
|
||||
return this->find_last_not_of(AuROString(&c, 1), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_last_not_of(const char *const s, const size_type offset, const size_type count) const
|
||||
{
|
||||
return this->find_last_not_of(AuROString(s, count), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_last_not_of(const char *const s, const size_type offset = npos) const
|
||||
{
|
||||
return this->find_last_not_of(AuROString(s), offset);
|
||||
}
|
||||
|
||||
inline constexpr operator AuROString() const
|
||||
{
|
||||
return this->view;
|
||||
}
|
||||
|
||||
inline operator bool() const
|
||||
{
|
||||
return this->view;
|
||||
}
|
||||
|
||||
inline constexpr const_iterator Begin() const noexcept
|
||||
{
|
||||
return this->begin();
|
||||
}
|
||||
|
||||
inline constexpr const_iterator CBegin() const noexcept
|
||||
{
|
||||
return this->cbegin();
|
||||
}
|
||||
|
||||
inline constexpr const_iterator End() const noexcept
|
||||
{
|
||||
return this->end();
|
||||
}
|
||||
|
||||
inline constexpr const_iterator CEnd() const noexcept
|
||||
{
|
||||
return this->cend();
|
||||
}
|
||||
|
||||
inline constexpr const_reverse_iterator RBegin() const noexcept
|
||||
{
|
||||
return this->rbegin();
|
||||
}
|
||||
|
||||
inline constexpr const_reverse_iterator CRBegin() const noexcept
|
||||
{
|
||||
return this->crbegin();
|
||||
}
|
||||
|
||||
inline constexpr const_reverse_iterator REnd() const noexcept
|
||||
{
|
||||
return this->rend();
|
||||
}
|
||||
|
||||
inline constexpr const_reverse_iterator CREnd() const noexcept
|
||||
{
|
||||
return this->crend();
|
||||
}
|
||||
|
||||
inline constexpr AuROString Substr(size_type pos1, size_type count1 = npos) const noexcept
|
||||
{
|
||||
return this->substr(pos1, count1);
|
||||
}
|
||||
|
||||
inline constexpr AuROString SubStr(size_type pos1, size_type count1 = npos) const noexcept
|
||||
{
|
||||
return this->substr(pos1, count1);
|
||||
}
|
||||
|
||||
inline constexpr int Compare(AuROString v) const noexcept
|
||||
{
|
||||
return this->compare(v);
|
||||
}
|
||||
|
||||
inline constexpr int Compare(const AuROString &v) const noexcept
|
||||
{
|
||||
return this->compare(v);
|
||||
}
|
||||
|
||||
inline constexpr int Compare(size_type pos1, size_type count1,
|
||||
AuROString v) const
|
||||
{
|
||||
return this->compare(pos1, count1, v);
|
||||
}
|
||||
|
||||
inline constexpr int Compare(size_type pos1, size_type count1, AuROString v,
|
||||
size_type pos2, size_type count2) const
|
||||
{
|
||||
return this->compare(pos1, count1, v, pos2, count2);
|
||||
}
|
||||
|
||||
inline constexpr int Compare(const char *s) const
|
||||
{
|
||||
return this->compare(s);
|
||||
}
|
||||
|
||||
inline constexpr int Compare(size_type pos1, size_type count1,
|
||||
const char *s) const
|
||||
{
|
||||
return this->compare(pos1, count1, s);
|
||||
}
|
||||
|
||||
inline constexpr int Compare(size_type pos1, size_type count1,
|
||||
const char *s, size_type count2) const
|
||||
{
|
||||
return this->compare(pos1, count1, s, count2);
|
||||
}
|
||||
|
||||
inline constexpr bool StartsWith(AuROString sv) const noexcept
|
||||
{
|
||||
return this->starts_with(sv);
|
||||
}
|
||||
|
||||
inline constexpr bool StartsWith(char ch) const noexcept
|
||||
{
|
||||
return this->starts_with(ch);
|
||||
}
|
||||
|
||||
inline constexpr bool StartsWith(const char *s) const
|
||||
{
|
||||
return this->starts_with(s);
|
||||
}
|
||||
|
||||
inline constexpr bool EndsWith(AuROString sv) const noexcept
|
||||
{
|
||||
return this->ends_with(sv);
|
||||
}
|
||||
|
||||
inline constexpr bool EndsWith(char ch) const noexcept
|
||||
{
|
||||
return this->ends_with(ch);
|
||||
}
|
||||
|
||||
inline constexpr bool EndsWith(const char *s) const
|
||||
{
|
||||
return this->ends_with(s);
|
||||
}
|
||||
|
||||
inline constexpr bool Contains(AuROString sv) const noexcept
|
||||
{
|
||||
return this->contains(sv);
|
||||
}
|
||||
|
||||
inline constexpr bool Contains(char C) const noexcept
|
||||
{
|
||||
return this->contains(C);
|
||||
}
|
||||
|
||||
inline constexpr bool Contains(const char *s) const
|
||||
{
|
||||
return this->contains(s);
|
||||
}
|
||||
|
||||
inline constexpr const_reference At(size_type pos) const
|
||||
{
|
||||
return this->at(pos);
|
||||
}
|
||||
|
||||
inline constexpr const_reference Front() const
|
||||
{
|
||||
return this->front();
|
||||
}
|
||||
|
||||
inline constexpr const_reference Back() const
|
||||
{
|
||||
return this->back();
|
||||
}
|
||||
|
||||
inline constexpr const_pointer Data() const noexcept
|
||||
{
|
||||
return this->data();
|
||||
}
|
||||
|
||||
inline constexpr const_pointer CStr() const noexcept
|
||||
{
|
||||
return this->c_str();
|
||||
}
|
||||
|
||||
inline constexpr size_type MaxSize() const noexcept
|
||||
{
|
||||
return this->max_size();
|
||||
}
|
||||
|
||||
inline constexpr size_type Size() const noexcept
|
||||
{
|
||||
return this->size();
|
||||
}
|
||||
|
||||
inline constexpr size_type Length() const noexcept
|
||||
{
|
||||
return this->length();
|
||||
}
|
||||
|
||||
inline constexpr bool Empty() const noexcept
|
||||
{
|
||||
return this->empty();
|
||||
}
|
||||
|
||||
inline constexpr size_type Find(AuROString v, size_type pos = 0) const noexcept
|
||||
{
|
||||
return this->find(v, pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type Find(char ch, size_type pos = 0) const noexcept
|
||||
{
|
||||
return this->find(ch, pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type Find(const char *s, size_type pos, size_type count) const
|
||||
{
|
||||
return this->find(s, pos, count);
|
||||
}
|
||||
|
||||
inline constexpr size_type Find(const char *s, size_type pos = 0) const
|
||||
{
|
||||
return this->find(s, pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type RFind(AuROString v, size_type pos = npos) const noexcept
|
||||
{
|
||||
return this->rfind(v, pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type RFind(char ch, size_type pos = npos) const noexcept
|
||||
{
|
||||
return this->rfind(ch, pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type Rfind(const char *s, size_type pos, size_type count) const
|
||||
{
|
||||
return this->rfind(s, pos, count);
|
||||
}
|
||||
|
||||
inline constexpr size_type Rfind(const char *s, size_type pos = npos) const
|
||||
{
|
||||
return this->rfind(s, pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindFirstNotOf(const AuROString right, const size_type offset = 0) const noexcept
|
||||
{
|
||||
return this->find_first_not_of(right, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindLastNotOf(const AuROString right, const size_type offset = npos) const noexcept
|
||||
{
|
||||
return this->find_last_not_of(right, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindLastOf(const AuROString right, const size_type offset = npos) const noexcept
|
||||
{
|
||||
return this->find_last_of(right, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindFirstOf(const AuROString right, const size_type offset = 0) const noexcept
|
||||
{
|
||||
return this->find_first_of(right, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type Find_first_of(const char c, const size_type offset = 0) const noexcept
|
||||
{
|
||||
return this->find_first_of(c, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindFirstOf(const char *const s, const size_type offset, const size_type count) const
|
||||
{
|
||||
return this->find_first_of(s, offset, count);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindFirstOf(const char *const s, const size_type offset = 0) const
|
||||
{
|
||||
return this->find_first_of(s, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindLastOf(const char c, const size_type offset = npos) const noexcept
|
||||
{
|
||||
return this->find_last_of(c, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindLastOf(const char *const s, const size_type offset, const size_type count) const
|
||||
{
|
||||
return this->find_last_of(s, offset, count);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindLastOf(const char *const s, const size_type offset = npos) const
|
||||
{
|
||||
return this->find_last_of(s, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindFirstNotOf(const char c, const size_type offset = 0) const noexcept
|
||||
{
|
||||
return this->find_first_not_of(c, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindFirstNotOf(const char *const s, const size_type offset, const size_type count) const
|
||||
{
|
||||
return this->find_first_not_of(s, offset, count);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindFirstNotOf(const char *const s, const size_type offset = 0) const
|
||||
{
|
||||
return this->find_first_not_of(s, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindLastNotOf(const char c, const size_type offset = npos) const noexcept
|
||||
{
|
||||
return this->find_last_not_of(c, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindLastNotOf(const char *const s, const size_type offset, const size_type count) const
|
||||
{
|
||||
return this->find_last_not_of(s, offset, count);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindLastNotOf(const char *const s, const size_type offset = npos) const
|
||||
{
|
||||
return this->find_last_not_of(s, offset);
|
||||
}
|
||||
private:
|
||||
AuROString view;
|
||||
};
|
790
Include/auROXTL/Iterators/auROString.hpp
Normal file
790
Include/auROXTL/Iterators/auROString.hpp
Normal file
@ -0,0 +1,790 @@
|
||||
/***
|
||||
Copyright (C) 2024 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: auROString.hpp
|
||||
Date: 2024-04-19
|
||||
Author: Reece
|
||||
Notes: Null terminated read only string view
|
||||
***/
|
||||
#pragma once
|
||||
|
||||
/* read-only, null terminated, utf-8 *byte* view */
|
||||
struct AuROString
|
||||
{
|
||||
// using basic_string_view = AuROString;
|
||||
using basic_string_view = std::basic_string_view<char>;
|
||||
|
||||
using traits_type = typename basic_string_view::traits_type;
|
||||
|
||||
using value_type = char;
|
||||
using pointer = char *;
|
||||
using const_pointer = const char *;
|
||||
using reference = char &;
|
||||
using const_reference = const char &;
|
||||
using const_iterator = const char *;
|
||||
using iterator = char *;
|
||||
using const_reverse_iterator = typename std::reverse_iterator<const char *>;
|
||||
using reverse_iterator = typename std::reverse_iterator<char *>;
|
||||
using size_type = AuUInt;
|
||||
using difference_type = AuSInt;
|
||||
|
||||
cstatic constexpr size_type npos = size_type(-1);
|
||||
|
||||
inline constexpr AuROString()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AU_COPY_MOVE(AuROString);
|
||||
|
||||
inline constexpr AuROString(const AuString &str) :
|
||||
pPointer(str.data()),
|
||||
uLength(str.length())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline constexpr AuROString(const std::string &str) :
|
||||
pPointer(str.data()),
|
||||
uLength(str.length())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline constexpr AuROString(const char *str) :
|
||||
pPointer(str),
|
||||
uLength(traits_type::length(str))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline constexpr AuROString(const char *str,
|
||||
AuUInt uLength) :
|
||||
pPointer(str),
|
||||
uLength(uLength)
|
||||
{
|
||||
|
||||
}
|
||||
inline constexpr AuROString(const char *str,
|
||||
const char *strEnd) :
|
||||
pPointer(str),
|
||||
uLength(strEnd - str)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline constexpr AuROString(basic_string_view strView) :
|
||||
pPointer(strView.data()),
|
||||
uLength(strView.size())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline constexpr const_iterator begin() const noexcept
|
||||
{
|
||||
return this->cbegin();
|
||||
}
|
||||
|
||||
inline constexpr const_iterator cbegin() const noexcept
|
||||
{
|
||||
return this->pPointer;
|
||||
}
|
||||
|
||||
inline constexpr const_iterator end() const noexcept
|
||||
{
|
||||
return this->cend();
|
||||
}
|
||||
|
||||
inline constexpr const_iterator cend() const noexcept
|
||||
{
|
||||
return this->cbegin() + this->length();
|
||||
}
|
||||
|
||||
inline constexpr const_reverse_iterator rbegin() const noexcept
|
||||
{
|
||||
return this->crbegin();
|
||||
}
|
||||
|
||||
inline constexpr const_reverse_iterator crbegin() const noexcept
|
||||
{
|
||||
return const_reverse_iterator(this->cend());
|
||||
}
|
||||
|
||||
inline constexpr const_reverse_iterator rend() const noexcept
|
||||
{
|
||||
return this->crend();
|
||||
}
|
||||
|
||||
inline constexpr const_reverse_iterator crend() const noexcept
|
||||
{
|
||||
return const_reverse_iterator(this->cbegin());
|
||||
}
|
||||
|
||||
inline constexpr AuROString substr(size_type pos1, size_type count1 = npos) const noexcept
|
||||
{
|
||||
if (pos1 >= this->uLength)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
if (count1 == npos)
|
||||
{
|
||||
return AuROString {this->pPointer + pos1, this->uLength - pos1 };
|
||||
}
|
||||
|
||||
if (pos1 + count1 > this->uLength)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
return AuROString { this->pPointer + pos1, count1 };
|
||||
}
|
||||
|
||||
inline constexpr void stl_remove_suffix(size_type n)
|
||||
{
|
||||
if (this->uLength < n)
|
||||
{
|
||||
*this = AuROString { };
|
||||
}
|
||||
else
|
||||
{
|
||||
*this = AuROString { this->pPointer, this->uLength - n };
|
||||
}
|
||||
}
|
||||
|
||||
inline constexpr void stl_remove_prefix(size_type n)
|
||||
{
|
||||
if (this->uLength < n)
|
||||
{
|
||||
*this = AuROString { };
|
||||
}
|
||||
else
|
||||
{
|
||||
*this = AuROString { this->pPointer + n, this->uLength - n };
|
||||
}
|
||||
}
|
||||
|
||||
inline constexpr AuROString remove_suffix(size_type n) const
|
||||
{
|
||||
if (this->uLength < n)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
return AuROString { this->pPointer, this->uLength - n };
|
||||
}
|
||||
|
||||
inline constexpr AuROString remove_prefix(size_type n) const
|
||||
{
|
||||
if (this->uLength < n)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
return AuROString { this->pPointer + n, this->uLength - n };
|
||||
}
|
||||
|
||||
inline constexpr AuROString RemoveSuffix(size_type n) const
|
||||
{
|
||||
return remove_suffix(n);
|
||||
}
|
||||
|
||||
inline constexpr AuROString RemovePrefix(size_type n) const
|
||||
{
|
||||
return remove_prefix(n);
|
||||
}
|
||||
|
||||
inline constexpr int compare(basic_string_view v) const noexcept
|
||||
{
|
||||
if (size() < v.size())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int iRet = AuMemcmp(data(), v.data(), v.size());
|
||||
|
||||
if (size() > v.size() &&
|
||||
iRet == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
inline constexpr int compare(const AuROString &v) const noexcept
|
||||
{
|
||||
if (size() < v.size())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int iRet = AuMemcmp(data(), v.data(), v.size());
|
||||
|
||||
if (size() > v.size() &&
|
||||
iRet == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
inline constexpr int compare(size_type pos1, size_type count1,
|
||||
AuROString v) const
|
||||
{
|
||||
return this->substr(pos1, count1).compare(v);
|
||||
}
|
||||
|
||||
inline constexpr int compare(size_type pos1, size_type count1, AuROString v,
|
||||
size_type pos2, size_type count2) const
|
||||
{
|
||||
return this->substr(pos1, count1).compare(v.substr(pos2, count2));
|
||||
}
|
||||
|
||||
inline constexpr int compare(const char *s) const
|
||||
{
|
||||
return this->compare(AuROString(s));
|
||||
}
|
||||
|
||||
inline constexpr int compare(size_type pos1, size_type count1,
|
||||
const char *s) const
|
||||
{
|
||||
return this->substr(pos1, count1).compare(AuROString(s));
|
||||
}
|
||||
|
||||
inline constexpr int compare(size_type pos1, size_type count1,
|
||||
const char *s, size_type count2) const
|
||||
{
|
||||
return this->substr(pos1, count1).compare(AuROString(s, count2));
|
||||
}
|
||||
|
||||
inline constexpr bool starts_with(AuROString sv) const noexcept
|
||||
{
|
||||
return AuStartsWith(*this, sv);
|
||||
}
|
||||
|
||||
inline constexpr bool starts_with(char ch) const noexcept
|
||||
{
|
||||
return AuStartsWith(*this, AuROString(&ch, 1));
|
||||
}
|
||||
|
||||
inline constexpr bool starts_with(const char *s) const
|
||||
{
|
||||
return AuStartsWith(*this, s);
|
||||
}
|
||||
|
||||
inline constexpr bool ends_with(AuROString sv) const noexcept
|
||||
{
|
||||
return AuEndsWith(*this, sv);
|
||||
}
|
||||
|
||||
inline constexpr bool ends_with(char ch) const noexcept
|
||||
{
|
||||
return AuEndsWith(*this, AuROString(&ch, 1));
|
||||
}
|
||||
|
||||
inline constexpr bool ends_with(const char *s) const
|
||||
{
|
||||
return AuEndsWith(*this, s);
|
||||
}
|
||||
|
||||
inline constexpr bool contains(AuROString sv) const noexcept
|
||||
{
|
||||
#if 0
|
||||
return AuCodepointsContains(*this, sv);
|
||||
#else
|
||||
return AuCodepointsFindByteOffsetUnsafe(*this, sv, 0) != AuROString::npos;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline constexpr bool contains(char c) const noexcept
|
||||
{
|
||||
return this->contains(AuROString(&c, 1));
|
||||
}
|
||||
|
||||
inline constexpr bool contains(const char *s) const
|
||||
{
|
||||
return this->contains(AuROString(s));
|
||||
}
|
||||
|
||||
inline constexpr const_reference operator[](size_type pos) const
|
||||
{
|
||||
return *(this->begin() + pos);
|
||||
}
|
||||
|
||||
inline constexpr const_reference at(size_type pos) const
|
||||
{
|
||||
return this->pPointer[pos];
|
||||
}
|
||||
|
||||
inline constexpr const_reference front() const
|
||||
{
|
||||
return this->operator[](0);
|
||||
}
|
||||
|
||||
inline constexpr const_reference back() const
|
||||
{
|
||||
return this->operator[](size() - 1);
|
||||
}
|
||||
|
||||
inline constexpr const_pointer data() const noexcept
|
||||
{
|
||||
return &this->operator[](0);
|
||||
}
|
||||
|
||||
inline constexpr size_type max_size() const noexcept
|
||||
{
|
||||
return SIZE_MAX;
|
||||
//return AuNumericLimits<AuSInt>().max();
|
||||
}
|
||||
|
||||
inline constexpr size_type size() const noexcept
|
||||
{
|
||||
return this->uLength;
|
||||
}
|
||||
|
||||
inline constexpr size_type length() const noexcept
|
||||
{
|
||||
return this->size();
|
||||
}
|
||||
|
||||
inline constexpr bool empty() const noexcept
|
||||
{
|
||||
return this->size() == 0 || !this->pPointer;
|
||||
}
|
||||
|
||||
inline constexpr size_type find(AuROString v, size_type pos = 0) const noexcept
|
||||
{
|
||||
return AuCodepointsFindByteOffsetUnsafe(*this, v, pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type find(char ch, size_type pos = 0) const noexcept
|
||||
{
|
||||
return this->find(AuROString(&ch, 1), pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type find(const char *s, size_type pos, size_type count) const
|
||||
{
|
||||
return this->find(AuROString(s, count), pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type find(const char *s, size_type pos = 0) const
|
||||
{
|
||||
return this->find(AuROString(s), pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type rfind(AuROString v, size_type pos = npos) const noexcept
|
||||
{
|
||||
return basic_string_view(*this).rfind(basic_string_view { v }, pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type rfind(char ch, size_type pos = npos) const noexcept
|
||||
{
|
||||
return this->find(AuROString(&ch, 1), pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type rfind(const char *s, size_type pos, size_type count) const
|
||||
{
|
||||
return this->rfind(AuROString(s, count), pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type rfind(const char *s, size_type pos = npos) const
|
||||
{
|
||||
return this->rfind(AuROString(s), pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_first_not_of(const AuROString right, const size_type offset = 0) const noexcept
|
||||
{
|
||||
return basic_string_view(*this).find_first_not_of(basic_string_view { right }, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_last_not_of(const AuROString right, const size_type offset = npos) const noexcept
|
||||
{
|
||||
return basic_string_view(*this).find_last_not_of(basic_string_view { right }, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_last_of(const AuROString right, const size_type offset = npos) const noexcept
|
||||
{
|
||||
return basic_string_view(*this).find_last_of(basic_string_view { right }, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_first_of(const AuROString right, const size_type offset = 0) const noexcept
|
||||
{
|
||||
if (right.size() == 0)
|
||||
{
|
||||
return npos;
|
||||
}
|
||||
|
||||
return this->find(right, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_first_of(const char c, const size_type offset = 0) const noexcept
|
||||
{
|
||||
return this->find_first_of(AuROString(&c, 1), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_first_of(const char *const s, const size_type offset, const size_type count) const
|
||||
{
|
||||
return this->find_first_of(AuROString(s, count), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_first_of(const char *const s, const size_type offset = 0) const
|
||||
{
|
||||
return this->find_first_of(AuROString(s), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_last_of(const char c, const size_type offset = npos) const noexcept
|
||||
{
|
||||
return this->find_last_of(AuROString(&c, 1), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_last_of(const char *const s, const size_type offset, const size_type count) const
|
||||
{
|
||||
return this->find_last_of(AuROString(s, count), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_last_of(const char *const s, const size_type offset = npos) const
|
||||
{
|
||||
return this->find_last_of(AuROString(s), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_first_not_of(const char c, const size_type offset = 0) const noexcept
|
||||
{
|
||||
return this->find_first_not_of(AuROString(&c, 1), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_first_not_of(const char *const s, const size_type offset, const size_type count) const
|
||||
{
|
||||
return this->find_first_not_of(AuROString(s, count), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_first_not_of(const char *const s, const size_type offset = 0) const
|
||||
{
|
||||
return this->find_first_not_of(AuROString(s), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_last_not_of(const char c, const size_type offset = npos) const noexcept
|
||||
{
|
||||
return this->find_last_not_of(AuROString(&c, 1), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_last_not_of(const char *const s, const size_type offset, const size_type count) const
|
||||
{
|
||||
return this->find_last_not_of(AuROString(s, count), offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type find_last_not_of(const char *const s, const size_type offset = npos) const
|
||||
{
|
||||
return this->find_last_not_of(AuROString(s), offset);
|
||||
}
|
||||
|
||||
inline constexpr operator std::string_view() const
|
||||
{
|
||||
return std::string_view { pPointer, uLength };
|
||||
}
|
||||
|
||||
inline constexpr const_iterator Begin() const noexcept
|
||||
{
|
||||
return this->begin();
|
||||
}
|
||||
|
||||
inline constexpr const_iterator CBegin() const noexcept
|
||||
{
|
||||
return this->cbegin();
|
||||
}
|
||||
|
||||
inline constexpr const_iterator End() const noexcept
|
||||
{
|
||||
return this->end();
|
||||
}
|
||||
|
||||
inline constexpr const_iterator CEnd() const noexcept
|
||||
{
|
||||
return this->cend();
|
||||
}
|
||||
|
||||
inline constexpr const_reverse_iterator RBegin() const noexcept
|
||||
{
|
||||
return this->rbegin();
|
||||
}
|
||||
|
||||
inline constexpr const_reverse_iterator CRBegin() const noexcept
|
||||
{
|
||||
return this->crbegin();
|
||||
}
|
||||
|
||||
inline constexpr const_reverse_iterator REnd() const noexcept
|
||||
{
|
||||
return this->rend();
|
||||
}
|
||||
|
||||
inline constexpr const_reverse_iterator CREnd() const noexcept
|
||||
{
|
||||
return this->crend();
|
||||
}
|
||||
|
||||
inline constexpr AuROString Substr(size_type pos1, size_type count1 = npos) const noexcept
|
||||
{
|
||||
return this->substr(pos1, count1);
|
||||
}
|
||||
|
||||
inline constexpr AuROString SubStr(size_type pos1, size_type count1 = npos) const noexcept
|
||||
{
|
||||
return this->substr(pos1, count1);
|
||||
}
|
||||
|
||||
inline constexpr int Compare(basic_string_view v) const noexcept
|
||||
{
|
||||
return this->compare(v);
|
||||
}
|
||||
|
||||
inline constexpr int Compare(const AuROString &v) const noexcept
|
||||
{
|
||||
return this->compare(v);
|
||||
}
|
||||
|
||||
inline constexpr int Compare(size_type pos1, size_type count1,
|
||||
AuROString v) const
|
||||
{
|
||||
return this->compare(pos1, count1, v);
|
||||
}
|
||||
|
||||
inline constexpr int Compare(size_type pos1, size_type count1, AuROString v,
|
||||
size_type pos2, size_type count2) const
|
||||
{
|
||||
return this->compare(pos1, count1, v, pos2, count2);
|
||||
}
|
||||
|
||||
inline constexpr int Compare(const char *s) const
|
||||
{
|
||||
return this->compare(s);
|
||||
}
|
||||
|
||||
inline constexpr int Compare(size_type pos1, size_type count1,
|
||||
const char *s) const
|
||||
{
|
||||
return this->compare(pos1, count1, s);
|
||||
}
|
||||
|
||||
inline constexpr int Compare(size_type pos1, size_type count1,
|
||||
const char *s, size_type count2) const
|
||||
{
|
||||
return this->compare(pos1, count1, s, count2);
|
||||
}
|
||||
|
||||
inline constexpr bool StartsWith(AuROString sv) const noexcept
|
||||
{
|
||||
return this->starts_with(sv);
|
||||
}
|
||||
|
||||
inline constexpr bool StartsWith(char ch) const noexcept
|
||||
{
|
||||
return this->starts_with(ch);
|
||||
}
|
||||
|
||||
inline constexpr bool StartsWith(const char *s) const
|
||||
{
|
||||
return this->starts_with(s);
|
||||
}
|
||||
|
||||
inline constexpr bool EndsWith(AuROString sv) const noexcept
|
||||
{
|
||||
return this->ends_with(sv);
|
||||
}
|
||||
|
||||
inline constexpr bool EndsWith(char ch) const noexcept
|
||||
{
|
||||
return this->ends_with(ch);
|
||||
}
|
||||
|
||||
inline constexpr bool EndsWith(const char *s) const
|
||||
{
|
||||
return this->ends_with(s);
|
||||
}
|
||||
|
||||
inline constexpr bool Contains(AuROString sv) const noexcept
|
||||
{
|
||||
return this->contains(sv);
|
||||
}
|
||||
|
||||
inline constexpr bool Contains(char C) const noexcept
|
||||
{
|
||||
return this->contains(C);
|
||||
}
|
||||
|
||||
inline constexpr bool Contains(const char *s) const
|
||||
{
|
||||
return this->contains(s);
|
||||
}
|
||||
|
||||
inline constexpr const_reference At(size_type pos) const
|
||||
{
|
||||
return this->at(pos);
|
||||
}
|
||||
|
||||
inline constexpr const_reference Front() const
|
||||
{
|
||||
return this->front();
|
||||
}
|
||||
|
||||
inline constexpr const_reference Back() const
|
||||
{
|
||||
return this->back();
|
||||
}
|
||||
|
||||
inline constexpr const_pointer Data() const noexcept
|
||||
{
|
||||
return this->data();
|
||||
}
|
||||
|
||||
inline constexpr size_type MaxSize() const noexcept
|
||||
{
|
||||
return this->max_size();
|
||||
}
|
||||
|
||||
inline constexpr size_type Size() const noexcept
|
||||
{
|
||||
return this->size();
|
||||
}
|
||||
|
||||
inline constexpr size_type Length() const noexcept
|
||||
{
|
||||
return this->length();
|
||||
}
|
||||
|
||||
inline constexpr bool Empty() const noexcept
|
||||
{
|
||||
return this->empty();
|
||||
}
|
||||
|
||||
inline constexpr size_type Find(AuROString v, size_type pos = 0) const noexcept
|
||||
{
|
||||
return this->find(v, pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type Find(char ch, size_type pos = 0) const noexcept
|
||||
{
|
||||
return this->find(ch, pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type Find(const char *s, size_type pos, size_type count) const
|
||||
{
|
||||
return this->find(s, pos, count);
|
||||
}
|
||||
|
||||
inline constexpr size_type Find(const char *s, size_type pos = 0) const
|
||||
{
|
||||
return this->find(s, pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type RFind(AuROString v, size_type pos = npos) const noexcept
|
||||
{
|
||||
return this->rfind(v, pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type RFind(char ch, size_type pos = npos) const noexcept
|
||||
{
|
||||
return this->rfind(ch, pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type Rfind(const char *s, size_type pos, size_type count) const
|
||||
{
|
||||
return this->rfind(s, pos, count);
|
||||
}
|
||||
|
||||
inline constexpr size_type Rfind(const char *s, size_type pos = npos) const
|
||||
{
|
||||
return this->rfind(s, pos);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindFirstNotOf(const AuROString right, const size_type offset = 0) const noexcept
|
||||
{
|
||||
return this->find_first_not_of(right, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindLastNotOf(const AuROString right, const size_type offset = npos) const noexcept
|
||||
{
|
||||
return this->find_last_not_of(right, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindLastOf(const AuROString right, const size_type offset = npos) const noexcept
|
||||
{
|
||||
return this->find_last_of(right, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindFirstOf(const AuROString right, const size_type offset = 0) const noexcept
|
||||
{
|
||||
return this->find_first_of(right, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type Find_first_of(const char c, const size_type offset = 0) const noexcept
|
||||
{
|
||||
return this->find_first_of(c, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindFirstOf(const char *const s, const size_type offset, const size_type count) const
|
||||
{
|
||||
return this->find_first_of(s, offset, count);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindFirstOf(const char *const s, const size_type offset = 0) const
|
||||
{
|
||||
return this->find_first_of(s, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindLastOf(const char c, const size_type offset = npos) const noexcept
|
||||
{
|
||||
return this->find_last_of(c, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindLastOf(const char *const s, const size_type offset, const size_type count) const
|
||||
{
|
||||
return this->find_last_of(s, offset, count);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindLastOf(const char *const s, const size_type offset = npos) const
|
||||
{
|
||||
return this->find_last_of(s, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindFirstNotOf(const char c, const size_type offset = 0) const noexcept
|
||||
{
|
||||
return this->find_first_not_of(c, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindFirstNotOf(const char *const s, const size_type offset, const size_type count) const
|
||||
{
|
||||
return this->find_first_not_of(s, offset, count);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindFirstNotOf(const char *const s, const size_type offset = 0) const
|
||||
{
|
||||
return this->find_first_not_of(s, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindLastNotOf(const char c, const size_type offset = npos) const noexcept
|
||||
{
|
||||
return this->find_last_not_of(c, offset);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindLastNotOf(const char *const s, const size_type offset, const size_type count) const
|
||||
{
|
||||
return this->find_last_not_of(s, offset, count);
|
||||
}
|
||||
|
||||
inline constexpr size_type FindLastNotOf(const char *const s, const size_type offset = npos) const
|
||||
{
|
||||
return this->find_last_not_of(s, offset);
|
||||
}
|
||||
|
||||
inline operator bool() const
|
||||
{
|
||||
return this->pPointer &&
|
||||
this->uLength;
|
||||
}
|
||||
|
||||
private:
|
||||
const char *pPointer {};
|
||||
AuUInt uLength {};
|
||||
};
|
71
Include/auROXTL/Iterators/auReverseIterator.hpp
Normal file
71
Include/auROXTL/Iterators/auReverseIterator.hpp
Normal file
@ -0,0 +1,71 @@
|
||||
/***
|
||||
Copyright (C) 2024 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: auReverseIterator.hpp
|
||||
Date: 2024-08-31
|
||||
Author: Reece
|
||||
***/
|
||||
#pragma once
|
||||
|
||||
template<typename Iterator>
|
||||
struct AuReverseIterator
|
||||
{
|
||||
using iterator_type = Iterator;
|
||||
|
||||
using iterator_category = std::iterator_traits<Iterator>;
|
||||
using value_type = typename std::iterator_traits<Iterator>::value_type;
|
||||
using difference_type = typename std::iterator_traits<Iterator>::difference_type;
|
||||
using pointer = typename std::iterator_traits<Iterator>::pointer;
|
||||
using reference = typename std::iterator_traits<Iterator>::reference;
|
||||
|
||||
template <class>
|
||||
friend struct AuReverseIterator;
|
||||
|
||||
constexpr AuReverseIterator() = default;
|
||||
|
||||
constexpr explicit AuReverseIterator(Iterator that);
|
||||
|
||||
template<typename Other_t>
|
||||
constexpr AuReverseIterator(const AuReverseIterator<Other_t> &that);
|
||||
|
||||
template <class Other_t>
|
||||
constexpr AuReverseIterator &operator=(const AuReverseIterator<Other_t> &that);
|
||||
|
||||
constexpr Iterator base() const;
|
||||
constexpr Iterator Base() const;
|
||||
|
||||
constexpr reference operator*() const;
|
||||
|
||||
constexpr pointer operator->() const;
|
||||
|
||||
constexpr AuReverseIterator &operator++();
|
||||
|
||||
constexpr AuReverseIterator operator++(int);
|
||||
|
||||
constexpr AuReverseIterator &operator--();
|
||||
|
||||
constexpr AuReverseIterator operator--(int);
|
||||
|
||||
constexpr AuReverseIterator operator+(const difference_type offset) const;
|
||||
|
||||
constexpr AuReverseIterator &operator+=(const difference_type offset);
|
||||
|
||||
constexpr AuReverseIterator operator-(const difference_type offset) const;
|
||||
|
||||
constexpr AuReverseIterator &operator-=(const difference_type offset);
|
||||
|
||||
constexpr reference operator[](const difference_type offset) const;
|
||||
|
||||
constexpr friend bool operator!=(AuReverseIterator<Iterator> a, AuReverseIterator<Iterator> b)
|
||||
{
|
||||
return a.base() != b.base();
|
||||
}
|
||||
|
||||
constexpr friend bool operator==(AuReverseIterator<Iterator> a, AuReverseIterator<Iterator> b)
|
||||
{
|
||||
return a.base() == b.base();
|
||||
}
|
||||
|
||||
protected:
|
||||
Iterator iterator;
|
||||
};
|
122
Include/auROXTL/Iterators/auReverseIterator.ipp
Normal file
122
Include/auROXTL/Iterators/auReverseIterator.ipp
Normal file
@ -0,0 +1,122 @@
|
||||
/***
|
||||
Copyright (C) 2024 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: auReverseIterator.ipp
|
||||
Date: 2024-08-31
|
||||
Author: Reece
|
||||
***/
|
||||
#pragma once
|
||||
|
||||
template<typename Iterator>
|
||||
constexpr AuReverseIterator<Iterator>::AuReverseIterator(Iterator that)
|
||||
: iterator(AuMove(that))
|
||||
{ }
|
||||
|
||||
template<typename Iterator>
|
||||
template<typename Other_t>
|
||||
constexpr AuReverseIterator<Iterator>::AuReverseIterator(const AuReverseIterator<Other_t> &that) :
|
||||
iterator(that.iterator)
|
||||
{ }
|
||||
|
||||
template<typename Iterator>
|
||||
template<class Other_t>
|
||||
constexpr AuReverseIterator<Iterator> &AuReverseIterator<Iterator>::operator=(const AuReverseIterator<Other_t> &that)
|
||||
{
|
||||
iterator = that.iterator;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
constexpr Iterator AuReverseIterator<Iterator>::base() const
|
||||
{
|
||||
return iterator;
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
constexpr Iterator AuReverseIterator<Iterator>::Base() const
|
||||
{
|
||||
return iterator;
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
constexpr AuReverseIterator<Iterator>::reference AuReverseIterator<Iterator>::operator*() const
|
||||
{
|
||||
Iterator ret = iterator;
|
||||
return *--ret;
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
constexpr AuReverseIterator<Iterator>::pointer AuReverseIterator<Iterator>::operator->() const
|
||||
{
|
||||
Iterator ret = iterator;
|
||||
--ret;
|
||||
if constexpr (AuIsPointer_v<Iterator>)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ret.operator->();
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
constexpr AuReverseIterator<Iterator> &AuReverseIterator<Iterator>::operator++()
|
||||
{
|
||||
--iterator;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
constexpr AuReverseIterator<Iterator> AuReverseIterator<Iterator>::operator++(int)
|
||||
{
|
||||
AuReverseIterator ret = *this;
|
||||
--iterator;
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
constexpr AuReverseIterator<Iterator> &AuReverseIterator<Iterator>::operator--()
|
||||
{
|
||||
++iterator;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
constexpr AuReverseIterator<Iterator> AuReverseIterator<Iterator>::operator--(int)
|
||||
{
|
||||
AuReverseIterator ret = *this;
|
||||
++iterator;
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
constexpr AuReverseIterator<Iterator> AuReverseIterator<Iterator>::operator+(const difference_type offset) const
|
||||
{
|
||||
return AuReverseIterator(iterator - offset);
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
constexpr AuReverseIterator<Iterator> &AuReverseIterator<Iterator>::operator+=(const difference_type offset)
|
||||
{
|
||||
iterator -= offset;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
constexpr AuReverseIterator<Iterator> AuReverseIterator<Iterator>::operator-(const difference_type offset) const
|
||||
{
|
||||
return AuReverseIterator(iterator + offset);
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
constexpr AuReverseIterator<Iterator> &AuReverseIterator<Iterator>::operator-=(const difference_type offset)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
constexpr AuReverseIterator<Iterator>::reference AuReverseIterator<Iterator>::operator[](const difference_type offset) const
|
||||
{
|
||||
return iterator[static_cast<difference_type>(-offset - 1)];
|
||||
}
|
80
Include/auROXTL/Iterators/auUTF8Iterator.hpp
Normal file
80
Include/auROXTL/Iterators/auUTF8Iterator.hpp
Normal file
@ -0,0 +1,80 @@
|
||||
/***
|
||||
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 ©);
|
||||
|
||||
inline constexpr AuUTF8Iterator(AuUTF8Iterator &©);
|
||||
|
||||
inline constexpr AuUTF8Iterator &operator =(const AuUTF8Iterator ©);
|
||||
|
||||
inline constexpr AuUTF8Iterator &operator =(AuUTF8Iterator &&move);
|
||||
|
||||
inline AuUTF8Iterator(const char *pStart);
|
||||
|
||||
inline AuUTF8Iterator(const AuROString &in, AuUInt uOffset = AuROString::npos);
|
||||
|
||||
inline AuUTF8Iterator(const AuROString &in);
|
||||
|
||||
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 {};
|
||||
};
|
289
Include/auROXTL/Iterators/auUTF8Iterator.ipp
Normal file
289
Include/auROXTL/Iterators/auUTF8Iterator.ipp
Normal file
@ -0,0 +1,289 @@
|
||||
/***
|
||||
Copyright (C) 2024 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: auUTF8Iterator.ipp
|
||||
Date: 2024-08-31
|
||||
Author: Reece
|
||||
Notes: UTF8 iterator
|
||||
***/
|
||||
#pragma once
|
||||
|
||||
inline constexpr AuUTF8Iterator::AuUTF8Iterator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline constexpr AuUTF8Iterator::AuUTF8Iterator(const AuUTF8Iterator ©) :
|
||||
baseView(copy.baseView),
|
||||
pCurrent(copy.pCurrent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline constexpr AuUTF8Iterator::AuUTF8Iterator(AuUTF8Iterator &©) :
|
||||
baseView(copy.baseView),
|
||||
pCurrent(copy.pCurrent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline constexpr AuUTF8Iterator &AuUTF8Iterator::operator =(const AuUTF8Iterator ©)
|
||||
{
|
||||
this->baseView = copy.baseView;
|
||||
this->baseView = copy.pCurrent;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline constexpr AuUTF8Iterator &AuUTF8Iterator::operator =(AuUTF8Iterator &&move)
|
||||
{
|
||||
this->baseView = move.baseView;
|
||||
this->pCurrent = move.pCurrent;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline AuUTF8Iterator::AuUTF8Iterator(const char *pStart)
|
||||
{
|
||||
this->baseView = pStart;
|
||||
this->pCurrent = pStart;
|
||||
}
|
||||
|
||||
inline AuUTF8Iterator::AuUTF8Iterator(const AuROString &in, AuUInt uOffset)
|
||||
{
|
||||
this->baseView = in;
|
||||
this->pCurrent = in.Begin();
|
||||
|
||||
if (uOffset != AuROString::npos)
|
||||
{
|
||||
auto out = AuCodepointsGetByteOffset(in, uOffset);
|
||||
if (out != AuROString::npos)
|
||||
{
|
||||
this->pCurrent += out;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->pCurrent = in.End();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline AuUTF8Iterator::AuUTF8Iterator(const AuROString &in)
|
||||
{
|
||||
this->baseView = in;
|
||||
this->pCurrent = in.Begin();
|
||||
}
|
||||
|
||||
AuUTF8Iterator AuUTF8Iterator::FromStringView(AuROString in, AuUInt uOffset)
|
||||
{
|
||||
return AuUTF8Iterator(in, uOffset);
|
||||
}
|
||||
|
||||
inline constexpr const char *AuUTF8Iterator::base() const
|
||||
{
|
||||
return this->pCurrent;
|
||||
}
|
||||
|
||||
inline constexpr const char *AuUTF8Iterator::Base() const
|
||||
{
|
||||
return this->pCurrent;
|
||||
}
|
||||
|
||||
inline constexpr AuUTF8Iterator AuUTF8Iterator::end() const
|
||||
{
|
||||
AuUTF8Iterator ret;
|
||||
ret.baseView = this->baseView;
|
||||
ret.pCurrent = this->baseView.End();
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline constexpr AuUTF8Iterator AuUTF8Iterator::End() const
|
||||
{
|
||||
AuUTF8Iterator ret;
|
||||
ret.baseView = this->baseView;
|
||||
ret.pCurrent = this->baseView.End();
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline constexpr AuOptional<AuUInt32> AuUTF8Iterator::operator*() const
|
||||
{
|
||||
auto pBegin = this->baseView.Begin();
|
||||
auto uDiff = this->pCurrent - pBegin;
|
||||
auto uLength = this->baseView.Length();
|
||||
|
||||
if (uLength == uDiff)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
auto pNext = pBegin + uDiff;
|
||||
auto uNext = uLength - uDiff;
|
||||
|
||||
return AuCodepointsDecodeOne(AuROString(pNext, uNext));
|
||||
}
|
||||
|
||||
inline constexpr AuUTF8Iterator::pointer AuUTF8Iterator::operator->() const
|
||||
{
|
||||
return this->base();
|
||||
}
|
||||
|
||||
inline constexpr AuUTF8Iterator &AuUTF8Iterator::operator++()
|
||||
{
|
||||
auto pBegin = this->baseView.Begin();
|
||||
auto uDiff = this->pCurrent - pBegin;
|
||||
auto uLength = this->baseView.Length();
|
||||
|
||||
if (uLength == uDiff)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto pNext = pBegin + uDiff;
|
||||
auto uNext = uLength - uDiff;
|
||||
|
||||
if (auto uCount = AuCodepointsNextLength(AuROString(pNext, uNext)))
|
||||
{
|
||||
this->pCurrent += uCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
*this = this->End();
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline constexpr AuUTF8Iterator AuUTF8Iterator::operator++(int)
|
||||
{
|
||||
AuUTF8Iterator ret = *this;
|
||||
++ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline constexpr AuUTF8Iterator &AuUTF8Iterator::operator--()
|
||||
{
|
||||
auto pBegin = this->baseView.Begin();
|
||||
auto uDiff = this->pCurrent - pBegin;
|
||||
auto uLength = this->baseView.Length();
|
||||
|
||||
if (uLength == uDiff)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
{
|
||||
auto uOffset = AuCodepointsFindPreviousValidByteOffsetFromByteOffset(this->baseView, uDiff);
|
||||
if (uOffset != AuString::npos)
|
||||
{
|
||||
this->pCurrent = pBegin + uOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->pCurrent = pBegin;
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline constexpr AuUTF8Iterator AuUTF8Iterator::operator--(int)
|
||||
{
|
||||
AuUTF8Iterator ret = *this;
|
||||
--ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline constexpr AuUTF8Iterator AuUTF8Iterator::operator+(const difference_type offset) const
|
||||
{
|
||||
AuUTF8Iterator copy = *this;
|
||||
copy += offset;
|
||||
return copy;
|
||||
}
|
||||
|
||||
inline constexpr AuUTF8Iterator &AuUTF8Iterator::operator+=(const difference_type offset)
|
||||
{
|
||||
auto pBegin = this->baseView.Begin();
|
||||
auto uDiff = this->pCurrent - pBegin;
|
||||
auto uLength = this->baseView.Length();
|
||||
|
||||
if (uLength == uDiff ||
|
||||
offset == 0)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (offset < 0)
|
||||
{
|
||||
(*this)-= 0 - offset;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto pNext = pBegin + uDiff;
|
||||
auto uNext = uLength - uDiff;
|
||||
|
||||
for (AU_ITERATE_N(i, offset))
|
||||
{
|
||||
if (auto uCount = AuCodepointsNextLength(AuROString(pNext, uNext)))
|
||||
{
|
||||
pNext += uCount;
|
||||
uNext -= uCount;
|
||||
this->pCurrent += uCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
*this = this->End();
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline constexpr AuUTF8Iterator AuUTF8Iterator::operator-(const difference_type offset) const
|
||||
{
|
||||
AuUTF8Iterator copy = *this;
|
||||
copy -= offset;
|
||||
return copy;
|
||||
}
|
||||
|
||||
inline constexpr AuUTF8Iterator &AuUTF8Iterator::operator-=(const difference_type offset)
|
||||
{
|
||||
auto pBegin = this->baseView.Begin();
|
||||
auto uDiff = this->pCurrent - pBegin;
|
||||
auto uLength = this->baseView.Length();
|
||||
|
||||
if (uLength == uDiff ||
|
||||
offset == 0)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (offset < 0)
|
||||
{
|
||||
(*this)+= 0 - offset;
|
||||
return *this;
|
||||
}
|
||||
|
||||
for (AU_ITERATE_N(i, offset))
|
||||
{
|
||||
auto uOffset = AuCodepointsFindPreviousValidByteOffsetFromByteOffset(this->baseView, uDiff);
|
||||
if (uOffset != AuString::npos)
|
||||
{
|
||||
this->pCurrent = pBegin + uOffset;
|
||||
uDiff = uOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->pCurrent = pBegin;
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline constexpr AuOptional<AuUInt32> AuUTF8Iterator::operator[](const difference_type offset) const
|
||||
{
|
||||
auto ret = *this;
|
||||
ret += offset;
|
||||
return *ret;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -38,6 +38,7 @@
|
||||
#include <auROXTL/auTryConstruct.hpp>
|
||||
#include <auROXTL/auTryCall.hpp>
|
||||
#include <auROXTL/auTemplateMeta.hpp>
|
||||
#include <auROXTL/Iterators/auReverseIterator.hpp>
|
||||
|
||||
// TODO: move to header
|
||||
// this needs to be after template mater and before containers and optional
|
||||
@ -169,6 +170,7 @@ namespace __audetail
|
||||
#include <auROXTL/auArrayList.hpp>
|
||||
#include <auROXTL/auOptional.hpp>
|
||||
#include <auROXTL/auOptionalEx.hpp>
|
||||
#include <auROXTL/Iterators/auUTF8Iterator.hpp>
|
||||
|
||||
namespace Aurora::Memory
|
||||
{
|
||||
|
@ -34,6 +34,8 @@
|
||||
#include <auROXTL/auContainerUtils.hpp>
|
||||
#include <auROXTL/auListUtils.hpp>
|
||||
#include <auROXTL/auStringUtils.hpp>
|
||||
#include <auROXTL/Iterators/auUTF8Iterator.ipp>
|
||||
#include <auROXTL/Iterators/auReverseIterator.ipp>
|
||||
#include <auROXTL/auTupleUtils.hpp>
|
||||
#include <auROXTL/auNumberUtils.hpp>
|
||||
#include <auROXTL/auEndianness.hpp>
|
||||
|
Loading…
Reference in New Issue
Block a user