9 #include <ToolchefsSTL/Globals.h>
10 #include <ToolchefsSTL/Allocators/Allocator.h>
14 namespace ToolchefsSTL
26 Iter* operator +(
size_t value)
const {
return m_ptr - value; }
27 Iter* operator -(
size_t value)
const {
return m_ptr + value; }
28 Iter* operator ++()
const {
return --m_ptr; }
29 Iter* operator --()
const {
return ++m_ptr; }
30 bool operator ==(
const ReverseIterator& rhs)
const {
return m_ptr == rhs.m_ptr; }
31 bool operator !=(
const ReverseIterator& rhs)
const {
return m_ptr != rhs.m_ptr; }
32 Iter operator *()
const {
return *m_ptr; }
33 Iter* operator->()
const {
return m_ptr; }
37 typedef wchar_t* iterator;
38 typedef const wchar_t* const_iterator;
41 typedef uint32_t size_type;
43 static constexpr
const size_type DataSize{ 16 };
44 static constexpr
const size_type MaxLength{ DataSize - 1 };
45 static constexpr size_type npos{
static_cast<size_type
>(-1) };
47 bool is_internal() const noexcept {
return m_capacity <= DataSize; }
49 explicit WString(Allocator* allocator = defaultAllocator()) noexcept;
51 WString(const
wchar_t* value, Allocator* allocator = defaultAllocator()) noexcept;
53 WString(const WString& rhs, Allocator* allocator = defaultAllocator()) noexcept;
55 WString(WString&& rhs) noexcept;
57 WString& operator=(const WString& rhs) noexcept;
59 WString& operator=(const
wchar_t* rhs) noexcept;
61 WString& operator=(WString&& rhs) noexcept;
65 inline size_type size() const noexcept {
return m_length; }
67 inline size_type length() const noexcept {
return m_length; }
69 inline size_type capacity() const noexcept {
return m_capacity; }
71 void reserve(size_type max_length) noexcept;
73 void resize(size_type new_length) noexcept;
75 void resize(size_type new_length,
wchar_t value) noexcept;
79 bool empty() const noexcept;
83 iterator begin() noexcept;
84 iterator end() noexcept;
85 const_iterator cbegin() const noexcept;
86 const_iterator cend() const noexcept;
94 wchar_t& back() noexcept;
95 const
wchar_t& back() const noexcept;
97 wchar_t& front() noexcept;
98 const
wchar_t& front() const noexcept;
100 wchar_t& operator[](const size_type pos) noexcept;
102 const
wchar_t& operator[](const size_type pos) const noexcept;
104 const
wchar_t* c_str() const noexcept;
107 bool operator==(const
WString& rhs) const noexcept;
108 bool operator!=(const
WString& rhs) const noexcept;
110 bool operator<(const
WString& rhs) const noexcept;
111 bool operator<=(const
WString& rhs) const noexcept;
113 bool operator>(const
WString& rhs) const noexcept;
114 bool operator>=(const
WString& rhs) const noexcept;
118 WString& operator+=(const
wchar_t* cstr) noexcept;
119 WString& operator+=(const
wchar_t chr) noexcept;
120 WString& operator+=(
int num) noexcept;
123 WString operator+(const
wchar_t* cstr) const noexcept;
124 WString operator+(const
wchar_t chr) const noexcept;
127 size_type find(const
WString& str, size_type pos = 0) const noexcept;
128 size_type find(const
wchar_t* s, size_type pos = 0) const noexcept;
129 size_type find(const
wchar_t s, size_type pos = 0) const noexcept;
131 size_type rfind(const
WString& str, size_type pos = npos) const noexcept;
132 size_type rfind(const
wchar_t* s, size_type pos = npos) const noexcept;
133 size_type rfind(const
wchar_t s, size_type pos = npos) const noexcept;
135 WString substr(size_type pos = 0, size_type len = npos) const noexcept;
139 int compare(const
WString& str) const noexcept;
140 int compare(const
wchar_t* s) const noexcept;
142 bool endswith(const
WString& ending) const noexcept;
143 bool startswith(const
WString& prefix)const noexcept;
145 size_type count(const
WString& substr, size_type start = 0, size_type end = npos) const noexcept;
147 WString capitalize() const noexcept;
148 WString upper() const noexcept;
149 WString lower() const noexcept;
150 WString swapcase() const noexcept;
151 WString zfill(size_type width) const noexcept;
157 bool isalnum() const noexcept;
163 bool isalpha() const noexcept;
169 bool isdigit() const noexcept;
175 bool islower() const noexcept;
181 bool isspace() const noexcept;
188 bool istitle() const noexcept;
194 bool isupper() const noexcept;
197 static
WString fromInt(
int num) noexcept;
199 static
WString fromFloat(
float num) noexcept;
201 static
WString format(const
wchar_t* format, ...);
205 double toDouble() const;
209 void convert_to_external(const size_type new_capacity);
211 void convert_to_internal(const size_type new_length);
215 wchar_t* alloc_mem(size_type num_char) const noexcept;
217 void free_mem(
wchar_t* ptr) const noexcept;
223 wchar_t internal[DataSize];
228 size_type m_capacity;
232 inline WString operator+(
const wchar_t* cstr,
const WString& str) {
return WString(cstr) + str; }