TGUI  0.8.6
String.hpp
1 //
3 // TGUI - Texus' Graphical User Interface
4 // Copyright (C) 2012-2019 Bruno Van de Velde (vdv_b@tgui.eu)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 
26 #ifndef TGUI_STRING_HPP
27 #define TGUI_STRING_HPP
28 
29 #include <TGUI/Config.hpp>
30 #include <string>
31 #include <cstring>
32 #include <locale>
33 
34 #include <SFML/System/String.hpp>
35 
37 
38 namespace tgui
39 {
43  TGUI_API bool isWhitespace(char character);
44 
45 
49 #ifdef TGUI_NEXT
50  TGUI_API bool isWhitespace(char32_t character);
51 #else
52  TGUI_API bool isWhitespace(sf::Uint32 character);
53 #endif
54 
61  TGUI_API int strToInt(const std::string& str, int defaultValue = 0);
62 
63 
70  TGUI_API unsigned int strToUInt(const std::string& str, unsigned int defaultValue = 0);
71 
72 
79  TGUI_API float strToFloat(const std::string& str, float defaultValue = 0);
80 
81 
85  TGUI_API std::string toLower(const std::string& str);
86 
87 
91  TGUI_API std::string toUpper(const std::string& str);
92 
93 
97  TGUI_API std::string trim(const std::string& str);
98 
99 
115  class TGUI_API String
116  {
117  private:
118  std::u32string m_string;
119 
120  public:
121 
122  static const decltype(std::u32string::npos) npos;
123 
124  using iterator = std::u32string::iterator;
125  using const_iterator = std::u32string::const_iterator;
126  using reverse_iterator = std::u32string::reverse_iterator;
127  using const_reverse_iterator = std::u32string::const_reverse_iterator;
128 
129  using value_type = char32_t;
130  using reference = char32_t&;
131  using const_reference = const char32_t&;
132 
133 
134  public:
135 
143  int toInt(int defaultValue = 0) const;
144 
145 
153  float toFloat(float defaultValue = 0) const;
154 
155 
161  String trim() const;
162 
163 
169  String toLower() const;
170 
171 
177  String toUpper() const;
178 
179 #ifdef TGUI_NEXT // Code not working on GCC 4.9
180  String& replace(const String& searchFor, const String& replaceWith);
189 #endif
190 
191  public:
192 
193  String() = default;
194 
195  String(const std::string& str);
196  String(const std::wstring& str);
197  String(const std::u16string& str);
198  String(const std::u32string& str);
199 
200  String(std::u32string&& str)
201  : m_string{std::move(str)}
202  {
203  }
204 
205  String(char ansiChar, const std::locale& locale = std::locale());
206  String(wchar_t wideChar);
207  String(char16_t utfChar);
208  String(char32_t utfChar);
209 
210  String(const char* str);
211  String(const wchar_t* str);
212  String(const char16_t* str);
213  String(const char32_t* str);
214 
215  String(std::size_t count, char ch);
216  String(std::size_t count, wchar_t ch);
217  String(std::size_t count, char16_t ch);
218  String(std::size_t count, char32_t ch);
219 
220  String(const std::string& str, std::size_t pos);
221  String(const std::wstring& str, std::size_t pos);
222  String(const std::u16string& str, std::size_t pos);
223  String(const std::u32string& str, std::size_t pos);
224 
225  String(const std::string& str, std::size_t pos, std::size_t count);
226  String(const std::wstring& str, std::size_t pos, std::size_t count);
227  String(const std::u16string& str, std::size_t pos, std::size_t count);
228  String(const std::u32string& str, std::size_t pos, std::size_t count);
229 
230  String(const char* str, std::size_t count);
231  String(const wchar_t* str, std::size_t count);
232  String(const char16_t* str, std::size_t count);
233  String(const char32_t* str, std::size_t count);
234 
235  String(std::initializer_list<char> chars);
236  String(std::initializer_list<wchar_t> chars);
237  String(std::initializer_list<char16_t> chars);
238  String(std::initializer_list<char32_t> chars);
239 
240  String(std::string::const_iterator first, std::string::const_iterator last);
241  String(std::wstring::const_iterator first, std::wstring::const_iterator last);
242  String(std::u16string::const_iterator first, std::u16string::const_iterator last);
243  String(std::u32string::const_iterator first, std::u32string::const_iterator last);
244 
245  explicit String(const sf::String& str)
246  : m_string{reinterpret_cast<const char32_t*>(str.toUtf32().c_str())}
247  {
248  }
249 
250  explicit operator sf::String() const
251  {
252  return sf::String::fromUtf32(m_string.begin(), m_string.end());
253  }
254 
255  operator std::string() const;
256  operator std::wstring() const;
257  operator std::u16string() const;
258  operator const std::u32string&() const
259  {
260  return m_string;
261  }
262 
263  std::string asAnsiString() const;
264  std::wstring asWideString() const;
265  std::u16string asUtf16() const;
266  const std::u32string& asUtf32() const;
267 
268  String& assign(std::size_t count, char ch);
269  String& assign(std::size_t count, wchar_t ch);
270  String& assign(std::size_t count, char16_t ch);
271  String& assign(std::size_t count, char32_t ch);
272 
273  String& assign(const std::string& str);
274  String& assign(const std::wstring& str);
275  String& assign(const std::u16string& str);
276  String& assign(const std::u32string& str);
277  String& assign(const String& str);
278 
279  String& assign(const std::string& str, std::size_t pos, std::size_t count = npos);
280  String& assign(const std::wstring& str, std::size_t pos, std::size_t count = npos);
281  String& assign(const std::u16string& str, std::size_t pos, std::size_t count = npos);
282  String& assign(const std::u32string& str, std::size_t pos, std::size_t count = npos);
283  String& assign(const String& str, std::size_t pos, std::size_t count = npos);
284 
285  String& assign(std::string&& str);
286  String& assign(std::wstring&& str);
287  String& assign(std::u16string&& str);
288  String& assign(std::u32string&& str);
289  String& assign(String&& str);
290 
291  String& assign(const char* str, std::size_t count);
292  String& assign(const wchar_t* str, std::size_t count);
293  String& assign(const char16_t* str, std::size_t count);
294  String& assign(const char32_t* str, std::size_t count);
295 
296  String& assign(const char* str);
297  String& assign(const wchar_t* str);
298  String& assign(const char16_t* str);
299  String& assign(const char32_t* str);
300 
301  String& assign(std::initializer_list<char> chars);
302  String& assign(std::initializer_list<wchar_t> chars);
303  String& assign(std::initializer_list<char16_t> chars);
304  String& assign(std::initializer_list<char32_t> chars);
305 
306  String& assign(std::string::const_iterator first, std::string::const_iterator last);
307  String& assign(std::wstring::const_iterator first, std::wstring::const_iterator last);
308  String& assign(std::u16string::const_iterator first, std::u16string::const_iterator last);
309  String& assign(std::u32string::const_iterator first, std::u32string::const_iterator last);
310 
311  reference at(std::size_t pos);
312  const_reference at(std::size_t pos) const;
313 
314  const_reference operator [](std::size_t index) const;
315  reference operator [](std::size_t index);
316 
317  reference front();
318  const_reference front() const;
319 
320  reference back();
321  const_reference back() const;
322 
323  const char32_t* data() const noexcept;
324 #if __cplusplus >= 201703L
325  char32_t* data() noexcept
326  {
327  return m_string.data();
328  }
329 #endif
330  const char32_t* c_str() const noexcept;
331 
332  iterator begin() noexcept;
333  const_iterator begin() const noexcept;
334  const_iterator cbegin() const noexcept;
335 
336  iterator end() noexcept;
337  const_iterator end() const noexcept;
338  const_iterator cend() const noexcept;
339 
340  reverse_iterator rbegin() noexcept;
341  const_reverse_iterator rbegin() const noexcept;
342  const_reverse_iterator crbegin() const noexcept;
343 
344  reverse_iterator rend() noexcept;
345  const_reverse_iterator rend() const noexcept;
346  const_reverse_iterator crend() const noexcept;
347 
348  bool empty() const noexcept;
349  std::size_t size() const noexcept;
350  std::size_t length() const noexcept;
351  std::size_t max_size() const noexcept;
352 
353  void reserve(std::size_t newCap);
354  std::size_t capacity() const noexcept;
355  void shrink_to_fit();
356 
357  void clear() noexcept;
358 #ifdef TGUI_NEXT // Code not working on GCC 4.9
359  String& insert(std::size_t index, std::size_t count, char ch);
360  String& insert(std::size_t index, std::size_t count, wchar_t ch);
361  String& insert(std::size_t index, std::size_t count, char16_t ch);
362  String& insert(std::size_t index, std::size_t count, char32_t ch);
363 
364  String& insert(std::size_t index, const std::string& str);
365  String& insert(std::size_t index, const std::wstring& str);
366  String& insert(std::size_t index, const std::u16string& str);
367  String& insert(std::size_t index, const std::u32string& str);
368  String& insert(std::size_t index, const String& str);
369 
370  String& insert(std::size_t index, const std::string& str, std::size_t pos, std::size_t count = npos);
371  String& insert(std::size_t index, const std::wstring& str, std::size_t pos, std::size_t count = npos);
372  String& insert(std::size_t index, const std::u16string& str, std::size_t pos, std::size_t count = npos);
373  String& insert(std::size_t index, const std::u32string& str, std::size_t pos, std::size_t count = npos);
374  String& insert(std::size_t index, const String& str, std::size_t pos, std::size_t count = npos);
375 
376  String& insert(std::size_t index, const char* str, std::size_t count);
377  String& insert(std::size_t index, const wchar_t* str, std::size_t count);
378  String& insert(std::size_t index, const char16_t* str, std::size_t count);
379  String& insert(std::size_t index, const char32_t* str, std::size_t count);
380 
381  String& insert(std::size_t index, const char* str);
382  String& insert(std::size_t index, const wchar_t* str);
383  String& insert(std::size_t index, const char16_t* str);
384  String& insert(std::size_t index, const char32_t* str);
385 
386  iterator insert(const_iterator pos, char ch);
387  iterator insert(const_iterator pos, wchar_t ch);
388  iterator insert(const_iterator pos, char16_t ch);
389  iterator insert(const_iterator pos, char32_t ch);
390 
391  iterator insert(const_iterator pos, std::size_t count, char ch);
392  iterator insert(const_iterator pos, std::size_t count, wchar_t ch);
393  iterator insert(const_iterator pos, std::size_t count, char16_t ch);
394  iterator insert(const_iterator pos, std::size_t count, char32_t ch);
395 
396  iterator insert(const_iterator pos, std::initializer_list<char> chars);
397  iterator insert(const_iterator pos, std::initializer_list<wchar_t> chars);
398  iterator insert(const_iterator pos, std::initializer_list<char16_t> chars);
399  iterator insert(const_iterator pos, std::initializer_list<char32_t> chars);
400 
401  iterator insert(const_iterator pos, std::string::const_iterator first, std::string::const_iterator last);
402  iterator insert(const_iterator pos, std::wstring::const_iterator first, std::wstring::const_iterator last);
403  iterator insert(const_iterator pos, std::u16string::const_iterator first, std::u16string::const_iterator last);
404  iterator insert(const_iterator pos, std::u32string::const_iterator first, std::u32string::const_iterator last);
405 
406  String& erase(std::size_t index = 0, std::size_t count = npos);
407 
408  iterator erase(const_iterator position);
409  iterator erase(const_iterator first, const_iterator last);
410 #endif
411  void push_back(char ch);
412  void push_back(wchar_t ch);
413  void push_back(char16_t ch);
414  void push_back(char32_t ch);
415 
416  void pop_back();
417 
418  String& append(std::size_t count, char ch);
419  String& append(std::size_t count, wchar_t ch);
420  String& append(std::size_t count, char16_t ch);
421  String& append(std::size_t count, char32_t ch);
422 
423  String& append(const std::string& str);
424  String& append(const std::wstring& str);
425  String& append(const std::u16string& str);
426  String& append(const std::u32string& str);
427  String& append(const String& str);
428 
429  String& append(const std::string& str, std::size_t pos, std::size_t count = npos);
430  String& append(const std::wstring& str, std::size_t pos, std::size_t count = npos);
431  String& append(const std::u16string& str, std::size_t pos, std::size_t count = npos);
432  String& append(const std::u32string& str, std::size_t pos, std::size_t count = npos);
433  String& append(const String& str, std::size_t pos, std::size_t count = npos);
434 
435  String& append(const char* str, std::size_t count);
436  String& append(const wchar_t* str, std::size_t count);
437  String& append(const char16_t* str, std::size_t count);
438  String& append(const char32_t* str, std::size_t count);
439 
440  String& append(const char* str);
441  String& append(const wchar_t* str);
442  String& append(const char16_t* str);
443  String& append(const char32_t* str);
444 
445  String& append(std::string::const_iterator first, std::string::const_iterator last);
446  String& append(std::wstring::const_iterator first, std::wstring::const_iterator last);
447  String& append(std::u16string::const_iterator first, std::u16string::const_iterator last);
448  String& append(std::u32string::const_iterator first, std::u32string::const_iterator last);
449 
450  String& append(std::initializer_list<char> chars);
451  String& append(std::initializer_list<wchar_t> chars);
452  String& append(std::initializer_list<char16_t> chars);
453  String& append(std::initializer_list<char32_t> chars);
454 
455  String& operator+=(const String& str);
456 
457  int compare(const std::string& str) const noexcept;
458  int compare(const std::wstring& str) const noexcept;
459  int compare(const std::u16string& str) const noexcept;
460  int compare(const std::u32string& str) const noexcept;
461  int compare(const String& str) const noexcept;
462 
463  int compare(std::size_t pos1, std::size_t count1, const std::string& str) const;
464  int compare(std::size_t pos1, std::size_t count1, const std::wstring& str) const;
465  int compare(std::size_t pos1, std::size_t count1, const std::u16string& str) const;
466  int compare(std::size_t pos1, std::size_t count1, const std::u32string& str) const;
467  int compare(std::size_t pos1, std::size_t count1, const String& str) const;
468 
469  int compare(std::size_t pos1, std::size_t count1, const std::string& str, std::size_t pos2, std::size_t count2 = npos) const;
470  int compare(std::size_t pos1, std::size_t count1, const std::wstring& str, std::size_t pos2, std::size_t count2 = npos) const;
471  int compare(std::size_t pos1, std::size_t count1, const std::u16string& str, std::size_t pos2, std::size_t count2 = npos) const;
472  int compare(std::size_t pos1, std::size_t count1, const std::u32string& str, std::size_t pos2, std::size_t count2 = npos) const;
473  int compare(std::size_t pos1, std::size_t count1, const String& str, std::size_t pos2, std::size_t count2 = npos) const;
474 
475  int compare(const char* s) const;
476  int compare(const wchar_t* s) const;
477  int compare(const char16_t* s) const;
478  int compare(const char32_t* s) const;
479 
480  int compare(std::size_t pos1, std::size_t count1, const char* s) const;
481  int compare(std::size_t pos1, std::size_t count1, const wchar_t* s) const;
482  int compare(std::size_t pos1, std::size_t count1, const char16_t* s) const;
483  int compare(std::size_t pos1, std::size_t count1, const char32_t* s) const;
484 
485  int compare(std::size_t pos1, std::size_t count1, const char* s, std::size_t count2) const;
486  int compare(std::size_t pos1, std::size_t count1, const wchar_t* s, std::size_t count2) const;
487  int compare(std::size_t pos1, std::size_t count1, const char16_t* s, std::size_t count2) const;
488  int compare(std::size_t pos1, std::size_t count1, const char32_t* s, std::size_t count2) const;
489 #ifdef TGUI_NEXT // Code not working on GCC 4.9
490  String& replace(std::size_t pos, std::size_t count, const std::string& str);
491  String& replace(std::size_t pos, std::size_t count, const std::wstring& str);
492  String& replace(std::size_t pos, std::size_t count, const std::u16string& str);
493  String& replace(std::size_t pos, std::size_t count, const std::u32string& str);
494  String& replace(std::size_t pos, std::size_t count, const String& str);
495 
496  String& replace(const_iterator first, const_iterator last, const std::string& str);
497  String& replace(const_iterator first, const_iterator last, const std::wstring& str);
498  String& replace(const_iterator first, const_iterator last, const std::u16string& str);
499  String& replace(const_iterator first, const_iterator last, const std::u32string& str);
500  String& replace(const_iterator first, const_iterator last, const String& str);
501 
502  String& replace(std::size_t pos, std::size_t count, const std::string& str, std::size_t pos2, std::size_t count2 = npos);
503  String& replace(std::size_t pos, std::size_t count, const std::wstring& str, std::size_t pos2, std::size_t count2 = npos);
504  String& replace(std::size_t pos, std::size_t count, const std::u16string& str, std::size_t pos2, std::size_t count2 = npos);
505  String& replace(std::size_t pos, std::size_t count, const std::u32string& str, std::size_t pos2, std::size_t count2 = npos);
506  String& replace(std::size_t pos, std::size_t count, const String& str, std::size_t pos2, std::size_t count2 = npos);
507 
508  String& replace(const_iterator first, const_iterator last, std::string::const_iterator first2, std::string::const_iterator last2);
509  String& replace(const_iterator first, const_iterator last, std::wstring::const_iterator first2, std::wstring::const_iterator last2);
510  String& replace(const_iterator first, const_iterator last, std::u16string::const_iterator first2, std::u16string::const_iterator last2);
511  String& replace(const_iterator first, const_iterator last, std::u32string::const_iterator first2, std::u32string::const_iterator last2);
512 
513  String& replace(std::size_t pos, std::size_t count, const char* cstr, std::size_t count2);
514  String& replace(std::size_t pos, std::size_t count, const wchar_t* cstr, std::size_t count2);
515  String& replace(std::size_t pos, std::size_t count, const char16_t* cstr, std::size_t count2);
516  String& replace(std::size_t pos, std::size_t count, const char32_t* cstr, std::size_t count2);
517 
518  String& replace(const_iterator first, const_iterator last, const char* cstr, std::size_t count2);
519  String& replace(const_iterator first, const_iterator last, const wchar_t* cstr, std::size_t count2);
520  String& replace(const_iterator first, const_iterator last, const char16_t* cstr, std::size_t count2);
521  String& replace(const_iterator first, const_iterator last, const char32_t* cstr, std::size_t count2);
522 
523  String& replace(std::size_t pos, std::size_t count, const char* cstr);
524  String& replace(std::size_t pos, std::size_t count, const wchar_t* cstr);
525  String& replace(std::size_t pos, std::size_t count, const char16_t* cstr);
526  String& replace(std::size_t pos, std::size_t count, const char32_t* cstr);
527 
528  String& replace(const_iterator first, const_iterator last, const char* cstr);
529  String& replace(const_iterator first, const_iterator last, const wchar_t* cstr);
530  String& replace(const_iterator first, const_iterator last, const char16_t* cstr);
531  String& replace(const_iterator first, const_iterator last, const char32_t* cstr);
532 
533  String& replace(std::size_t pos, std::size_t count, std::size_t count2, char ch);
534  String& replace(std::size_t pos, std::size_t count, std::size_t count2, wchar_t ch);
535  String& replace(std::size_t pos, std::size_t count, std::size_t count2, char16_t ch);
536  String& replace(std::size_t pos, std::size_t count, std::size_t count2, char32_t ch);
537 
538  String& replace(const_iterator first, const_iterator last, std::size_t count2, char ch);
539  String& replace(const_iterator first, const_iterator last, std::size_t count2, wchar_t ch);
540  String& replace(const_iterator first, const_iterator last, std::size_t count2, char16_t ch);
541  String& replace(const_iterator first, const_iterator last, std::size_t count2, char32_t ch);
542 
543  String& replace(const_iterator first, const_iterator last, std::initializer_list<char> chars);
544  String& replace(const_iterator first, const_iterator last, std::initializer_list<wchar_t> chars);
545  String& replace(const_iterator first, const_iterator last, std::initializer_list<char16_t> chars);
546  String& replace(const_iterator first, const_iterator last, std::initializer_list<char32_t> chars);
547 #endif
548  String substr(std::size_t pos = 0, std::size_t count = npos) const;
549 
550  std::size_t copy(char32_t* dest, std::size_t count, std::size_t pos = 0) const;
551 
552  void resize(std::size_t count);
553  void resize(std::size_t count, char ch);
554  void resize(std::size_t count, wchar_t ch);
555  void resize(std::size_t count, char16_t ch);
556  void resize(std::size_t count, char32_t ch);
557 
558  void swap(String& other);
559 
560  std::size_t find(const std::string& str, std::size_t pos = 0) const noexcept;
561  std::size_t find(const std::wstring& str, std::size_t pos = 0) const noexcept;
562  std::size_t find(const std::u16string& str, std::size_t pos = 0) const noexcept;
563  std::size_t find(const std::u32string& str, std::size_t pos = 0) const noexcept;
564  std::size_t find(const String& str, std::size_t pos = 0) const noexcept;
565 
566  std::size_t find(const char* s, std::size_t pos, std::size_t count) const;
567  std::size_t find(const wchar_t* s, std::size_t pos, std::size_t count) const;
568  std::size_t find(const char16_t* s, std::size_t pos, std::size_t count) const;
569  std::size_t find(const char32_t* s, std::size_t pos, std::size_t count) const;
570 
571  std::size_t find(const char* s, std::size_t pos = 0) const;
572  std::size_t find(const wchar_t* s, std::size_t pos = 0) const;
573  std::size_t find(const char16_t* s, std::size_t pos = 0) const;
574  std::size_t find(const char32_t* s, std::size_t pos = 0) const;
575 
576  std::size_t find(char ch, std::size_t pos = 0) const noexcept;
577  std::size_t find(wchar_t ch, std::size_t pos = 0) const noexcept;
578  std::size_t find(char16_t ch, std::size_t pos = 0) const noexcept;
579  std::size_t find(char32_t ch, std::size_t pos = 0) const noexcept;
580 
581  std::size_t find_first_of(const std::string& str, std::size_t pos = 0) const noexcept;
582  std::size_t find_first_of(const std::wstring& str, std::size_t pos = 0) const noexcept;
583  std::size_t find_first_of(const std::u16string& str, std::size_t pos = 0) const noexcept;
584  std::size_t find_first_of(const std::u32string& str, std::size_t pos = 0) const noexcept;
585  std::size_t find_first_of(const String& str, std::size_t pos = 0) const noexcept;
586 
587  std::size_t find_first_of(const char* s, std::size_t pos, std::size_t count) const;
588  std::size_t find_first_of(const wchar_t* s, std::size_t pos, std::size_t count) const;
589  std::size_t find_first_of(const char16_t* s, std::size_t pos, std::size_t count) const;
590  std::size_t find_first_of(const char32_t* s, std::size_t pos, std::size_t count) const;
591 
592  std::size_t find_first_of(const char* s, std::size_t pos = 0) const;
593  std::size_t find_first_of(const wchar_t* s, std::size_t pos = 0) const;
594  std::size_t find_first_of(const char16_t* s, std::size_t pos = 0) const;
595  std::size_t find_first_of(const char32_t* s, std::size_t pos = 0) const;
596 
597  std::size_t find_first_of(char ch, std::size_t pos = 0) const noexcept;
598  std::size_t find_first_of(wchar_t ch, std::size_t pos = 0) const noexcept;
599  std::size_t find_first_of(char16_t ch, std::size_t pos = 0) const noexcept;
600  std::size_t find_first_of(char32_t ch, std::size_t pos = 0) const noexcept;
601 
602  std::size_t find_first_not_of(const std::string& str, std::size_t pos = 0) const noexcept;
603  std::size_t find_first_not_of(const std::wstring& str, std::size_t pos = 0) const noexcept;
604  std::size_t find_first_not_of(const std::u16string& str, std::size_t pos = 0) const noexcept;
605  std::size_t find_first_not_of(const std::u32string& str, std::size_t pos = 0) const noexcept;
606  std::size_t find_first_not_of(const String& str, std::size_t pos = 0) const noexcept;
607 
608  std::size_t find_first_not_of(const char* s, std::size_t pos, std::size_t count) const;
609  std::size_t find_first_not_of(const wchar_t* s, std::size_t pos, std::size_t count) const;
610  std::size_t find_first_not_of(const char16_t* s, std::size_t pos, std::size_t count) const;
611  std::size_t find_first_not_of(const char32_t* s, std::size_t pos, std::size_t count) const;
612 
613  std::size_t find_first_not_of(const char* s, std::size_t pos = 0) const;
614  std::size_t find_first_not_of(const wchar_t* s, std::size_t pos = 0) const;
615  std::size_t find_first_not_of(const char16_t* s, std::size_t pos = 0) const;
616  std::size_t find_first_not_of(const char32_t* s, std::size_t pos = 0) const;
617 
618  std::size_t find_first_not_of(char ch, std::size_t pos = 0) const noexcept;
619  std::size_t find_first_not_of(wchar_t ch, std::size_t pos = 0) const noexcept;
620  std::size_t find_first_not_of(char16_t ch, std::size_t pos = 0) const noexcept;
621  std::size_t find_first_not_of(char32_t ch, std::size_t pos = 0) const noexcept;
622 
623  std::size_t rfind(const std::string& str, std::size_t pos = npos) const noexcept;
624  std::size_t rfind(const std::wstring& str, std::size_t pos = npos) const noexcept;
625  std::size_t rfind(const std::u16string& str, std::size_t pos = npos) const noexcept;
626  std::size_t rfind(const std::u32string& str, std::size_t pos = npos) const noexcept;
627  std::size_t rfind(const String& str, std::size_t pos = npos) const noexcept;
628 
629  std::size_t rfind(const char* s, std::size_t pos, std::size_t count) const;
630  std::size_t rfind(const wchar_t* s, std::size_t pos, std::size_t count) const;
631  std::size_t rfind(const char16_t* s, std::size_t pos, std::size_t count) const;
632  std::size_t rfind(const char32_t* s, std::size_t pos, std::size_t count) const;
633 
634  std::size_t rfind(const char* s, std::size_t pos = npos) const;
635  std::size_t rfind(const wchar_t* s, std::size_t pos = npos) const;
636  std::size_t rfind(const char16_t* s, std::size_t pos = npos) const;
637  std::size_t rfind(const char32_t* s, std::size_t pos = npos) const;
638 
639  std::size_t rfind(char ch, std::size_t pos = npos) const noexcept;
640  std::size_t rfind(wchar_t ch, std::size_t pos = npos) const noexcept;
641  std::size_t rfind(char16_t ch, std::size_t pos = npos) const noexcept;
642  std::size_t rfind(char32_t ch, std::size_t pos = npos) const noexcept;
643 
644  std::size_t find_last_of(const std::string& str, std::size_t pos = npos) const noexcept;
645  std::size_t find_last_of(const std::wstring& str, std::size_t pos = npos) const noexcept;
646  std::size_t find_last_of(const std::u16string& str, std::size_t pos = npos) const noexcept;
647  std::size_t find_last_of(const std::u32string& str, std::size_t pos = npos) const noexcept;
648  std::size_t find_last_of(const String& str, std::size_t pos = npos) const noexcept;
649 
650  std::size_t find_last_of(const char* s, std::size_t pos, std::size_t count) const;
651  std::size_t find_last_of(const wchar_t* s, std::size_t pos, std::size_t count) const;
652  std::size_t find_last_of(const char16_t* s, std::size_t pos, std::size_t count) const;
653  std::size_t find_last_of(const char32_t* s, std::size_t pos, std::size_t count) const;
654 
655  std::size_t find_last_of(const char* s, std::size_t pos = npos) const;
656  std::size_t find_last_of(const wchar_t* s, std::size_t pos = npos) const;
657  std::size_t find_last_of(const char16_t* s, std::size_t pos = npos) const;
658  std::size_t find_last_of(const char32_t* s, std::size_t pos = npos) const;
659 
660  std::size_t find_last_of(char ch, std::size_t pos = npos) const noexcept;
661  std::size_t find_last_of(wchar_t ch, std::size_t pos = npos) const noexcept;
662  std::size_t find_last_of(char16_t ch, std::size_t pos = npos) const noexcept;
663  std::size_t find_last_of(char32_t ch, std::size_t pos = npos) const noexcept;
664 
665  std::size_t find_last_not_of(const std::string& str, std::size_t pos = npos) const noexcept;
666  std::size_t find_last_not_of(const std::wstring& str, std::size_t pos = npos) const noexcept;
667  std::size_t find_last_not_of(const std::u16string& str, std::size_t pos = npos) const noexcept;
668  std::size_t find_last_not_of(const std::u32string& str, std::size_t pos = npos) const noexcept;
669  std::size_t find_last_not_of(const String& str, std::size_t pos = npos) const noexcept;
670 
671  std::size_t find_last_not_of(const char* s, std::size_t pos, std::size_t count) const;
672  std::size_t find_last_not_of(const wchar_t* s, std::size_t pos, std::size_t count) const;
673  std::size_t find_last_not_of(const char16_t* s, std::size_t pos, std::size_t count) const;
674  std::size_t find_last_not_of(const char32_t* s, std::size_t pos, std::size_t count) const;
675 
676  std::size_t find_last_not_of(const char* s, std::size_t pos = npos) const;
677  std::size_t find_last_not_of(const wchar_t* s, std::size_t pos = npos) const;
678  std::size_t find_last_not_of(const char16_t* s, std::size_t pos = npos) const;
679  std::size_t find_last_not_of(const char32_t* s, std::size_t pos = npos) const;
680 
681  std::size_t find_last_not_of(char ch, std::size_t pos = npos) const noexcept;
682  std::size_t find_last_not_of(wchar_t ch, std::size_t pos = npos) const noexcept;
683  std::size_t find_last_not_of(char16_t ch, std::size_t pos = npos) const noexcept;
684  std::size_t find_last_not_of(char32_t ch, std::size_t pos = npos) const noexcept;
685 
686  friend bool operator==(const String& left, const String& right);
687  friend bool operator!=(const String& left, const String& right);
688  friend bool operator<(const String& left, const String& right);
689  friend bool operator<=(const String& left, const String& right);
690  friend bool operator>(const String& left, const String& right);
691  friend bool operator>=(const String& left, const String& right);
692  friend String operator+(const String& left, const String& right);
693  friend String operator+(const String& left, String&& right);
694  friend String operator+(String&& left, const String& right);
695  friend String operator+(String&& left, String&& right);
696 
697 #if defined(__cpp_lib_char8_t) && (__cpp_lib_char8_t >= 201811L)
698  String(const std::u8string& str);
699  String(char8_t utfChar);
700  String(const char8_t* str);
701  String(std::size_t count, char8_t ch);
702  String(const std::u8string& str, std::size_t pos);
703  String(const std::u8string& str, std::size_t pos, std::size_t count);
704  String(const char8_t* str, std::size_t count);
705  String(std::initializer_list<char8_t> chars);
706  String(std::u8string::const_iterator first, std::u8string::const_iterator last);
707 
708  operator std::u8string() const;
709 
710  std::u8string asUtf8() const;
711 
712  String& assign(std::size_t count, char8_t ch);
713  String& assign(const std::u8string& str);
714  String& assign(const std::u8string& str, std::size_t pos, std::size_t count = npos);
715  String& assign(std::u8string&& str);
716  String& assign(const char8_t* str, std::size_t count);
717  String& assign(const char8_t* str);
718  String& assign(std::initializer_list<char8_t> chars);
719  String& assign(std::u8string::const_iterator first, std::u8string::const_iterator last);
720 
721  String& insert(std::size_t index, std::size_t count, char8_t ch);
722  String& insert(std::size_t index, const std::u8string& str);
723  String& insert(std::size_t index, const std::u8string& str, std::size_t pos, std::size_t count = npos);
724  String& insert(std::size_t index, const char8_t* str, std::size_t count);
725  String& insert(std::size_t index, const char8_t* str);
726  iterator insert(const_iterator pos, char8_t ch);
727  iterator insert(const_iterator pos, std::size_t count, char8_t ch);
728  iterator insert(const_iterator pos, std::initializer_list<char8_t> chars);
729  iterator insert(const_iterator pos, std::u8string::const_iterator first, std::u8string::const_iterator last);
730 
731  String& append(std::size_t count, char8_t ch);
732  String& append(const std::u8string& str);
733  String& append(const std::u8string& str, std::size_t pos, std::size_t count = npos);
734  String& append(const char8_t* str, std::size_t count);
735  String& append(const char8_t* str);
736  String& append(std::initializer_list<char8_t> chars);
737  String& append(std::u8string::const_iterator first, std::u8string::const_iterator last);
738 
739  int compare(const std::u8string& str) const noexcept;
740  int compare(std::size_t pos1, std::size_t count1, const std::u8string& str) const;
741  int compare(std::size_t pos1, std::size_t count1, const std::u8string& str, std::size_t pos2, std::size_t count2 = npos) const;
742  int compare(const char8_t* s) const;
743  int compare(std::size_t pos1, std::size_t count1, const char8_t* s) const;
744  int compare(std::size_t pos1, std::size_t count1, const char8_t* s, std::size_t count2) const;
745 
746  String& replace(std::size_t pos, std::size_t count, const std::u8string& str);
747  String& replace(const_iterator first, const_iterator last, const std::u8string& str);
748  String& replace(std::size_t pos, std::size_t count, const std::u8string& str, std::size_t pos2, std::size_t count2 = npos);
749  String& replace(const_iterator first, const_iterator last, std::u8string::const_iterator first2, std::u8string::const_iterator last2);
750  String& replace(std::size_t pos, std::size_t count, const char8_t* cstr, std::size_t count2);
751  String& replace(const_iterator first, const_iterator last, const char8_t* cstr, std::size_t count2);
752  String& replace(std::size_t pos, std::size_t count, const char8_t* cstr);
753  String& replace(const_iterator first, const_iterator last, const char8_t* cstr);
754  String& replace(std::size_t pos, std::size_t count, std::size_t count2, char8_t ch);
755  String& replace(const_iterator first, const_iterator last, std::size_t count2, char8_t ch);
756  String& replace(const_iterator first, const_iterator last, std::initializer_list<char8_t> chars);
757 
758  void resize(std::size_t count, char8_t ch);
759 
760  std::size_t find(const std::u8string& str, std::size_t pos = 0) const noexcept;
761  std::size_t find(const char8_t* s, std::size_t pos, std::size_t count) const;
762  std::size_t find(const char8_t* s, std::size_t pos = 0) const;
763  std::size_t find(char8_t ch, std::size_t pos = 0) const noexcept;
764 
765  std::size_t find_first_of(const std::u8string& str, std::size_t pos = 0) const noexcept;
766  std::size_t find_first_of(const char8_t* s, std::size_t pos, std::size_t count) const;
767  std::size_t find_first_of(const char8_t* s, std::size_t pos = 0) const;
768  std::size_t find_first_of(char8_t ch, std::size_t pos = 0) const noexcept;
769 
770  std::size_t find_first_not_of(const std::u8string& str, std::size_t pos = 0) const noexcept;
771  std::size_t find_first_not_of(const char8_t* s, std::size_t pos, std::size_t count) const;
772  std::size_t find_first_not_of(const char8_t* s, std::size_t pos = 0) const;
773  std::size_t find_first_not_of(char8_t ch, std::size_t pos = 0) const noexcept;
774 
775  std::size_t rfind(const std::u8string& str, std::size_t pos = npos) const noexcept;
776  std::size_t rfind(const char8_t* s, std::size_t pos, std::size_t count) const;
777  std::size_t rfind(const char8_t* s, std::size_t pos = npos) const;
778  std::size_t rfind(char8_t ch, std::size_t pos = npos) const noexcept;
779 
780  std::size_t find_last_of(const std::u8string& str, std::size_t pos = npos) const noexcept;
781  std::size_t find_last_of(const char8_t* s, std::size_t pos, std::size_t count) const;
782  std::size_t find_last_of(const char8_t* s, std::size_t pos = npos) const;
783  std::size_t find_last_of(char8_t ch, std::size_t pos = npos) const noexcept;
784 
785  std::size_t find_last_not_of(const std::u8string& str, std::size_t pos = npos) const noexcept;
786  std::size_t find_last_not_of(const char8_t* s, std::size_t pos, std::size_t count) const;
787  std::size_t find_last_not_of(const char8_t* s, std::size_t pos = npos) const;
788  std::size_t find_last_not_of(char8_t ch, std::size_t pos = npos) const noexcept;
789 
790  friend std::basic_ostream<char8_t>& operator<<(std::basic_ostream<char8_t>& os, const String& str);
791 #endif
792  };
793 
795 
796  inline bool operator==(const String& left, const String& right)
797  {
798  return left.m_string == right.m_string;
799  }
800 
801  inline bool operator!=(const String& left, const String& right)
802  {
803  return left.m_string != right.m_string;
804  }
805 
806  inline bool operator<(const String& left, const String& right)
807  {
808  return left.m_string < right.m_string;
809  }
810 
811  inline bool operator<=(const String& left, const String& right)
812  {
813  return left.m_string <= right.m_string;
814  }
815 
816  inline bool operator>(const String& left, const String& right)
817  {
818  return left.m_string > right.m_string;
819  }
820 
821  inline bool operator>=(const String& left, const String& right)
822  {
823  return left.m_string >= right.m_string;
824  }
825 
826  inline String operator+(const String& left, const String& right)
827  {
828  return String(left.m_string + right.m_string);
829  }
830  inline String operator+(String&& left, String&& right)
831  {
832  return String(std::move(left.m_string) + std::move(right.m_string));
833  }
834  inline String operator+(String&& left, const String& right)
835  {
836  return String(std::move(left.m_string) + right.m_string);
837  }
838  inline String operator+(const String& left, String&& right)
839  {
840  return String(left.m_string + std::move(right.m_string));
841  }
842 
843  TGUI_API std::basic_ostream<char>& operator<<(std::basic_ostream<char>& os, const String& str);
844  TGUI_API std::basic_ostream<wchar_t>& operator<<(std::basic_ostream<wchar_t>& os, const String& str);
845  //TGUI_API std::basic_ostream<char16_t>& operator<<(std::basic_ostream<char16_t>& os, const String& str);
846  //TGUI_API std::basic_ostream<char32_t>& operator<<(std::basic_ostream<char32_t>& os, const String& str);
847 
848 
849  // UTF-8 function are defined in the header so that they can be enabled/disabled based on
850  // the compiler settings without having to recompile TGUI with a different c++ standard.
851 #if defined(__cpp_lib_char8_t) && (__cpp_lib_char8_t >= 201811L)
852  inline String::String(const std::u8string& str)
853  {
854  m_string.reserve(str.length()+1);
855  sf::Utf8::toUtf32(str.begin(), str.end(), std::back_inserter(m_string));
856  }
857 
858  inline String::String(char8_t utfChar)
859  : m_string(1, static_cast<char32_t>(utfChar))
860  {
861  }
862 
863  inline String::String(const char8_t* str)
864  : String{std::u8string{str}}
865  {
866  }
867 
868  inline String::String(std::size_t count, char8_t ch)
869  : m_string(count, static_cast<char32_t>(ch))
870  {
871  }
872 
873  inline String::String(const std::u8string& str, std::size_t pos)
874  : String{std::u8string(str, pos)}
875  {
876  }
877 
878  inline String::String(const std::u8string& str, std::size_t pos, std::size_t count)
879  : String{std::u8string(str, pos, count)}
880  {
881  }
882 
883  inline String::String(const char8_t* str, std::size_t count)
884  : String{std::u8string{str, count}}
885  {
886  }
887 
888  inline String::String(std::initializer_list<char8_t> chars)
889  : String(std::u8string(chars.begin(), chars.end()))
890  {
891  }
892 
893  inline String::String(std::u8string::const_iterator first, std::u8string::const_iterator last)
894  : String{std::u8string(first, last)}
895  {
896  }
897 
898  inline String::operator std::u8string() const
899  {
900  return asUtf8();
901  }
902 
903  inline std::u8string String::asUtf8() const
904  {
905  std::u8string output;
906  output.reserve(m_string.length() + 1);
907  sf::Utf32::toUtf8(m_string.begin(), m_string.end(), std::back_inserter(output));
908  return output;
909  }
910 
911  inline String& String::assign(std::size_t count, char8_t ch)
912  {
913  m_string.assign(count, static_cast<char32_t>(ch));
914  return *this;
915  }
916 
917  inline String& String::assign(const std::u8string& str)
918  {
919  return *this = str;
920  }
921 
922  inline String& String::assign(const std::u8string& str, std::size_t pos, std::size_t count)
923  {
924  return *this = {str, pos, count};
925  }
926 
927  inline String& String::assign(std::u8string&& str)
928  {
929  return *this = std::move(str);
930  }
931 
932  inline String& String::assign(const char8_t* str, std::size_t count)
933  {
934  return *this = {str, count};
935  }
936 
937  inline String& String::assign(const char8_t* str)
938  {
939  return *this = str;
940  }
941 
942  inline String& String::assign(std::initializer_list<char8_t> chars)
943  {
944  return *this = chars;
945  }
946 
947  inline String& String::assign(std::u8string::const_iterator first, std::u8string::const_iterator last)
948  {
949  return *this = {first, last};
950  }
951 
952  inline String& String::insert(std::size_t index, std::size_t count, char8_t ch)
953  {
954  m_string.insert(index, count, static_cast<char32_t>(ch));
955  return *this;
956  }
957 
958  inline String& String::insert(std::size_t index, const std::u8string& str)
959  {
960  m_string.insert(index, String{str}.m_string);
961  return *this;
962  }
963 
964  inline String& String::insert(std::size_t index, const std::u8string& str, std::size_t pos, std::size_t count)
965  {
966  m_string.insert(index, String{str, pos, count}.m_string);
967  return *this;
968  }
969 
970  inline String& String::insert(std::size_t index, const char8_t* str, std::size_t count)
971  {
972  m_string.insert(index, String{str, count}.m_string);
973  return *this;
974  }
975 
976  inline String& String::insert(std::size_t index, const char8_t* str)
977  {
978  m_string.insert(index, String{str}.m_string);
979  return *this;
980  }
981 
982  inline String::iterator String::insert(String::const_iterator pos, char8_t ch)
983  {
984  return m_string.insert(pos, static_cast<char32_t>(ch));
985  }
986 
987  inline String::iterator String::insert(String::const_iterator pos, std::size_t count, char8_t ch)
988  {
989  return m_string.insert(pos, count, static_cast<char32_t>(ch));
990  }
991 
992  inline String::iterator String::insert(String::const_iterator pos, std::initializer_list<char8_t> chars)
993  {
994  auto tmpStr = String{chars};
995  return m_string.insert(pos, tmpStr.begin(), tmpStr.end());
996  }
997 
998  inline String::iterator String::insert(String::const_iterator pos, std::u8string::const_iterator first, std::u8string::const_iterator last)
999  {
1000  auto tmpStr = String{first, last};
1001  return m_string.insert(pos, tmpStr.begin(), tmpStr.end());
1002  }
1003 
1004  inline String& String::append(std::size_t count, char8_t ch)
1005  {
1006  return append(String(count, ch));
1007  }
1008 
1009  inline String& String::append(const std::u8string& str)
1010  {
1011  return append(String{str});
1012  }
1013 
1014  inline String& String::append(const std::u8string& str, std::size_t pos, std::size_t count)
1015  {
1016  return append(String{str, pos, count});
1017  }
1018 
1019  inline String& String::append(const char8_t* str, std::size_t count)
1020  {
1021  return append(String{str, count});
1022  }
1023 
1024  inline String& String::append(const char8_t* str)
1025  {
1026  return append(String{str});
1027  }
1028 
1029  inline String& String::append(std::initializer_list<char8_t> chars)
1030  {
1031  return append(String{chars});
1032  }
1033 
1034  inline String& String::append(std::u8string::const_iterator first, std::u8string::const_iterator last)
1035  {
1036  return append(String{first, last});
1037  }
1038 
1039  inline int String::compare(const std::u8string& str) const noexcept
1040  {
1041  return m_string.compare(String{str});
1042  }
1043 
1044  inline int String::compare(std::size_t pos1, std::size_t count1, const std::u8string& str) const
1045  {
1046  return m_string.compare(pos1, count1, String{str});
1047  }
1048 
1049  inline int String::compare(std::size_t pos1, std::size_t count1, const std::u8string& str, std::size_t pos2, std::size_t count2) const
1050  {
1051  return m_string.compare(pos1, count1, String{str, pos2, count2});
1052  }
1053 
1054  inline int String::compare(const char8_t* s) const
1055  {
1056  return m_string.compare(String{s});
1057  }
1058 
1059  inline int String::compare(std::size_t pos1, std::size_t count1, const char8_t* s) const
1060  {
1061  return m_string.compare(pos1, count1, String{s});
1062  }
1063 
1064  inline int String::compare(std::size_t pos1, std::size_t count1, const char8_t* s, std::size_t count2) const
1065  {
1066  return m_string.compare(pos1, count1, String{s, count2});
1067  }
1068 
1069  inline String& String::replace(std::size_t pos, std::size_t count, const std::u8string& str)
1070  {
1071  m_string.replace(pos, count, String{str}.m_string);
1072  return *this;
1073  }
1074 
1075  inline String& String::replace(const_iterator first, const_iterator last, const std::u8string& str)
1076  {
1077  m_string.replace(first, last, String{str}.m_string);
1078  return *this;
1079  }
1080 
1081  inline String& String::replace(std::size_t pos, std::size_t count, const std::u8string& str, std::size_t pos2, std::size_t count2)
1082  {
1083  m_string.replace(pos, count, String{str, pos2, count2}.m_string);
1084  return *this;
1085  }
1086 
1087  inline String& String::replace(const_iterator first, const_iterator last, std::u8string::const_iterator first2, std::u8string::const_iterator last2)
1088  {
1089  m_string.replace(first, last, String{first2, last2}.m_string);
1090  return *this;
1091  }
1092 
1093  inline String& String::replace(std::size_t pos, std::size_t count, const char8_t* cstr, std::size_t count2)
1094  {
1095  m_string.replace(pos, count, String{cstr, count2}.m_string);
1096  return *this;
1097  }
1098 
1099  inline String& String::replace(const_iterator first, const_iterator last, const char8_t* cstr, std::size_t count2)
1100  {
1101  m_string.replace(first, last, String{cstr, count2}.m_string);
1102  return *this;
1103  }
1104 
1105  inline String& String::replace(std::size_t pos, std::size_t count, const char8_t* cstr)
1106  {
1107  m_string.replace(pos, count, String{cstr}.m_string);
1108  return *this;
1109  }
1110 
1111  inline String& String::replace(const_iterator first, const_iterator last, const char8_t* cstr)
1112  {
1113  m_string.replace(first, last, String{cstr}.m_string);
1114  return *this;
1115  }
1116 
1117  inline String& String::replace(std::size_t pos, std::size_t count, std::size_t count2, char8_t ch)
1118  {
1119  m_string.replace(pos, count, String(count2, ch).m_string);
1120  return *this;
1121  }
1122 
1123  inline String& String::replace(const_iterator first, const_iterator last, std::size_t count2, char8_t ch)
1124  {
1125  m_string.replace(first, last, String(count2, ch).m_string);
1126  return *this;
1127  }
1128 
1129  inline String& String::replace(const_iterator first, const_iterator last, std::initializer_list<char8_t> chars)
1130  {
1131  m_string.replace(first, last, String{chars}.m_string);
1132  return *this;
1133  }
1134 
1135  inline void String::resize(std::size_t count, char8_t ch)
1136  {
1137  m_string.resize(count, static_cast<char32_t>(ch));
1138  }
1139 
1140  inline std::size_t String::find(const std::u8string& str, std::size_t pos) const noexcept
1141  {
1142  return m_string.find(String{str}.m_string, pos);
1143  }
1144 
1145  inline std::size_t String::find(const char8_t* s, std::size_t pos, std::size_t count) const
1146  {
1147  return m_string.find(String{s, count}.m_string, pos);
1148  }
1149 
1150  inline std::size_t String::find(const char8_t* s, std::size_t pos) const
1151  {
1152  return m_string.find(String{s}.m_string, pos);
1153  }
1154 
1155  inline std::size_t String::find(char8_t ch, std::size_t pos) const noexcept
1156  {
1157  return m_string.find(static_cast<char32_t>(ch), pos);
1158  }
1159 
1160  inline std::size_t String::find_first_of(const std::u8string& str, std::size_t pos) const noexcept
1161  {
1162  return m_string.find_first_of(String{str}.m_string, pos);
1163  }
1164 
1165  inline std::size_t String::find_first_of(const char8_t* s, std::size_t pos, std::size_t count) const
1166  {
1167  return m_string.find_first_of(String{s, count}.m_string, pos);
1168  }
1169 
1170  inline std::size_t String::find_first_of(const char8_t* s, std::size_t pos) const
1171  {
1172  return m_string.find_first_of(String{s}.m_string, pos);
1173  }
1174 
1175  inline std::size_t String::find_first_of(char8_t ch, std::size_t pos) const noexcept
1176  {
1177  return m_string.find_first_of(static_cast<char32_t>(ch), pos);
1178  }
1179 
1180  inline std::size_t String::find_first_not_of(const std::u8string& str, std::size_t pos) const noexcept
1181  {
1182  return m_string.find_first_not_of(String{str}.m_string, pos);
1183  }
1184 
1185  inline std::size_t String::find_first_not_of(const char8_t* s, std::size_t pos, std::size_t count) const
1186  {
1187  return m_string.find_first_not_of(String{s, count}.m_string, pos);
1188  }
1189 
1190  inline std::size_t String::find_first_not_of(const char8_t* s, std::size_t pos) const
1191  {
1192  return m_string.find_first_not_of(String{s}.m_string, pos);
1193  }
1194 
1195  inline std::size_t String::find_first_not_of(char8_t ch, std::size_t pos) const noexcept
1196  {
1197  return m_string.find_first_not_of(static_cast<char32_t>(ch), pos);
1198  }
1199 
1200  inline std::size_t String::rfind(const std::u8string& str, std::size_t pos) const noexcept
1201  {
1202  return m_string.rfind(String{str}.m_string, pos);
1203  }
1204 
1205  inline std::size_t String::rfind(const char8_t* s, std::size_t pos, std::size_t count) const
1206  {
1207  return m_string.rfind(String{s, count}.m_string, pos);
1208  }
1209 
1210  inline std::size_t String::rfind(const char8_t* s, std::size_t pos) const
1211  {
1212  return m_string.rfind(String{s}.m_string, pos);
1213  }
1214 
1215  inline std::size_t String::rfind(char8_t ch, std::size_t pos) const noexcept
1216  {
1217  return m_string.rfind(static_cast<char32_t>(ch), pos);
1218  }
1219 
1220  inline std::size_t String::find_last_of(const std::u8string& str, std::size_t pos) const noexcept
1221  {
1222  return m_string.find_last_of(String{str}.m_string, pos);
1223  }
1224 
1225  inline std::size_t String::find_last_of(const char8_t* s, std::size_t pos, std::size_t count) const
1226  {
1227  return m_string.find_last_of(String{s, count}.m_string, pos);
1228  }
1229 
1230  inline std::size_t String::find_last_of(const char8_t* s, std::size_t pos) const
1231  {
1232  return m_string.find_last_of(String{s}.m_string, pos);
1233  }
1234 
1235  inline std::size_t String::find_last_of(char8_t ch, std::size_t pos) const noexcept
1236  {
1237  return m_string.find_last_of(static_cast<char32_t>(ch), pos);
1238  }
1239 
1240  inline std::size_t String::find_last_not_of(const std::u8string& str, std::size_t pos) const noexcept
1241  {
1242  return m_string.find_last_not_of(String{str}.m_string, pos);
1243  }
1244 
1245  inline std::size_t String::find_last_not_of(const char8_t* s, std::size_t pos, std::size_t count) const
1246  {
1247  return m_string.find_last_not_of(String{s, count}.m_string, pos);
1248  }
1249 
1250  inline std::size_t String::find_last_not_of(const char8_t* s, std::size_t pos) const
1251  {
1252  return m_string.find_last_not_of(String{s}.m_string, pos);
1253  }
1254 
1255  inline std::size_t String::find_last_not_of(char8_t ch, std::size_t pos) const noexcept
1256  {
1257  return m_string.find_last_not_of(static_cast<char8_t>(ch), pos);
1258  }
1259 
1260  inline std::basic_ostream<char8_t>& operator<<(std::basic_ostream<char8_t>& os, const String& str)
1261  {
1262  os << std::u8string(str);
1263  return os;
1264  }
1265 #endif
1266 
1268 }
1269 
1271 
1272 #endif // TGUI_STRING_HPP
TGUI_API std::string toLower(const std::string &str)
Converts a string to lowercase.
TGUI_API std::string toUpper(const std::string &str)
Converts a string to uppercase.
TGUI_API std::string trim(const std::string &str)
Trims the whitespace from a string.
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
TGUI_API unsigned int strToUInt(const std::string &str, unsigned int defaultValue=0)
Converts a string to an unsigned int.
TGUI_API bool isWhitespace(char character)
Checks if a character is a whitespace character (space, tab, carriage return or line feed)
Wrapper class to store strings.
Definition: String.hpp:115
TGUI_API Layout operator+(Layout left, Layout right)
operator for the Layout class
TGUI_API float strToFloat(const std::string &str, float defaultValue=0)
Converts a string to a float.
TGUI_CONSTEXPR Vector2f & operator+=(Vector2f &left, const Vector2f &right)
Overload of binary operator +=.
Definition: Vector2f.hpp:137
TGUI_API int strToInt(const std::string &str, int defaultValue=0)
Converts a string to an int.