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