9 #include <ToolchefsSTL/Globals.h>
10 #include <ToolchefsSTL/SSE.h>
11 #include <ToolchefsSTL/Allocators/Allocator.h>
15 namespace ToolchefsSTL
27 Iter* operator +(
size_t value)
const {
return m_ptr - value; }
28 Iter* operator -(
size_t value)
const {
return m_ptr + value; }
29 Iter* operator ++()
const {
return --m_ptr;}
30 Iter* operator --()
const {
return ++m_ptr;}
31 bool operator ==(
const ReverseIterator& rhs)
const {
return m_ptr == rhs.m_ptr; }
32 bool operator !=(
const ReverseIterator& rhs)
const {
return m_ptr != rhs.m_ptr; }
33 Iter operator *()
const {
return *m_ptr;}
34 Iter* operator->()
const {
return m_ptr;}
38 typedef char* iterator;
39 typedef const char* const_iterator;
42 typedef uint32_t size_type;
44 #if __cplusplus >= 201703L
45 static constexpr
const size_type DataSize{ 16 };
46 static constexpr
const size_type MaxLength{ DataSize - 1 };
47 static constexpr size_type npos{
static_cast<size_type
>(-1) };
49 static const size_type DataSize;
50 static const size_type MaxLength;
51 static size_type npos;
53 bool is_internal() const noexcept {
return m_capacity <= DataSize; }
55 explicit String(Allocator* allocator = defaultAllocator()) noexcept;
57 String(const
char* value, Allocator* allocator = defaultAllocator()) noexcept ;
59 String(const String& rhs, Allocator* allocator = defaultAllocator()) noexcept;
61 String(String&& rhs) noexcept;
63 String& operator=(const String& rhs) noexcept;
65 String& operator=(const
char* rhs) noexcept;
67 String& operator=(String&& rhs) noexcept;
71 inline size_type size() const noexcept {
return m_length;}
73 inline size_type length() const noexcept {
return m_length;}
75 inline size_type capacity() const noexcept {
return m_capacity; }
77 void reserve(size_type max_length) noexcept;
79 void resize(size_type new_length) noexcept;
81 void resize(size_type new_length,
char value) noexcept;
85 bool empty() const noexcept;
89 iterator begin() noexcept;
90 iterator end() noexcept;
91 const_iterator cbegin() const noexcept;
92 const_iterator cend() const noexcept;
100 char& back() noexcept;
101 const
char& back() const noexcept;
103 char& front() noexcept;
104 const
char& front() const noexcept;
106 char& operator[](const size_type pos) noexcept;
108 const
char& operator[](const size_type pos) const noexcept;
110 const
char* c_str() const noexcept;
113 bool operator==(const
String& rhs) const noexcept;
114 bool operator!=(const
String& rhs) const noexcept;
116 bool operator<(const
String& rhs) const noexcept;
117 bool operator<=(const
String& rhs) const noexcept;
119 bool operator>(const
String& rhs) const noexcept;
120 bool operator>=(const
String& rhs) const noexcept;
124 String& operator+=(const
char* cstr) noexcept;
125 String& operator+=(const
char chr) noexcept;
126 String& operator+=(
int num) noexcept;
129 String operator+(const
char* cstr) const noexcept;
130 String operator+(const
char chr) const noexcept;
133 size_type find(const
String& str, size_type pos = 0) const noexcept;
134 size_type find(const
char* s, size_type pos = 0) const noexcept;
135 size_type find(const
char s, size_type pos = 0) const noexcept;
137 size_type rfind(const
String& str, size_type pos = npos) const noexcept;
138 size_type rfind(const
char* s, size_type pos = npos) const noexcept;
139 size_type rfind(const
char s, size_type pos = npos) const noexcept;
141 String substr(size_type pos = 0, size_type len = npos) const noexcept;
145 int compare(const
String& str) const noexcept;
146 int compare(const
char* s) const noexcept;
148 bool endswith(const
String& ending) const noexcept;
149 bool startswith(const
String& prefix)const noexcept;
151 size_type count(const
String& substr, size_type start = 0, size_type end = npos) const noexcept;
153 String capitalize() const noexcept;
154 String upper() const noexcept;
155 String lower() const noexcept;
156 String swapcase() const noexcept;
157 String zfill(size_type width) const noexcept;
163 bool isalnum() const noexcept;
169 bool isalpha() const noexcept;
175 bool isdigit() const noexcept;
181 bool islower() const noexcept;
187 bool isspace() const noexcept;
194 bool istitle() const noexcept;
200 bool isupper() const noexcept;
203 static
String fromInt(
int num) noexcept;
205 static
String fromFloat(
float num) noexcept;
207 static
String format(const
char* format, ...);
211 double toDouble() const;
215 void convert_to_external(const size_type new_capacity);
217 void convert_to_internal(const size_type new_length);
221 char* alloc_mem(size_type num_char) const noexcept;
223 void free_mem(
char* ptr) const noexcept;
228 #if __cplusplus >= 201703L
229 typedef union alignas(16) __m128i {
230 char m128i_i8[DataSize];
233 typedef union alignas(16) __m128i {
246 size_type m_capacity;
247 Allocator* m_allocator;
250 inline String operator+(
const char* cstr,
const String& str) {
return String(cstr) + str; }