26#ifndef TGUI_STRING_HPP
27#define TGUI_STRING_HPP
29#include <TGUI/Config.hpp>
30#include <TGUI/Utf.hpp>
39#if TGUI_HAS_WINDOW_BACKEND_SFML
40 #include <SFML/System/String.hpp>
43#if TGUI_COMPILED_WITH_CPP_VER >= 17
44 #include <type_traits>
45 #include <string_view>
81 std::u32string m_string;
83#if TGUI_COMPILED_WITH_CPP_VER >= 17
85 template <
typename StringViewType>
86 using IsStringViewType = std::enable_if_t<
87 std::is_same_v<StringViewType, std::string_view>
88#if defined(__cpp_lib_char8_t) && (__cpp_lib_char8_t >= 201811L)
89 || std::is_same_v<StringViewType, std::u8string_view>
91 || std::is_same_v<StringViewType, std::wstring_view>
92 || std::is_same_v<StringViewType, std::u16string_view>
93 || std::is_same_v<StringViewType, std::u32string_view>,
99 static const decltype(std::u32string::npos) npos;
101 using iterator = std::u32string::iterator;
102 using const_iterator = std::u32string::const_iterator;
103 using reverse_iterator = std::u32string::reverse_iterator;
104 using const_reverse_iterator = std::u32string::const_reverse_iterator;
106 using value_type = char32_t;
107 using reference =
char32_t&;
108 using const_reference =
const char32_t&;
150 int toInt(
int defaultValue = 0)
const;
160 unsigned int toUInt(
unsigned int defaultValue = 0)
const;
264 std::vector<String>
split(
char32_t delimiter,
bool trim =
false)
const;
283 template <
typename T>
286 std::ostringstream oss;
287 oss.imbue(std::locale::classic());
301 template <
typename T>
304 std::ostringstream oss;
305 oss.imbue(std::locale::classic());
306 oss << std::fixed << std::setprecision(decimals);
316 String(
const std::string& str);
317 String(
const std::wstring& str);
318 String(
const std::u16string& str);
319 String(
const std::u32string& str);
321 String(std::u32string&& str) :
322 m_string{std::move(str)}
326 String(
char ansiChar);
327 String(
wchar_t wideChar);
328 String(
char16_t utfChar);
329 String(
char32_t utfChar);
331 String(
const char* str);
332 String(
const wchar_t* str);
333 String(
const char16_t* str);
334 String(
const char32_t* str) :
340 template <typename T, typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type>
341 explicit String(T number) :
342 String{fromNumber(number)}
346 String(std::size_t count,
char ch);
347 String(std::size_t count,
wchar_t ch);
348 String(std::size_t count,
char16_t ch);
349 String(std::size_t count,
char32_t ch);
351 String(
const std::string& str, std::size_t pos);
352 String(
const std::wstring& str, std::size_t pos);
353 String(
const std::u16string& str, std::size_t pos);
354 String(
const std::u32string& str, std::size_t pos);
356 String(
const std::string& str, std::size_t pos, std::size_t count);
357 String(
const std::wstring& str, std::size_t pos, std::size_t count);
358 String(
const std::u16string& str, std::size_t pos, std::size_t count);
359 String(
const std::u32string& str, std::size_t pos, std::size_t count);
361 String(
const char* str, std::size_t count);
362 String(
const wchar_t* str, std::size_t count);
363 String(
const char16_t* str, std::size_t count);
364 String(
const char32_t* str, std::size_t count);
366 explicit String(std::initializer_list<char> chars);
367 explicit String(std::initializer_list<wchar_t> chars);
368 explicit String(std::initializer_list<char16_t> chars);
369 explicit String(std::initializer_list<char32_t> chars);
373 explicit String(std::string::const_iterator first, std::string::const_iterator last);
374 explicit String(std::wstring::const_iterator first, std::wstring::const_iterator last);
375 explicit String(std::u16string::const_iterator first, std::u16string::const_iterator last);
376 explicit String(std::u32string::const_iterator first, std::u32string::const_iterator last);
378#if TGUI_COMPILED_WITH_CPP_VER >= 17
379 template <
typename StringViewType,
typename = IsStringViewType<StringViewType>>
380 explicit String(
const StringViewType& stringView) :
381 String(stringView.data(), stringView.size())
385 template <
typename StringViewType,
typename = IsStringViewType<StringViewType>>
386 explicit String(
const StringViewType& stringView, std::size_t pos, std::size_t count) :
387 String(stringView.data(), pos, count)
392#if TGUI_HAS_WINDOW_BACKEND_SFML
394 explicit String(
const sf::String& str)
395 : m_string{reinterpret_cast<const char32_t*>(str.toUtf32().c_str())}
399 explicit operator sf::String()
const
401 return sf::String::fromUtf32(m_string.begin(), m_string.end());
405 explicit operator std::string()
const;
406 explicit operator std::wstring()
const;
407 explicit operator std::u16string()
const;
408 explicit operator const std::u32string&()
const
413#if TGUI_COMPILED_WITH_CPP_VER >= 17
414 operator std::u32string_view() const noexcept
420 std::string toStdString()
const;
421 std::wstring toWideString()
const;
422 std::u16string toUtf16()
const;
423 const std::u32string& toUtf32()
const
428 String& assign(std::size_t count,
char ch);
429 String& assign(std::size_t count,
wchar_t ch);
430 String& assign(std::size_t count,
char16_t ch);
431 String& assign(std::size_t count,
char32_t ch);
433 String& assign(
const std::string& str);
434 String& assign(
const std::wstring& str);
435 String& assign(
const std::u16string& str);
436 String& assign(
const std::u32string& str);
437 String& assign(
const String& str);
439 String& assign(
const std::string& str, std::size_t pos, std::size_t count = npos);
440 String& assign(
const std::wstring& str, std::size_t pos, std::size_t count = npos);
441 String& assign(
const std::u16string& str, std::size_t pos, std::size_t count = npos);
442 String& assign(
const std::u32string& str, std::size_t pos, std::size_t count = npos);
443 String& assign(
const String& str, std::size_t pos, std::size_t count = npos);
445 String& assign(std::string&& str);
446 String& assign(std::wstring&& str);
447 String& assign(std::u16string&& str);
448 String& assign(std::u32string&& str);
449 String& assign(String&& str);
451 String& assign(
const char* str, std::size_t count);
452 String& assign(
const wchar_t* str, std::size_t count);
453 String& assign(
const char16_t* str, std::size_t count);
454 String& assign(
const char32_t* str, std::size_t count);
456 String& assign(
const char* str);
457 String& assign(
const wchar_t* str);
458 String& assign(
const char16_t* str);
459 String& assign(
const char32_t* str);
461 String& assign(std::initializer_list<char> chars);
462 String& assign(std::initializer_list<wchar_t> chars);
463 String& assign(std::initializer_list<char16_t> chars);
464 String& assign(std::initializer_list<char32_t> chars);
466 String& assign(std::string::const_iterator first, std::string::const_iterator last);
467 String& assign(std::wstring::const_iterator first, std::wstring::const_iterator last);
468 String& assign(std::u16string::const_iterator first, std::u16string::const_iterator last);
469 String& assign(std::u32string::const_iterator first, std::u32string::const_iterator last);
471 reference at(std::size_t pos);
472 const_reference at(std::size_t pos)
const;
474 const_reference operator [](std::size_t index)
const;
475 reference operator [](std::size_t index);
478 const_reference front()
const;
481 const_reference back()
const;
483 const char32_t* data() const noexcept
485 return m_string.data();
488#if __cplusplus >= 201703L
489 char32_t* data() noexcept
491 return m_string.data();
494 const char32_t* c_str() const noexcept
496 return m_string.c_str();
499 iterator begin() noexcept;
500 const_iterator begin() const noexcept;
501 const_iterator cbegin() const noexcept;
503 iterator end() noexcept;
504 const_iterator end() const noexcept;
505 const_iterator cend() const noexcept;
507 reverse_iterator rbegin() noexcept;
508 const_reverse_iterator rbegin() const noexcept;
509 const_reverse_iterator crbegin() const noexcept;
511 reverse_iterator rend() noexcept;
512 const_reverse_iterator rend() const noexcept;
513 const_reverse_iterator crend() const noexcept;
515 bool empty() const noexcept
517 return m_string.empty();
520 std::size_t size() const noexcept
522 return m_string.size();
525 std::size_t length() const noexcept
527 return m_string.length();
530 std::size_t max_size() const noexcept;
532 void reserve(std::
size_t newCap);
533 std::
size_t capacity() const noexcept;
534 void shrink_to_fit();
536 void clear() noexcept;
538 String& insert(std::
size_t index, std::
size_t count,
char ch);
539 String& insert(std::
size_t index, std::
size_t count,
wchar_t ch);
540 String& insert(std::
size_t index, std::
size_t count,
char16_t ch);
541 String& insert(std::
size_t index, std::
size_t count,
char32_t ch);
543 String& insert(std::
size_t index, const std::
string& str);
544 String& insert(std::
size_t index, const std::wstring& str);
545 String& insert(std::
size_t index, const std::u16string& str);
546 String& insert(std::
size_t index, const std::u32string& str);
547 String& insert(std::
size_t index, const String& str);
549 String& insert(std::
size_t index, const std::
string& str, std::
size_t pos, std::
size_t count = npos);
550 String& insert(std::
size_t index, const std::wstring& str, std::
size_t pos, std::
size_t count = npos);
551 String& insert(std::
size_t index, const std::u16string& str, std::
size_t pos, std::
size_t count = npos);
552 String& insert(std::
size_t index, const std::u32string& str, std::
size_t pos, std::
size_t count = npos);
553 String& insert(std::
size_t index, const String& str, std::
size_t pos, std::
size_t count = npos);
555 String& insert(std::
size_t index, const
char* str, std::
size_t count);
556 String& insert(std::
size_t index, const
wchar_t* str, std::
size_t count);
557 String& insert(std::
size_t index, const
char16_t* str, std::
size_t count);
558 String& insert(std::
size_t index, const
char32_t* str, std::
size_t count);
560 String& insert(std::
size_t index, const
char* str);
561 String& insert(std::
size_t index, const
wchar_t* str);
562 String& insert(std::
size_t index, const
char16_t* str);
563 String& insert(std::
size_t index, const
char32_t* str);
565 iterator insert(const_iterator pos,
char ch);
566 iterator insert(const_iterator pos,
wchar_t ch);
567 iterator insert(const_iterator pos,
char16_t ch);
568 iterator insert(const_iterator pos,
char32_t ch);
570 iterator insert(const_iterator pos, std::
size_t count,
char ch);
571 iterator insert(const_iterator pos, std::
size_t count,
wchar_t ch);
572 iterator insert(const_iterator pos, std::
size_t count,
char16_t ch);
573 iterator insert(const_iterator pos, std::
size_t count,
char32_t ch);
575 iterator insert(const_iterator pos, std::initializer_list<
char> chars);
576 iterator insert(const_iterator pos, std::initializer_list<
wchar_t> chars);
577 iterator insert(const_iterator pos, std::initializer_list<
char16_t> chars);
578 iterator insert(const_iterator pos, std::initializer_list<
char32_t> chars);
580 iterator insert(const_iterator pos, std::
string::const_iterator first, std::
string::const_iterator last);
581 iterator insert(const_iterator pos, std::wstring::const_iterator first, std::wstring::const_iterator last);
582 iterator insert(const_iterator pos, std::u16string::const_iterator first, std::u16string::const_iterator last);
583 iterator insert(const_iterator pos, std::u32string::const_iterator first, std::u32string::const_iterator last);
585 String& erase(std::
size_t index = 0, std::
size_t count = npos);
587 iterator erase(const_iterator position);
588 iterator erase(const_iterator first, const_iterator last);
590 void push_back(
char ch);
591 void push_back(
wchar_t ch);
592 void push_back(
char16_t ch);
593 void push_back(
char32_t ch);
597 String& append(std::
size_t count,
char ch);
598 String& append(std::
size_t count,
wchar_t ch);
599 String& append(std::
size_t count,
char16_t ch);
600 String& append(std::
size_t count,
char32_t ch);
602 String& append(const std::
string& str);
603 String& append(const std::wstring& str);
604 String& append(const std::u16string& str);
605 String& append(const std::u32string& str);
606 String& append(const String& str);
608 String& append(const std::
string& str, std::
size_t pos, std::
size_t count = npos);
609 String& append(const std::wstring& str, std::
size_t pos, std::
size_t count = npos);
610 String& append(const std::u16string& str, std::
size_t pos, std::
size_t count = npos);
611 String& append(const std::u32string& str, std::
size_t pos, std::
size_t count = npos);
612 String& append(const String& str, std::
size_t pos, std::
size_t count = npos);
614 String& append(const
char* str, std::
size_t count);
615 String& append(const
wchar_t* str, std::
size_t count);
616 String& append(const
char16_t* str, std::
size_t count);
617 String& append(const
char32_t* str, std::
size_t count);
619 String& append(const
char* str);
620 String& append(const
wchar_t* str);
621 String& append(const
char16_t* str);
622 String& append(const
char32_t* str);
624 String& append(std::
string::const_iterator first, std::
string::const_iterator last);
625 String& append(std::wstring::const_iterator first, std::wstring::const_iterator last);
626 String& append(std::u16string::const_iterator first, std::u16string::const_iterator last);
627 String& append(std::u32string::const_iterator first, std::u32string::const_iterator last);
629 String& append(std::initializer_list<
char> chars);
630 String& append(std::initializer_list<
wchar_t> chars);
631 String& append(std::initializer_list<
char16_t> chars);
632 String& append(std::initializer_list<
char32_t> chars);
634 String& operator+=(const String& str);
636 int compare(const std::
string& str) const noexcept;
637 int compare(const std::wstring& str) const noexcept;
638 int compare(const std::u16string& str) const noexcept;
639 int compare(const std::u32string& str) const noexcept;
640 int compare(const String& str) const noexcept;
642 int compare(std::
size_t pos1, std::
size_t count1, const std::
string& str) const;
643 int compare(std::
size_t pos1, std::
size_t count1, const std::wstring& str) const;
644 int compare(std::
size_t pos1, std::
size_t count1, const std::u16string& str) const;
645 int compare(std::
size_t pos1, std::
size_t count1, const std::u32string& str) const;
646 int compare(std::
size_t pos1, std::
size_t count1, const String& str) const;
648 int compare(std::
size_t pos1, std::
size_t count1, const std::
string& str, std::
size_t pos2, std::
size_t count2 = npos) const;
649 int compare(std::
size_t pos1, std::
size_t count1, const std::wstring& str, std::
size_t pos2, std::
size_t count2 = npos) const;
650 int compare(std::
size_t pos1, std::
size_t count1, const std::u16string& str, std::
size_t pos2, std::
size_t count2 = npos) const;
651 int compare(std::
size_t pos1, std::
size_t count1, const std::u32string& str, std::
size_t pos2, std::
size_t count2 = npos) const;
652 int compare(std::
size_t pos1, std::
size_t count1, const String& str, std::
size_t pos2, std::
size_t count2 = npos) const;
654 int compare(const
char* s) const;
655 int compare(const
wchar_t* s) const;
656 int compare(const
char16_t* s) const;
657 int compare(const
char32_t* s) const;
659 int compare(std::
size_t pos1, std::
size_t count1, const
char* s) const;
660 int compare(std::
size_t pos1, std::
size_t count1, const
wchar_t* s) const;
661 int compare(std::
size_t pos1, std::
size_t count1, const
char16_t* s) const;
662 int compare(std::
size_t pos1, std::
size_t count1, const
char32_t* s) const;
664 int compare(std::
size_t pos1, std::
size_t count1, const
char* s, std::
size_t count2) const;
665 int compare(std::
size_t pos1, std::
size_t count1, const
wchar_t* s, std::
size_t count2) const;
666 int compare(std::
size_t pos1, std::
size_t count1, const
char16_t* s, std::
size_t count2) const;
667 int compare(std::
size_t pos1, std::
size_t count1, const
char32_t* s, std::
size_t count2) const;
669 String& replace(std::
size_t pos, std::
size_t count, const std::
string& str);
670 String& replace(std::
size_t pos, std::
size_t count, const std::wstring& str);
671 String& replace(std::
size_t pos, std::
size_t count, const std::u16string& str);
672 String& replace(std::
size_t pos, std::
size_t count, const std::u32string& str);
673 String& replace(std::
size_t pos, std::
size_t count, const String& str);
675 String& replace(const_iterator first, const_iterator last, const std::
string& str);
676 String& replace(const_iterator first, const_iterator last, const std::wstring& str);
677 String& replace(const_iterator first, const_iterator last, const std::u16string& str);
678 String& replace(const_iterator first, const_iterator last, const std::u32string& str);
679 String& replace(const_iterator first, const_iterator last, const String& str);
681 String& replace(std::
size_t pos, std::
size_t count, const std::
string& str, std::
size_t pos2, std::
size_t count2 = npos);
682 String& replace(std::
size_t pos, std::
size_t count, const std::wstring& str, std::
size_t pos2, std::
size_t count2 = npos);
683 String& replace(std::
size_t pos, std::
size_t count, const std::u16string& str, std::
size_t pos2, std::
size_t count2 = npos);
684 String& replace(std::
size_t pos, std::
size_t count, const std::u32string& str, std::
size_t pos2, std::
size_t count2 = npos);
685 String& replace(std::
size_t pos, std::
size_t count, const String& str, std::
size_t pos2, std::
size_t count2 = npos);
687 String& replace(const_iterator first, const_iterator last, std::
string::const_iterator first2, std::
string::const_iterator last2);
688 String& replace(const_iterator first, const_iterator last, std::wstring::const_iterator first2, std::wstring::const_iterator last2);
689 String& replace(const_iterator first, const_iterator last, std::u16string::const_iterator first2, std::u16string::const_iterator last2);
690 String& replace(const_iterator first, const_iterator last, std::u32string::const_iterator first2, std::u32string::const_iterator last2);
692 String& replace(std::
size_t pos, std::
size_t count, const
char* cstr, std::
size_t count2);
693 String& replace(std::
size_t pos, std::
size_t count, const
wchar_t* cstr, std::
size_t count2);
694 String& replace(std::
size_t pos, std::
size_t count, const
char16_t* cstr, std::
size_t count2);
695 String& replace(std::
size_t pos, std::
size_t count, const
char32_t* cstr, std::
size_t count2);
697 String& replace(const_iterator first, const_iterator last, const
char* cstr, std::
size_t count2);
698 String& replace(const_iterator first, const_iterator last, const
wchar_t* cstr, std::
size_t count2);
699 String& replace(const_iterator first, const_iterator last, const
char16_t* cstr, std::
size_t count2);
700 String& replace(const_iterator first, const_iterator last, const
char32_t* cstr, std::
size_t count2);
702 String& replace(std::
size_t pos, std::
size_t count, const
char* cstr);
703 String& replace(std::
size_t pos, std::
size_t count, const
wchar_t* cstr);
704 String& replace(std::
size_t pos, std::
size_t count, const
char16_t* cstr);
705 String& replace(std::
size_t pos, std::
size_t count, const
char32_t* cstr);
707 String& replace(const_iterator first, const_iterator last, const
char* cstr);
708 String& replace(const_iterator first, const_iterator last, const
wchar_t* cstr);
709 String& replace(const_iterator first, const_iterator last, const
char16_t* cstr);
710 String& replace(const_iterator first, const_iterator last, const
char32_t* cstr);
712 String& replace(std::
size_t pos, std::
size_t count, std::
size_t count2,
char ch);
713 String& replace(std::
size_t pos, std::
size_t count, std::
size_t count2,
wchar_t ch);
714 String& replace(std::
size_t pos, std::
size_t count, std::
size_t count2,
char16_t ch);
715 String& replace(std::
size_t pos, std::
size_t count, std::
size_t count2,
char32_t ch);
717 String& replace(const_iterator first, const_iterator last, std::
size_t count2,
char ch);
718 String& replace(const_iterator first, const_iterator last, std::
size_t count2,
wchar_t ch);
719 String& replace(const_iterator first, const_iterator last, std::
size_t count2,
char16_t ch);
720 String& replace(const_iterator first, const_iterator last, std::
size_t count2,
char32_t ch);
722 String& replace(const_iterator first, const_iterator last, std::initializer_list<
char> chars);
723 String& replace(const_iterator first, const_iterator last, std::initializer_list<
wchar_t> chars);
724 String& replace(const_iterator first, const_iterator last, std::initializer_list<
char16_t> chars);
725 String& replace(const_iterator first, const_iterator last, std::initializer_list<
char32_t> chars);
727 String substr(std::
size_t pos = 0, std::
size_t count = npos) const;
729 std::
size_t copy(
char32_t* dest, std::
size_t count, std::
size_t pos = 0) const;
731 void resize(std::
size_t count);
732 void resize(std::
size_t count,
char ch);
733 void resize(std::
size_t count,
wchar_t ch);
734 void resize(std::
size_t count,
char16_t ch);
735 void resize(std::
size_t count,
char32_t ch);
737 void swap(String& other);
739#if TGUI_COMPILED_WITH_CPP_VER >= 17
740 bool contains(std::u32string_view sv)
const noexcept;
743 bool contains(
char c)
const noexcept;
744 bool contains(
wchar_t c)
const noexcept;
745 bool contains(
char16_t c)
const noexcept;
746 bool contains(
char32_t c)
const noexcept;
748 bool contains(
const char* s)
const;
749 bool contains(
const wchar_t* s)
const;
750 bool contains(
const char16_t* s)
const;
751 bool contains(
const char32_t* s)
const;
753 std::size_t find(
const std::string& str, std::size_t pos = 0) const noexcept;
754 std::
size_t find(const std::wstring& str, std::
size_t pos = 0) const noexcept;
755 std::
size_t find(const std::u16string& str, std::
size_t pos = 0) const noexcept;
756 std::
size_t find(const std::u32string& str, std::
size_t pos = 0) const noexcept;
757 std::
size_t find(const String& str, std::
size_t pos = 0) const noexcept;
759 std::
size_t find(const
char* s, std::
size_t pos, std::
size_t count) const;
760 std::
size_t find(const
wchar_t* s, std::
size_t pos, std::
size_t count) const;
761 std::
size_t find(const
char16_t* s, std::
size_t pos, std::
size_t count) const;
762 std::
size_t find(const
char32_t* s, std::
size_t pos, std::
size_t count) const;
764 std::
size_t find(const
char* s, std::
size_t pos = 0) const;
765 std::
size_t find(const
wchar_t* s, std::
size_t pos = 0) const;
766 std::
size_t find(const
char16_t* s, std::
size_t pos = 0) const;
767 std::
size_t find(const
char32_t* s, std::
size_t pos = 0) const;
769 std::
size_t find(
char ch, std::
size_t pos = 0) const noexcept;
770 std::
size_t find(
wchar_t ch, std::
size_t pos = 0) const noexcept;
771 std::
size_t find(
char16_t ch, std::
size_t pos = 0) const noexcept;
772 std::
size_t find(
char32_t ch, std::
size_t pos = 0) const noexcept;
774#if TGUI_COMPILED_WITH_CPP_VER >= 17
775 std::size_t find(std::u32string_view sv, std::size_t pos = 0) const noexcept;
778 std::size_t find_first_of(
const std::string& str, std::size_t pos = 0) const noexcept;
779 std::
size_t find_first_of(const std::wstring& str, std::
size_t pos = 0) const noexcept;
780 std::
size_t find_first_of(const std::u16string& str, std::
size_t pos = 0) const noexcept;
781 std::
size_t find_first_of(const std::u32string& str, std::
size_t pos = 0) const noexcept;
782 std::
size_t find_first_of(const String& str, std::
size_t pos = 0) const noexcept;
784 std::
size_t find_first_of(const
char* s, std::
size_t pos, std::
size_t count) const;
785 std::
size_t find_first_of(const
wchar_t* s, std::
size_t pos, std::
size_t count) const;
786 std::
size_t find_first_of(const
char16_t* s, std::
size_t pos, std::
size_t count) const;
787 std::
size_t find_first_of(const
char32_t* s, std::
size_t pos, std::
size_t count) const;
789 std::
size_t find_first_of(const
char* s, std::
size_t pos = 0) const;
790 std::
size_t find_first_of(const
wchar_t* s, std::
size_t pos = 0) const;
791 std::
size_t find_first_of(const
char16_t* s, std::
size_t pos = 0) const;
792 std::
size_t find_first_of(const
char32_t* s, std::
size_t pos = 0) const;
794 std::
size_t find_first_of(
char ch, std::
size_t pos = 0) const noexcept;
795 std::
size_t find_first_of(
wchar_t ch, std::
size_t pos = 0) const noexcept;
796 std::
size_t find_first_of(
char16_t ch, std::
size_t pos = 0) const noexcept;
797 std::
size_t find_first_of(
char32_t ch, std::
size_t pos = 0) const noexcept;
799 std::
size_t find_first_not_of(const std::
string& str, std::
size_t pos = 0) const noexcept;
800 std::
size_t find_first_not_of(const std::wstring& str, std::
size_t pos = 0) const noexcept;
801 std::
size_t find_first_not_of(const std::u16string& str, std::
size_t pos = 0) const noexcept;
802 std::
size_t find_first_not_of(const std::u32string& str, std::
size_t pos = 0) const noexcept;
803 std::
size_t find_first_not_of(const String& str, std::
size_t pos = 0) const noexcept;
805 std::
size_t find_first_not_of(const
char* s, std::
size_t pos, std::
size_t count) const;
806 std::
size_t find_first_not_of(const
wchar_t* s, std::
size_t pos, std::
size_t count) const;
807 std::
size_t find_first_not_of(const
char16_t* s, std::
size_t pos, std::
size_t count) const;
808 std::
size_t find_first_not_of(const
char32_t* s, std::
size_t pos, std::
size_t count) const;
810 std::
size_t find_first_not_of(const
char* s, std::
size_t pos = 0) const;
811 std::
size_t find_first_not_of(const
wchar_t* s, std::
size_t pos = 0) const;
812 std::
size_t find_first_not_of(const
char16_t* s, std::
size_t pos = 0) const;
813 std::
size_t find_first_not_of(const
char32_t* s, std::
size_t pos = 0) const;
815 std::
size_t find_first_not_of(
char ch, std::
size_t pos = 0) const noexcept;
816 std::
size_t find_first_not_of(
wchar_t ch, std::
size_t pos = 0) const noexcept;
817 std::
size_t find_first_not_of(
char16_t ch, std::
size_t pos = 0) const noexcept;
818 std::
size_t find_first_not_of(
char32_t ch, std::
size_t pos = 0) const noexcept;
820 std::
size_t rfind(const std::
string& str, std::
size_t pos = npos) const noexcept;
821 std::
size_t rfind(const std::wstring& str, std::
size_t pos = npos) const noexcept;
822 std::
size_t rfind(const std::u16string& str, std::
size_t pos = npos) const noexcept;
823 std::
size_t rfind(const std::u32string& str, std::
size_t pos = npos) const noexcept;
824 std::
size_t rfind(const String& str, std::
size_t pos = npos) const noexcept;
826 std::
size_t rfind(const
char* s, std::
size_t pos, std::
size_t count) const;
827 std::
size_t rfind(const
wchar_t* s, std::
size_t pos, std::
size_t count) const;
828 std::
size_t rfind(const
char16_t* s, std::
size_t pos, std::
size_t count) const;
829 std::
size_t rfind(const
char32_t* s, std::
size_t pos, std::
size_t count) const;
831 std::
size_t rfind(const
char* s, std::
size_t pos = npos) const;
832 std::
size_t rfind(const
wchar_t* s, std::
size_t pos = npos) const;
833 std::
size_t rfind(const
char16_t* s, std::
size_t pos = npos) const;
834 std::
size_t rfind(const
char32_t* s, std::
size_t pos = npos) const;
836 std::
size_t rfind(
char ch, std::
size_t pos = npos) const noexcept;
837 std::
size_t rfind(
wchar_t ch, std::
size_t pos = npos) const noexcept;
838 std::
size_t rfind(
char16_t ch, std::
size_t pos = npos) const noexcept;
839 std::
size_t rfind(
char32_t ch, std::
size_t pos = npos) const noexcept;
841 std::
size_t find_last_of(const std::
string& str, std::
size_t pos = npos) const noexcept;
842 std::
size_t find_last_of(const std::wstring& str, std::
size_t pos = npos) const noexcept;
843 std::
size_t find_last_of(const std::u16string& str, std::
size_t pos = npos) const noexcept;
844 std::
size_t find_last_of(const std::u32string& str, std::
size_t pos = npos) const noexcept;
845 std::
size_t find_last_of(const String& str, std::
size_t pos = npos) const noexcept;
847 std::
size_t find_last_of(const
char* s, std::
size_t pos, std::
size_t count) const;
848 std::
size_t find_last_of(const
wchar_t* s, std::
size_t pos, std::
size_t count) const;
849 std::
size_t find_last_of(const
char16_t* s, std::
size_t pos, std::
size_t count) const;
850 std::
size_t find_last_of(const
char32_t* s, std::
size_t pos, std::
size_t count) const;
852 std::
size_t find_last_of(const
char* s, std::
size_t pos = npos) const;
853 std::
size_t find_last_of(const
wchar_t* s, std::
size_t pos = npos) const;
854 std::
size_t find_last_of(const
char16_t* s, std::
size_t pos = npos) const;
855 std::
size_t find_last_of(const
char32_t* s, std::
size_t pos = npos) const;
857 std::
size_t find_last_of(
char ch, std::
size_t pos = npos) const noexcept;
858 std::
size_t find_last_of(
wchar_t ch, std::
size_t pos = npos) const noexcept;
859 std::
size_t find_last_of(
char16_t ch, std::
size_t pos = npos) const noexcept;
860 std::
size_t find_last_of(
char32_t ch, std::
size_t pos = npos) const noexcept;
862 std::
size_t find_last_not_of(const std::
string& str, std::
size_t pos = npos) const noexcept;
863 std::
size_t find_last_not_of(const std::wstring& str, std::
size_t pos = npos) const noexcept;
864 std::
size_t find_last_not_of(const std::u16string& str, std::
size_t pos = npos) const noexcept;
865 std::
size_t find_last_not_of(const std::u32string& str, std::
size_t pos = npos) const noexcept;
866 std::
size_t find_last_not_of(const String& str, std::
size_t pos = npos) const noexcept;
868 std::
size_t find_last_not_of(const
char* s, std::
size_t pos, std::
size_t count) const;
869 std::
size_t find_last_not_of(const
wchar_t* s, std::
size_t pos, std::
size_t count) const;
870 std::
size_t find_last_not_of(const
char16_t* s, std::
size_t pos, std::
size_t count) const;
871 std::
size_t find_last_not_of(const
char32_t* s, std::
size_t pos, std::
size_t count) const;
873 std::
size_t find_last_not_of(const
char* s, std::
size_t pos = npos) const;
874 std::
size_t find_last_not_of(const
wchar_t* s, std::
size_t pos = npos) const;
875 std::
size_t find_last_not_of(const
char16_t* s, std::
size_t pos = npos) const;
876 std::
size_t find_last_not_of(const
char32_t* s, std::
size_t pos = npos) const;
878 std::
size_t find_last_not_of(
char ch, std::
size_t pos = npos) const noexcept;
879 std::
size_t find_last_not_of(
wchar_t ch, std::
size_t pos = npos) const noexcept;
880 std::
size_t find_last_not_of(
char16_t ch, std::
size_t pos = npos) const noexcept;
881 std::
size_t find_last_not_of(
char32_t ch, std::
size_t pos = npos) const noexcept;
883 friend
bool operator==(const String& left, const String& right);
884 friend
bool operator!=(const String& left, const String& right);
885 friend
bool operator<(const String& left, const String& right);
886 friend
bool operator<=(const String& left, const String& right);
887 friend
bool operator>(const String& left, const String& right);
888 friend
bool operator>=(const String& left, const String& right);
889 friend String operator+(const String& left, const String& right);
890 friend String operator+(const String& left, String&& right);
891 friend String operator+(String&& left, const String& right);
892 friend String operator+(String&& left, String&& right);
894#if defined(__cpp_lib_char8_t) && (__cpp_lib_char8_t >= 201811L)
895 String(
const std::u8string& str);
896 String(
char8_t utfChar);
897 String(
const char8_t* str);
898 String(std::size_t count,
char8_t ch);
899 String(
const std::u8string& str, std::size_t pos);
900 String(
const std::u8string& str, std::size_t pos, std::size_t count);
901 String(
const char8_t* str, std::size_t count);
902 String(std::initializer_list<char8_t> chars);
903 String(std::u8string::const_iterator first, std::u8string::const_iterator last);
905 explicit operator std::u8string()
const;
907 std::u8string toUtf8()
const;
909 String& assign(std::size_t count,
char8_t ch);
910 String& assign(
const std::u8string& str);
911 String& assign(
const std::u8string& str, std::size_t pos, std::size_t count = npos);
912 String& assign(std::u8string&& str);
913 String& assign(
const char8_t* str, std::size_t count);
914 String& assign(
const char8_t* str);
915 String& assign(std::initializer_list<char8_t> chars);
916 String& assign(std::u8string::const_iterator first, std::u8string::const_iterator last);
918 String& insert(std::size_t index, std::size_t count,
char8_t ch);
919 String& insert(std::size_t index,
const std::u8string& str);
920 String& insert(std::size_t index,
const std::u8string& str, std::size_t pos, std::size_t count = npos);
921 String& insert(std::size_t index,
const char8_t* str, std::size_t count);
922 String& insert(std::size_t index,
const char8_t* str);
923 iterator insert(const_iterator pos,
char8_t ch);
924 iterator insert(const_iterator pos, std::size_t count,
char8_t ch);
925 iterator insert(const_iterator pos, std::initializer_list<char8_t> chars);
926 iterator insert(const_iterator pos, std::u8string::const_iterator first, std::u8string::const_iterator last);
928 String& append(std::size_t count,
char8_t ch);
929 String& append(
const std::u8string& str);
930 String& append(
const std::u8string& str, std::size_t pos, std::size_t count = npos);
931 String& append(
const char8_t* str, std::size_t count);
932 String& append(
const char8_t* str);
933 String& append(std::initializer_list<char8_t> chars);
934 String& append(std::u8string::const_iterator first, std::u8string::const_iterator last);
936 int compare(
const std::u8string& str)
const noexcept;
937 int compare(std::size_t pos1, std::size_t count1,
const std::u8string& str)
const;
938 int compare(std::size_t pos1, std::size_t count1,
const std::u8string& str, std::size_t pos2, std::size_t count2 = npos)
const;
939 int compare(
const char8_t* s)
const;
940 int compare(std::size_t pos1, std::size_t count1,
const char8_t* s)
const;
941 int compare(std::size_t pos1, std::size_t count1,
const char8_t* s, std::size_t count2)
const;
943 String& replace(std::size_t pos, std::size_t count,
const std::u8string& str);
944 String& replace(const_iterator first, const_iterator last,
const std::u8string& str);
945 String& replace(std::size_t pos, std::size_t count,
const std::u8string& str, std::size_t pos2, std::size_t count2 = npos);
946 String& replace(const_iterator first, const_iterator last, std::u8string::const_iterator first2, std::u8string::const_iterator last2);
947 String& replace(std::size_t pos, std::size_t count,
const char8_t* cstr, std::size_t count2);
948 String& replace(const_iterator first, const_iterator last,
const char8_t* cstr, std::size_t count2);
949 String& replace(std::size_t pos, std::size_t count,
const char8_t* cstr);
950 String& replace(const_iterator first, const_iterator last,
const char8_t* cstr);
951 String& replace(std::size_t pos, std::size_t count, std::size_t count2,
char8_t ch);
952 String& replace(const_iterator first, const_iterator last, std::size_t count2,
char8_t ch);
953 String& replace(const_iterator first, const_iterator last, std::initializer_list<char8_t> chars);
955 void resize(std::size_t count,
char8_t ch);
957 bool contains(
char8_t c)
const noexcept;
958 bool contains(
const char8_t* s)
const noexcept;
960 std::size_t find(
const std::u8string& str, std::size_t pos = 0) const noexcept;
961 std::
size_t find(const
char8_t* s, std::
size_t pos, std::
size_t count) const;
962 std::
size_t find(const
char8_t* s, std::
size_t pos = 0) const;
963 std::
size_t find(
char8_t ch, std::
size_t pos = 0) const noexcept;
965 std::
size_t find_first_of(const std::u8string& str, std::
size_t pos = 0) const noexcept;
966 std::
size_t find_first_of(const
char8_t* s, std::
size_t pos, std::
size_t count) const;
967 std::
size_t find_first_of(const
char8_t* s, std::
size_t pos = 0) const;
968 std::
size_t find_first_of(
char8_t ch, std::
size_t pos = 0) const noexcept;
970 std::
size_t find_first_not_of(const std::u8string& str, std::
size_t pos = 0) const noexcept;
971 std::
size_t find_first_not_of(const
char8_t* s, std::
size_t pos, std::
size_t count) const;
972 std::
size_t find_first_not_of(const
char8_t* s, std::
size_t pos = 0) const;
973 std::
size_t find_first_not_of(
char8_t ch, std::
size_t pos = 0) const noexcept;
975 std::
size_t rfind(const std::u8string& str, std::
size_t pos = npos) const noexcept;
976 std::
size_t rfind(const
char8_t* s, std::
size_t pos, std::
size_t count) const;
977 std::
size_t rfind(const
char8_t* s, std::
size_t pos = npos) const;
978 std::
size_t rfind(
char8_t ch, std::
size_t pos = npos) const noexcept;
980 std::
size_t find_last_of(const std::u8string& str, std::
size_t pos = npos) const noexcept;
981 std::
size_t find_last_of(const
char8_t* s, std::
size_t pos, std::
size_t count) const;
982 std::
size_t find_last_of(const
char8_t* s, std::
size_t pos = npos) const;
983 std::
size_t find_last_of(
char8_t ch, std::
size_t pos = npos) const noexcept;
985 std::
size_t find_last_not_of(const std::u8string& str, std::
size_t pos = npos) const noexcept;
986 std::
size_t find_last_not_of(const
char8_t* s, std::
size_t pos, std::
size_t count) const;
987 std::
size_t find_last_not_of(const
char8_t* s, std::
size_t pos = npos) const;
988 std::
size_t find_last_not_of(
char8_t ch, std::
size_t pos = npos) const noexcept;
996 inline bool operator==(
const String& left,
const String& right)
998 return left.m_string == right.m_string;
1001 inline bool operator!=(
const String& left,
const String& right)
1003 return left.m_string != right.m_string;
1006 inline bool operator<(
const String& left,
const String& right)
1008 return left.m_string < right.m_string;
1011 inline bool operator<=(
const String& left,
const String& right)
1013 return left.m_string <= right.m_string;
1016 inline bool operator>(
const String& left,
const String& right)
1018 return left.m_string > right.m_string;
1021 inline bool operator>=(
const String& left,
const String& right)
1023 return left.m_string >= right.m_string;
1026 inline String operator+(
const String& left,
const String& right)
1028 return String(left.m_string + right.m_string);
1030 inline String operator+(String&& left, String&& right)
1032 return String(std::move(left.m_string) + std::move(right.m_string));
1034 inline String operator+(String&& left,
const String& right)
1036 return String(std::move(left.m_string) + right.m_string);
1038 inline String operator+(
const String& left, String&& right)
1040 return String(left.m_string + std::move(right.m_string));
1043 TGUI_API std::basic_ostream<char>& operator<<(std::basic_ostream<char>& os,
const String& str);
1044 TGUI_API std::basic_ostream<wchar_t>& operator<<(std::basic_ostream<wchar_t>& os,
const String& str);
1051#if defined(__cpp_lib_char8_t) && (__cpp_lib_char8_t >= 201811L)
1052 inline String::String(
const std::u8string& str) :
1053 m_string(utf::convertUtf8toUtf32(str.begin(), str.end()))
1057 inline String::String(
char8_t utfChar)
1058 : m_string(1, static_cast<char32_t>(utfChar))
1062 inline String::String(
const char8_t* str)
1063 : String{utf::convertUtf8toUtf32(str, str + std::char_traits<char8_t>::length(str))}
1067 inline String::String(std::size_t count,
char8_t ch)
1068 : m_string(count, static_cast<char32_t>(ch))
1072 inline String::String(
const std::u8string& str, std::size_t pos)
1073 : String{std::u8string(str, pos)}
1077 inline String::String(
const std::u8string& str, std::size_t pos, std::size_t count)
1078 : String{std::u8string(str, pos, count)}
1082 inline String::String(
const char8_t* str, std::size_t count)
1083 : String{std::u8string{str, count}}
1087 inline String::String(std::initializer_list<char8_t> chars)
1088 : String(std::u8string(chars.begin(), chars.end()))
1092 inline String::String(std::u8string::const_iterator first, std::u8string::const_iterator last)
1093 : String{std::u8string(first, last)}
1097 inline String::operator std::u8string()
const
1102 inline std::u8string String::toUtf8()
const
1104 return utf::convertUtf32toUtf8(m_string);
1107 inline String& String::assign(std::size_t count,
char8_t ch)
1109 m_string.assign(count,
static_cast<char32_t>(ch));
1113 inline String& String::assign(
const std::u8string& str)
1118 inline String& String::assign(
const std::u8string& str, std::size_t pos, std::size_t count)
1120 return *
this = {str, pos, count};
1123 inline String& String::assign(std::u8string&& str)
1125 return *
this = std::move(str);
1128 inline String& String::assign(
const char8_t* str, std::size_t count)
1130 return *
this = {str, count};
1133 inline String& String::assign(
const char8_t* str)
1138 inline String& String::assign(std::initializer_list<char8_t> chars)
1140 return *
this = chars;
1143 inline String& String::assign(std::u8string::const_iterator first, std::u8string::const_iterator last)
1145 return *
this = {first, last};
1148 inline String& String::insert(std::size_t index, std::size_t count,
char8_t ch)
1150 m_string.insert(index, count,
static_cast<char32_t>(ch));
1154 inline String& String::insert(std::size_t index,
const std::u8string& str)
1156 m_string.insert(index, String{str}.m_string);
1160 inline String& String::insert(std::size_t index,
const std::u8string& str, std::size_t pos, std::size_t count)
1162 m_string.insert(index, String{str, pos, count}.m_string);
1166 inline String& String::insert(std::size_t index,
const char8_t* str, std::size_t count)
1168 m_string.insert(index, String{str, count}.m_string);
1172 inline String& String::insert(std::size_t index,
const char8_t* str)
1174 m_string.insert(index, String{str}.m_string);
1178 inline String::iterator String::insert(String::const_iterator pos,
char8_t ch)
1180 return m_string.insert(pos,
static_cast<char32_t>(ch));
1183 inline String::iterator String::insert(String::const_iterator pos, std::size_t count,
char8_t ch)
1185 return m_string.insert(pos, count,
static_cast<char32_t>(ch));
1188 inline String::iterator String::insert(String::const_iterator pos, std::initializer_list<char8_t> chars)
1190 auto tmpStr = String{chars};
1191 return m_string.insert(pos, tmpStr.begin(), tmpStr.end());
1194 inline String::iterator String::insert(String::const_iterator pos, std::u8string::const_iterator first, std::u8string::const_iterator last)
1196 auto tmpStr = String{first, last};
1197 return m_string.insert(pos, tmpStr.begin(), tmpStr.end());
1200 inline String& String::append(std::size_t count,
char8_t ch)
1202 return append(String(count, ch));
1205 inline String& String::append(
const std::u8string& str)
1207 return append(String{str});
1210 inline String& String::append(
const std::u8string& str, std::size_t pos, std::size_t count)
1212 return append(String{str, pos, count});
1215 inline String& String::append(
const char8_t* str, std::size_t count)
1217 return append(String{str, count});
1220 inline String& String::append(
const char8_t* str)
1222 return append(String{str});
1225 inline String& String::append(std::initializer_list<char8_t> chars)
1227 return append(String{chars});
1230 inline String& String::append(std::u8string::const_iterator first, std::u8string::const_iterator last)
1232 return append(String{first, last});
1235 inline int String::compare(
const std::u8string& str)
const noexcept
1237 return m_string.compare(String{str}.m_string);
1240 inline int String::compare(std::size_t pos1, std::size_t count1,
const std::u8string& str)
const
1242 return m_string.compare(pos1, count1, String{str}.m_string);
1245 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
1247 return m_string.compare(pos1, count1, String{str, pos2, count2}.m_string);
1250 inline int String::compare(
const char8_t* s)
const
1252 return m_string.compare(String{s}.m_string);
1255 inline int String::compare(std::size_t pos1, std::size_t count1,
const char8_t* s)
const
1257 return m_string.compare(pos1, count1, String{s}.m_string);
1260 inline int String::compare(std::size_t pos1, std::size_t count1,
const char8_t* s, std::size_t count2)
const
1262 return m_string.compare(pos1, count1, String{s, count2}.m_string);
1265 inline String&
String::replace(std::size_t pos, std::size_t count,
const std::u8string& str)
1267 m_string.
replace(pos, count, String{str}.m_string);
1271 inline String&
String::replace(const_iterator first, const_iterator last,
const std::u8string& str)
1273 m_string.
replace(first, last, String{str}.m_string);
1277 inline String&
String::replace(std::size_t pos, std::size_t count,
const std::u8string& str, std::size_t pos2, std::size_t count2)
1279 m_string.
replace(pos, count, String{str, pos2, count2}.m_string);
1283 inline String&
String::replace(const_iterator first, const_iterator last, std::u8string::const_iterator first2, std::u8string::const_iterator last2)
1285 m_string.
replace(first, last, String{first2, last2}.m_string);
1289 inline String&
String::replace(std::size_t pos, std::size_t count,
const char8_t* cstr, std::size_t count2)
1291 m_string.
replace(pos, count, String{cstr, count2}.m_string);
1295 inline String&
String::replace(const_iterator first, const_iterator last,
const char8_t* cstr, std::size_t count2)
1297 m_string.
replace(first, last, String{cstr, count2}.m_string);
1301 inline String&
String::replace(std::size_t pos, std::size_t count,
const char8_t* cstr)
1303 m_string.
replace(pos, count, String{cstr}.m_string);
1307 inline String&
String::replace(const_iterator first, const_iterator last,
const char8_t* cstr)
1309 m_string.
replace(first, last, String{cstr}.m_string);
1313 inline String&
String::replace(std::size_t pos, std::size_t count, std::size_t count2,
char8_t ch)
1315 m_string.
replace(pos, count, String(count2, ch).m_string);
1319 inline String&
String::replace(const_iterator first, const_iterator last, std::size_t count2,
char8_t ch)
1321 m_string.
replace(first, last, String(count2, ch).m_string);
1325 inline String&
String::replace(const_iterator first, const_iterator last, std::initializer_list<char8_t> chars)
1327 m_string.
replace(first, last, String{chars}.m_string);
1331 inline void String::resize(std::size_t count,
char8_t ch)
1333 m_string.resize(count,
static_cast<char32_t>(ch));
1336 inline bool String::contains(
char8_t c)
const noexcept
1338 return contains(
static_cast<char32_t>(c));
1341 inline bool String::contains(
const char8_t* s)
const noexcept
1343 return find(s) != npos;
1346 inline std::size_t String::find(
const std::u8string& str, std::size_t pos)
const noexcept
1348 return m_string.find(String{str}.m_string, pos);
1351 inline std::size_t String::find(
const char8_t* s, std::size_t pos, std::size_t count)
const
1353 return m_string.find(String{s, count}.m_string, pos);
1356 inline std::size_t String::find(
const char8_t* s, std::size_t pos)
const
1358 return m_string.find(String{s}.m_string, pos);
1361 inline std::size_t String::find(
char8_t ch, std::size_t pos)
const noexcept
1363 return m_string.find(
static_cast<char32_t>(ch), pos);
1366 inline std::size_t String::find_first_of(
const std::u8string& str, std::size_t pos)
const noexcept
1368 return m_string.find_first_of(String{str}.m_string, pos);
1371 inline std::size_t String::find_first_of(
const char8_t* s, std::size_t pos, std::size_t count)
const
1373 return m_string.find_first_of(String{s, count}.m_string, pos);
1376 inline std::size_t String::find_first_of(
const char8_t* s, std::size_t pos)
const
1378 return m_string.find_first_of(String{s}.m_string, pos);
1381 inline std::size_t String::find_first_of(
char8_t ch, std::size_t pos)
const noexcept
1383 return m_string.find_first_of(
static_cast<char32_t>(ch), pos);
1386 inline std::size_t String::find_first_not_of(
const std::u8string& str, std::size_t pos)
const noexcept
1388 return m_string.find_first_not_of(String{str}.m_string, pos);
1391 inline std::size_t String::find_first_not_of(
const char8_t* s, std::size_t pos, std::size_t count)
const
1393 return m_string.find_first_not_of(String{s, count}.m_string, pos);
1396 inline std::size_t String::find_first_not_of(
const char8_t* s, std::size_t pos)
const
1398 return m_string.find_first_not_of(String{s}.m_string, pos);
1401 inline std::size_t String::find_first_not_of(
char8_t ch, std::size_t pos)
const noexcept
1403 return m_string.find_first_not_of(
static_cast<char32_t>(ch), pos);
1406 inline std::size_t String::rfind(
const std::u8string& str, std::size_t pos)
const noexcept
1408 return m_string.rfind(String{str}.m_string, pos);
1411 inline std::size_t String::rfind(
const char8_t* s, std::size_t pos, std::size_t count)
const
1413 return m_string.rfind(String{s, count}.m_string, pos);
1416 inline std::size_t String::rfind(
const char8_t* s, std::size_t pos)
const
1418 return m_string.rfind(String{s}.m_string, pos);
1421 inline std::size_t String::rfind(
char8_t ch, std::size_t pos)
const noexcept
1423 return m_string.rfind(
static_cast<char32_t>(ch), pos);
1426 inline std::size_t String::find_last_of(
const std::u8string& str, std::size_t pos)
const noexcept
1428 return m_string.find_last_of(String{str}.m_string, pos);
1431 inline std::size_t String::find_last_of(
const char8_t* s, std::size_t pos, std::size_t count)
const
1433 return m_string.find_last_of(String{s, count}.m_string, pos);
1436 inline std::size_t String::find_last_of(
const char8_t* s, std::size_t pos)
const
1438 return m_string.find_last_of(String{s}.m_string, pos);
1441 inline std::size_t String::find_last_of(
char8_t ch, std::size_t pos)
const noexcept
1443 return m_string.find_last_of(
static_cast<char32_t>(ch), pos);
1446 inline std::size_t String::find_last_not_of(
const std::u8string& str, std::size_t pos)
const noexcept
1448 return m_string.find_last_not_of(String{str}.m_string, pos);
1451 inline std::size_t String::find_last_not_of(
const char8_t* s, std::size_t pos, std::size_t count)
const
1453 return m_string.find_last_not_of(String{s, count}.m_string, pos);
1456 inline std::size_t String::find_last_not_of(
const char8_t* s, std::size_t pos)
const
1458 return m_string.find_last_not_of(String{s}.m_string, pos);
1461 inline std::size_t String::find_last_not_of(
char8_t ch, std::size_t pos)
const noexcept
1463 return m_string.find_last_not_of(
static_cast<char8_t>(ch), pos);
1476#if TGUI_COMPILED_WITH_CPP_VER >= 17
1477 using StringView = std::u32string_view;
1478 using CharStringView = std::string_view;
1480 using StringView = String;
1481 using CharStringView = std::string;
Wrapper class to store strings.
Definition: String.hpp:79
bool endsWithIgnoreCase(const String &substring) const
Checks whether the last part of the string matches the given substring, case-insensitive.
bool attemptToFloat(float &result) const
Converts the string to a float.
std::vector< String > split(char32_t delimiter, bool trim=false) const
Splits the string into multiple substrings given the delimiter that separates them.
float toFloat(float defaultValue=0) const
Converts the string to a float.
static String fromNumberRounded(T value, int decimals)
Construct the string from a floating point number, keeping only a certain amount of decimals behind t...
Definition: String.hpp:302
bool equalIgnoreCase(const String &other) const
Compares this string to another and checks if they are equal if ASCII letters would have been lowerca...
bool startsWith(const String &substring) const
Checks whether the first part of the string matches the given substring.
static String fromNumber(T value)
Construct the string from a number.
Definition: String.hpp:284
static String join(const std::vector< String > &segments, const String &separator)
Joins multiple string segments into a single string.
bool endsWith(const String &substring) const
Checks whether the last part of the string matches the given substring.
bool attemptToUInt(unsigned int &result) const
Converts the string to an unsigned int.
String trim() const
Returns a string with the whitespace at the start and end of this string removed.
bool startsWithIgnoreCase(const String &substring) const
Checks whether the first part of the string matches the given substring, case-insensitive.
unsigned int toUInt(unsigned int defaultValue=0) const
Converts the string to an unsigned int.
int toInt(int defaultValue=0) const
Converts the string to an integer.
String toLower() const
Converts the ASCII characters in the string to lowercase.
bool attemptToInt(int &result) const
Converts the string to an integer.
String & replace(const String &searchFor, const String &replaceWith)
Replaces all occurrences of a substring with a replacement string.
String toUpper() const
Converts the ASCII characters in the string to uppercase.
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
TGUI_API bool isWhitespace(char character)
Checks if a character is a whitespace character (space, tab, carriage return or line feed)