xtd 0.2.0
xtd::basic_string< char_t, traits_t, allocator_t > Class Template Reference
Inheritance diagram for xtd::basic_string< char_t, traits_t, allocator_t >:
xtd::object xtd::icomparable< basic_string< char_t, traits_t, allocator_t > > xtd::iequatable< basic_string< char_t, traits_t, allocator_t > > xtd::collections::generic::ienumerable< char_t > xtd::interface xtd::extensions::comparison_operators< basic_string< char_t, traits_t, allocator_t >, icomparable< basic_string< char_t, traits_t, allocator_t > > > xtd::interface xtd::extensions::equality_operators< basic_string< char_t, traits_t, allocator_t >, iequatable< basic_string< char_t, traits_t, allocator_t > > > xtd::interface xtd::collections::generic::extensions::enumerable_iterators< char_t, xtd::collections::generic::ienumerable< char_t > > xtd::collections::generic::extensions::enumerable< ienumerable< char_t >, char_t >

Definition

template<class char_t, class traits_t, class allocator_t>
class xtd::basic_string< char_t, traits_t, allocator_t >

Represents text as a sequence of character units.

Namespace
xtd
Library
xtd.core
Remarks
A basic_string is a sequential collection of characters that's used to represent text. A xtd::basic_string object is a sequential collection of char that represent a basic_string. The value of the xtd::basic_string object is the content of the sequential collection of char_t, and unlike std::basic_string<char_t> that value is immutable (that is, it is read-only).
If you want the same mutable basic_string class, you can use xtd::text::basic_string_builder <char_t> class.
xtd::basic_string implements std::basic_string<char> and therefore offers the full (immutable) API of std::basic_string.
Several aliases for common character types are provided:
Type Definition
xtd::string xtd::basic_string <char>
xtd::u16string xtd::basic_string <xtd::char16>
xtd::u32string xtd::basic_string <xtd::char32>
xtd::u8string xtd::basic_string <xtd::char8>
xtd::wstring xtd::basic_string <xtd::wchar>
Namespace
xtd
Library
xtd.core
Remarks
A basic_string is a sequential collection of characters that's used to represent text. A xtd::basic_string object is a sequential collection of char that represent a basic_string. The value of the xtd::basic_string object is the content of the sequential collection of char_t, and unlike std::basic_string<char_t> that value is immutable (that is, it is read-only).
If you want the same mutable basic_string class, you can use xtd::text::basic_string_builder <char_t> class.
xtd::basic_string implements std::basic_string<char> and therefore offers the full (immutable) API of std::string.

Public Methods

Returns a reference to the character at specified location pos. /

/

/ /

Returns
Reference to the requested character. /
Exceptions
xtd::index_out_of_range_exceptionIf `index` is not within the range of the string. const_reference at(size_type pos) const {return operator [](pos);}

/ Compares two character sequences. /

Parameters
strThe other string to compare to. /
Returns
/ * Negative value if *this appears before the character sequence specified by the arguments, in lexicographical order. / * Zero if both character sequences compare equivalent. / * Positive value if *this appears after the character sequence specified by the arguments, in lexicographical order. /
Remarks
Compares this string to str. /
A character sequence consisting of count1 characters starting at data1 is compared to a character sequence consisting of count2 characters starting at data2 as follows: / * First, calculate the number of characters to compare, as if by size_type rlen = std::min(count1, count2). / * Then compare the sequences by calling traits_t::compare(data1, data2, rlen). For standard strings this function performs character-by-character lexicographical comparison. If the result is zero (the character sequences are equal so far), then their sizes are compared as follows: /
/ | Condition | Result | Return value | / | ----------------------------------------------------------— | ----------------------------— | ---------— | / | traits_t::compare(data1, data2, rlen) < 0 | data1 is less than data2 | < 0 | / | traits_t::compare(data1, data2, rlen) == 0 and size1 < size2 | data1 is less than data2 | < 0 | / | traits_t::compare(data1, data2, rlen) == 0 and size1 == size2 | data1 is equal to data2 | 0 | / | traits_t::compare(data1, data2, rlen) == 0 and size1 > size2 | data1 is greater than data2 | > 0 | / | traits_t::compare(data1, data2, rlen) > 0 | data1 is greater than data2 | > 0 | int32 compare(const basic_string& str) const {return chars_.compare(str);} / Compares two character sequences. /
Parameters
pos1The position of the first character in this string to compare. /
count1The number of characters of this string to compare. /
strThe other string to compare to. /
Returns
/ * Negative value if *this appears before the character sequence specified by the arguments, in lexicographical order. / * Zero if both character sequences compare equivalent. / * Positive value if *this appears after the character sequence specified by the arguments, in lexicographical order. /
Remarks
Compares a [pos1, pos1 + count1) substring of this string to str. / * If count1 > size() - pos1, the substring is [pos1, size()). /
A character sequence consisting of count1 characters starting at data1 is compared to a character sequence consisting of count2 characters starting at data2 as follows: / * First, calculate the number of characters to compare, as if by size_type rlen = std::min(count1, count2). / * Then compare the sequences by calling traits_t::compare(data1, data2, rlen). For standard strings this function performs character-by-character lexicographical comparison. If the result is zero (the character sequences are equal so far), then their sizes are compared as follows: /
/ | Condition | Result | Return value | / | ----------------------------------------------------------— | ----------------------------— | ---------— | / | traits_t::compare(data1, data2, rlen) < 0 | data1 is less than data2 | < 0 | / | traits_t::compare(data1, data2, rlen) == 0 and size1 < size2 | data1 is less than data2 | < 0 | / | traits_t::compare(data1, data2, rlen) == 0 and size1 == size2 | data1 is equal to data2 | 0 | / | traits_t::compare(data1, data2, rlen) == 0 and size1 > size2 | data1 is greater than data2 | > 0 | / | traits_t::compare(data1, data2, rlen) > 0 | data1 is greater than data2 | > 0 | int32 compare(size_type pos1, size_type count1, const basic_string& str) const {return chars_.compare(pos1, count1, str);} / Compares two character sequences. /
Parameters
pos1The position of the first character in this string to compare. /
count1The number of characters of this string to compare. /
strThe other string to compare to. /
pos2The position of the first character of the given string to compare. /
Returns
/ * Negative value if *this appears before the character sequence specified by the arguments, in lexicographical order. / * Zero if both character sequences compare equivalent. / * Positive value if *this appears after the character sequence specified by the arguments, in lexicographical order. /
Remarks
Compares a [pos1, pos1 + count1) substring of this string to a substring [pos2, pos2 + count2) of str. / * If count1 > size() - pos1, the first substring is [pos1, size()). / * If count2 > str.size() - pos2, the second substring is [pos2, str.size()). /
A character sequence consisting of count1 characters starting at data1 is compared to a character sequence consisting of count2 characters starting at data2 as follows: / * First, calculate the number of characters to compare, as if by size_type rlen = std::min(count1, count2). / * Then compare the sequences by calling traits_t::compare(data1, data2, rlen). For standard strings this function performs character-by-character lexicographical comparison. If the result is zero (the character sequences are equal so far), then their sizes are compared as follows: /
/ | Condition | Result | Return value | / | ----------------------------------------------------------— | ----------------------------— | ---------— | / | traits_t::compare(data1, data2, rlen) < 0 | data1 is less than data2 | < 0 | / | traits_t::compare(data1, data2, rlen) == 0 and size1 < size2 | data1 is less than data2 | < 0 | / | traits_t::compare(data1, data2, rlen) == 0 and size1 == size2 | data1 is equal to data2 | 0 | / | traits_t::compare(data1, data2, rlen) == 0 and size1 > size2 | data1 is greater than data2 | > 0 | / | traits_t::compare(data1, data2, rlen) > 0 | data1 is greater than data2 | > 0 | int32 compare(size_type pos1, size_type count1, const basic_string& str, size_type pos2) const {return chars_.compare(pos1, count1, str, pos2);} / Compares two character sequences. /
Parameters
pos1The position of the first character in this string to compare. /
count1The number of characters of this string to compare. /
strThe other string to compare to. /
pos2The position of the first character of the given string to compare. /
count2The number of characters of the given string to compare. /
Returns
A 32-bit signed integer that indicates whether this instance precedes, follows, or appears in the same position in the sort order as the value parameter: / * Negative value if *this appears before the character sequence specified by the arguments, in lexicographical order. / * Zero if both character sequences compare equivalent. / * Positive value if *this appears after the character sequence specified by the arguments, in lexicographical order. /
Remarks
Compares a [pos1, pos1 + count1) substring of this string to a substring [pos2, pos2 + count2) of str. / * If count1 > size() - pos1, the first substring is [pos1, size()). / * If count2 > str.size() - pos2, the second substring is [pos2, str.size()). /
A character sequence consisting of count1 characters starting at data1 is compared to a character sequence consisting of count2 characters starting at data2 as follows: / * First, calculate the number of characters to compare, as if by size_type rlen = std::min(count1, count2). / * Then compare the sequences by calling traits_t::compare(data1, data2, rlen). For standard strings this function performs character-by-character lexicographical comparison. If the result is zero (the character sequences are equal so far), then their sizes are compared as follows: /
/ | Condition | Result | Return value | / | ----------------------------------------------------------— | ----------------------------— | ---------— | / | traits_t::compare(data1, data2, rlen) < 0 | data1 is less than data2 | < 0 | / | traits_t::compare(data1, data2, rlen) == 0 and size1 < size2 | data1 is less than data2 | < 0 | / | traits_t::compare(data1, data2, rlen) == 0 and size1 == size2 | data1 is equal to data2 | 0 | / | traits_t::compare(data1, data2, rlen) == 0 and size1 > size2 | data1 is greater than data2 | > 0 | / | traits_t::compare(data1, data2, rlen) > 0 | data1 is greater than data2 | > 0 | int32 compare(size_type pos1, size_type count1, const basic_string& str, size_type pos2, size_type count2) const {return chars_.compare(pos1, count1, str, pos2, count2);} / Compares two character sequences. /
Parameters
spointer to the character string to compare to. /
Returns
/ * Negative value if *this appears before the character sequence specified by the arguments, in lexicographical order. / * Zero if both character sequences compare equivalent. / * Positive value if *this appears after the character sequence specified by the arguments, in lexicographical order. /
Remarks
Compares this string to the null-terminated character sequence beginning at the character pointed to by s with length traits_t::length(s). /
A character sequence consisting of count1 characters starting at data1 is compared to a character sequence consisting of count2 characters starting at data2 as follows: / * First, calculate the number of characters to compare, as if by size_type rlen = std::min(count1, count2). / * Then compare the sequences by calling traits_t::compare(data1, data2, rlen). For standard strings this function performs character-by-character lexicographical comparison. If the result is zero (the character sequences are equal so far), then their sizes are compared as follows: /
/ | Condition | Result | Return value | / | ----------------------------------------------------------— | ----------------------------— | ---------— | / | traits_t::compare(data1, data2, rlen) < 0 | data1 is less than data2 | < 0 | / | traits_t::compare(data1, data2, rlen) == 0 and size1 < size2 | data1 is less than data2 | < 0 | / | traits_t::compare(data1, data2, rlen) == 0 and size1 == size2 | data1 is equal to data2 | 0 | / | traits_t::compare(data1, data2, rlen) == 0 and size1 > size2 | data1 is greater than data2 | > 0 | / | traits_t::compare(data1, data2, rlen) > 0 | data1 is greater than data2 | > 0 | int32 compare(const_pointer s) const {return chars_.compare(s);} / Compares two character sequences. /
Parameters
pos1The position of the first character in this string to compare. /
count1The number of characters of this string to compare. /
spointer to the character string to compare to. /
Returns
/ * Negative value if *this appears before the character sequence specified by the arguments, in lexicographical order. / * Zero if both character sequences compare equivalent. / * Positive value if *this appears after the character sequence specified by the arguments, in lexicographical order. /
Remarks
Compares a [pos1, pos1 + count1) substring of this string to the null-terminated character sequence beginning at the character pointed to by s with length traits_t::length(s). / * If count1 > size() - pos1, the substring is [pos1$ , size()). @remarks A character sequence consisting ofcount1characters starting atdata1is compared to a character sequence consisting ofcount2characters starting atdata2as follows:
  • First, calculate the number of characters to compare, as if by
size_type rlen = std::min(count1, count2).
  • Then compare the sequences by calling
traits_t::compare(data1, data2, rlen)`. For standard strings this function performs character-by-character lexicographical comparison. If the result is zero (the character sequences are equal so far), then their sizes are compared as follows:
Condition Result Return value
traits_t::compare(data1, data2, rlen) < 0 data1 is less than data2 < 0
traits_t::compare(data1, data2, rlen) == 0 and size1 < size2 data1 is less than data2 < 0
traits_t::compare(data1, data2, rlen) == 0 and size1 == size2 data1 is equal to data2 0
traits_t::compare(data1, data2, rlen) == 0 and size1 > size2 data1 is greater than data2 > 0
traits_t::compare(data1, data2, rlen) > 0 data1 is greater than data2 > 0
int32 compare (size_type pos1, size_type count1, const_pointer s) const
 
int32 compare (size_type pos1, size_type count1, const_pointer s, size_type count2) const
 Compares two character sequences.
 
int32 compare_to (const object &value) const
 Compares this instance with a specified xtd::object and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified xtd::object.
 
int32 compare_to (const basic_string &value) const noexcept override
 Compares this instance with a specified xtd::basic_string object and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified string.
 
virtual bool contains (value_type value) const noexcept
 Returns a value indicating whether a specified char occurs within this basic_string.
 
virtual bool contains (const basic_string &value) const noexcept
 Returns a value indicating whether a specified substring occurs within this basic_string.
 
bool equals (const object &obj) const noexcept override
 Determines whether this instance and a specified object, which must also be a xtd::basic_string object, have the same value.
 
bool equals (const basic_string &value) const noexcept override
 Determines whether this instance and another specified xtd::basic_string object have the same value.
 
bool equals (const basic_string &value, bool ignore_case) const noexcept
 Determines whether this instance and another specified xtd::basic_string object have the same value, ignoring or honoring their case.
 
bool ends_with (value_type value) const noexcept
 Determines whether the end of this basic_string matches the specified character.
 
bool ends_with (value_type value, bool ignore_case) const noexcept
 Determines whether the end of this basic_string matches the specified character, ignoring or honoring their case.
 
bool ends_with (const basic_string &value) const noexcept
 Determines whether the end of this basic_string matches the specified basic_string.
 
bool ends_with (const basic_string &value, bool ignore_case) const noexcept
 Determines whether the end of this basic_string instance matches the specified basic_string, ignoring or honoring their case.
 
bool ends_with (const basic_string &value, xtd::string_comparison comparison_type) const noexcept
 Determines whether the end of this basic_string matches the specified basic_string when compared using the specified comparison option.
 
size_type find (const basic_string &str) const
 Finds the first substring equal to the given character sequence. Search begins at 0, i.e. the found substring must not begin in a position preceding 0.
 
size_type find (const basic_string &str, size_type pos) const
 Finds the first substring equal to the given character sequence. Search begins at pos, i.e. the found substring must not begin in a position preceding pos.
 
size_type find (const_pointer s, size_type pos, size_type count) const
 Finds the first substring equal to the given character sequence. Search begins at pos, i.e. the found substring must not begin in a position preceding pos.
 
size_type find (const_pointer s) const
 Finds the first substring equal to the given character sequence. Search begins at 0, i.e. the found substring must not begin in a position preceding 0.
 
size_type find (const_pointer s, size_type pos) const
 Finds the first substring equal to the given character sequence. Search begins at pos, i.e. the found substring must not begin in a position preceding pos.
 
size_type find (value_type ch) const
 Finds the first substring equal to the given character sequence. Search begins at 0, i.e. the found substring must not begin in a position preceding 0.
 
size_type find (value_type ch, size_type pos) const
 Finds the first substring equal to the given character sequence. Search begins at pos, i.e. the found substring must not begin in a position preceding pos.
 
size_type find_first_of (const basic_string &str) const
 Finds the first character equal to one of the characters in the given character sequence. The search considers only the range [pos, size()). If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned. @parzm str The string identifying characters to search for.
 
size_type find_first_of (const basic_string &str, size_type pos) const
 Finds the first character equal to one of the characters in the given character sequence. The search considers only the range [pos, size()). If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.
 
size_type find_first_of (const_pointer s, size_type pos, size_type count) const
 Finds the first character equal to one of the characters in the given character sequence. The search considers only the range [pos, size()). If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.
 
size_type find_first_of (const_pointer s) const
 Finds the first character equal to one of the characters in the given character sequence. The search considers only the range [pos, size()). If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.
 
size_type find_first_of (const_pointer s, size_type pos) const
 Finds the first character equal to one of the characters in the given character sequence. The search considers only the range [pos, size()). If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.
 
size_type find_first_of (char_t ch) const
 Finds the first character equal to one of the characters in the given character sequence. The search considers only the range [pos, size()). If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.
 
size_type find_first_of (char_t ch, size_type pos) const
 Finds the first character equal to one of the characters in the given character sequence. The search considers only the range [pos, size()). If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.
 
size_type find_first_not_of (const basic_string &str) const
 Finds the first character equal to none of the characters in the given character sequence. The search considers only the range [pos, size()). If all characters in the range can be found in the given character sequence, xtd::basic_string::npos will be returned. @parzm str The string identifying characters to search for.
 
size_type find_first_not_of (const basic_string &str, size_type pos) const
 Finds the first character equal to none of the characters in the given character sequence. The search considers only the range [pos, size()). If all characters in the range can be found in the given character sequence, xtd::basic_string::npos will be returned.
 
size_type find_first_not_of (const_pointer s, size_type pos, size_type count) const
 Finds the first character equal to none of the characters in the given character sequence. The search considers only the range [pos, size()). If all characters in the range can be found in the given character sequence, xtd::basic_string::npos will be returned.
 
size_type find_first_not_of (const_pointer s) const
 Finds the first character equal to none of the characters in the given character sequence. The search considers only the range [pos, size()). If all characters in the range can be found in the given character sequence, xtd::basic_string::npos will be returned.
 
size_type find_first_not_of (const_pointer s, size_type pos) const
 Finds the first character equal to none of the characters in the given character sequence. The search considers only the range [pos, size()). If all characters in the range can be found in the given character sequence, xtd::basic_string::npos will be returned.
 
size_type find_first_not_of (char_t ch) const
 Finds the first character equal to none of the characters in the given character sequence. The search considers only the range [pos, size()). If all characters in the range can be found in the given character sequence, xtd::basic_string::npos will be returned.
 
size_type find_first_not_of (char_t ch, size_type pos) const
 Finds the first character equal to none of the characters in the given character sequence. The search considers only the range [pos, size()). If all characters in the range can be found in the given character sequence, xtd::basic_string::npos will be returned.
 
size_type find_last_of (const basic_string &str) const
 Finds the last character equal to one of characters in the given character sequence. The exact search algorithm is not specified. The search considers only the range [​0​, pos]. If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned. @parzm str The string identifying characters to search for.
 
size_type find_last_of (const basic_string &str, size_type pos) const
 Finds the last character equal to one of characters in the given character sequence. The exact search algorithm is not specified. The search considers only the range [​0​, pos]. If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.
 
size_type find_last_of (const_pointer s, size_type pos, size_type count) const
 Finds the last character equal to one of characters in the given character sequence. The exact search algorithm is not specified. The search considers only the range [​0​, pos]. If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.
 
size_type find_last_of (const_pointer s) const
 Finds the last character equal to one of characters in the given character sequence. The exact search algorithm is not specified. The search considers only the range [​0​, pos]. If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.
 
size_type find_last_of (const_pointer s, size_type pos) const
 Finds the last character equal to one of characters in the given character sequence. The exact search algorithm is not specified. The search considers only the range [​0​, pos]. If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.
 
size_type find_last_of (char_t ch) const
 Finds the last character equal to one of characters in the given character sequence. The exact search algorithm is not specified. The search considers only the range [​0​, pos]. If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.
 
size_type find_last_of (char_t ch, size_type pos) const
 Finds the last character equal to one of characters in the given character sequence. The exact search algorithm is not specified. The search considers only the range [​0​, pos]. If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.
 
size_type find_last_not_of (const basic_string &str) const
 Finds the last character equal to none of the characters in the given character sequence. The search considers only the range [​0​, pos]. If all characters in the range can be found in the given character sequence,xtd::basic_string::npos will be returned. @parzm str The string identifying characters to search for.
 
size_type find_last_not_of (const basic_string &str, size_type pos) const
 Finds the last character equal to none of the characters in the given character sequence. The search considers only the range [​0​, pos]. If all characters in the range can be found in the given character sequence,xtd::basic_string::npos will be returned.
 
size_type find_last_not_of (const_pointer s, size_type pos, size_type count) const
 Finds the last character equal to none of the characters in the given character sequence. The search considers only the range [​0​, pos]. If all characters in the range can be found in the given character sequence,xtd::basic_string::npos will be returned.
 
size_type find_last_not_of (const_pointer s) const
 Finds the last character equal to none of the characters in the given character sequence. The search considers only the range [​0​, pos]. If all characters in the range can be found in the given character sequence,xtd::basic_string::npos will be returned.
 
size_type find_last_not_of (const_pointer s, size_type pos) const
 Finds the last character equal to none of the characters in the given character sequence. The search considers only the range [​0​, pos]. If all characters in the range can be found in the given character sequence,xtd::basic_string::npos will be returned.
 
size_type find_last_not_of (char_t ch) const
 Finds the last character equal to none of the characters in the given character sequence. The search considers only the range [​0​, pos]. If all characters in the range can be found in the given character sequence,xtd::basic_string::npos will be returned.
 
size_type find_last_not_of (char_t ch, size_type pos) const
 Finds the last character equal to none of the characters in the given character sequence. The search considers only the range [​0​, pos]. If all characters in the range can be found in the given character sequence,xtd::basic_string::npos will be returned.
 
allocator_type get_allocator () const
 Returns the allocator associated with the string.
 
virtual const base_type & get_base_type () const noexcept
 Returns the underlying base type.
 
xtd::size get_hash_code () const noexcept override
 Returns the hash code for this basic_string.
 
enumerator_type get_enumerator () const noexcept override
 Returns an enumerator that iterates through a collection.
 
xtd::size index_of (const basic_string &value) const noexcept
 Reports the index of the first occurrence of the specified basic_string in this basic_string.
 
xtd::size index_of (const basic_string &value, xtd::size start_index) const
 Reports the index of the first occurrence of the specified character in this basic_string. The search starts at a specified character position.
 
xtd::size index_of (const basic_string &value, xtd::size start_index, xtd::size count) const
 Reports the index of the first occurrence of the specified character in this basic_string. The search starts at a specified character position and examines a specified number of character positions.
 
xtd::size index_of (value_type value) const noexcept
 Reports the index of the first occurrence of the specified character in this basic_string.
 
xtd::size index_of (value_type value, xtd::size start_index) const
 Reports the index of the first occurrence of the specified character in this basic_string. The search starts at a specified character position.
 
xtd::size index_of (value_type value, xtd::size start_index, xtd::size count) const
 Reports the index of the first occurrence of the specified character in this basic_string. The search starts at a specified character position and examines a specified number of character positions.
 
xtd::size index_of_any (const xtd::array< value_type > &values) const noexcept
 Reports the index of the first occurrence in this instance of any character in a specified array of characters.
 
xtd::size index_of_any (const xtd::array< value_type > &values, xtd::size start_index) const
 Reports the index of the first occurrence in this instance of any character in a specified array of characters. The search starts at a specified character position.
 
xtd::size index_of_any (const xtd::array< value_type > &values, xtd::size start_index, xtd::size count) const
 Reports the index of the first occurrence in this instance of any character in a specified array of characters. The search starts at a specified character position.
 
basic_string insert (xtd::size start_index, const basic_string &value) const
 Inserts a specified instance of basic_string at a specified index position in this instance.
 
bool is_empty () const noexcept
 Indicates whether this basic_string is an empty basic_string ("").
 
xtd::size last_index_of (const basic_string &value) const noexcept
 Reports the index of the last occurrence of the specified basic_string in this basic_string.
 
xtd::size last_index_of (const basic_string &value, xtd::size start_index) const
 Reports the index of the last occurrence of the specified character in this basic_string. The search starts at a specified character position.
 
xtd::size last_index_of (const basic_string &value, xtd::size start_index, xtd::size count) const
 Reports the index of the last occurrence of the specified character in this basic_string. The search starts at a specified character position and examines a specified number of character positions.
 
xtd::size last_index_of (value_type value) const noexcept
 Reports the index of the last occurrence of the specified character in this tring.
 
xtd::size last_index_of (value_type value, xtd::size start_index) const
 Reports the index of the last occurrence of the specified character in this basic_string. The search starts at a specified character position.
 
xtd::size last_index_of (value_type value, xtd::size start_index, xtd::size count) const
 Reports the index of the last occurrence of the specified character in this basic_string. The search starts at a specified character position and examines a specified number of character positions.
 
xtd::size last_index_of_any (const xtd::array< value_type > &values) const noexcept
 Reports the index of the last occurrence in this instance of any character in a specified array of characters.
 
xtd::size last_index_of_any (const xtd::array< value_type > &values, xtd::size start_index) const
 Reports the index of the last occurrence in this instance of any character in a specified array of characters. The search starts at a specified character position.
 
xtd::size last_index_of_any (const xtd::array< value_type > &values, xtd::size start_index, xtd::size count) const
 Reports the index of the last occurrence in this instance of any character in a specified array of characters. The search starts at a specified character position.
 
basic_string pad_left (xtd::size total_width) const noexcept
 Right-aligns the characters in this basic_string, padding with spaces on the left for a specified total length.
 
basic_string pad_left (xtd::size total_width, char32 padding_char) const noexcept
 Right-aligns the characters in this basic_string, padding with spaces on the left for a specified total length.
 
basic_string pad_right (xtd::size total_width) const noexcept
 Left-aligns the characters in this basic_string, padding with spaces on the right for a specified total length.
 
basic_string pad_right (xtd::size total_width, char32 padding_char) const noexcept
 Left-aligns the characters in this basic_string, padding with spaces on the right for a specified total length.
 
basic_string quoted () const
 Allows insertion and extraction of quoted strings, such as the ones found in CSV or XML.
 
basic_string quoted (value_type delimiter) const
 Allows insertion and extraction of quoted strings, such as the ones found in CSV or XML ith specified delimiter.
 
basic_string quoted (value_type delimiter, value_type escape) const
 Allows insertion and extraction of quoted strings, such as the ones found in CSV or XML ith specified delimiter and escape.
 
basic_string remove (xtd::size start_index) const
 Deletes all the characters from this basic_string beginning at a specified position and continuing through the last position.
 
basic_string remove (xtd::size start_index, xtd::size count) const
 Deletes all the characters from this basic_string beginning at a specified position and continuing through the last position.
 
basic_string replace (value_type old_char, value_type new_char) const noexcept
 Replaces all occurrences of a specified char_t in this basic_string with another specified char_t.
 
basic_string replace (const basic_string &old_string, const basic_string &new_string) const noexcept
 Replaces all occurrences of a specified basic_string in this basic_string with another specified basic_string.
 
size_type rfind (const_pointer s) const
 Finds the last substring that is equal to the given character sequence. The search begins at xtd::basic_string::nposand proceeds from right to left (thus, the found substring, if any, cannot begin in a position following xtd::basic_string::npos). If xtd::basic_string::npos or any value not smaller than xtd::basic_string::size() - 1 is passed as xtd::basic_string::npos, the whole string will be searched. / @return Position of the first character of the found substring or xtd::basic_string::npos if no such substring is found. / @remarks Finds the first substring equal tostr. size_type rfind(const basic_string& str) const {return chars_.rfind(str);} / @brief Finds the last substring that is equal to the given character sequence. The search begins atposand proceeds from right to left (thus, the found substring, if any, cannot begin in a position followingpos). If xtd::basic_string::npos or any value not smaller than xtd::basic_string::size() - 1 is passed aspos, the whole string will be searched. / @param str The string to search for. / @param pos The position at which to start the search / @return Position of the first character of the found substring or xtd::basic_string::npos if no such substring is found. / @remarks Finds the first substring equal tostr. size_type rfind(const basic_string& str, size_type pos) const {return chars_.rfind(str, pos);} / @brief Finds the last substring that is equal to the given character sequence. The search begins atposand proceeds from right to left (thus, the found substring, if any, cannot begin in a position followingpos). If xtd::basic_string::npos or any value not smaller than xtd::basic_string::size() - 1 is passed aspos, the whole string will be searched. / @param str The string to search for. / @param pos The position at which to start the search / @param count The length of substring to search for. / @return Position of the first character of the found substring or xtd::basic_string::npos if no such substring is found. / @remarks Finds the first substring equal to the range [s, s + count). / @remarks This range may contain null characters. If [s,s + count) is not a valid range, the behavior is undefined. size_type rfind(const_pointer s, size_type pos, size_type count) const {return chars_.rfind(s, pos, count);} / @brief Finds the last substring that is equal to the given character sequence. The search begins at xtd::basic_string::npos and proceeds from right to left (thus, the found substring, if any, cannot begin in a position following xtd::basic_string::npos). If xtd::basic_string::npos or any value not smaller than xtd::basic_string::size() - 1 is passed as xtd::basic_string::npos, the whole string will be searched.
 
size_type rfind (const_pointer s, size_type pos) const
 Finds the last substring that is equal to the given character sequence. The search begins at pos and proceeds from right to left (thus, the found substring, if any, cannot begin in a position following pos). If xtd::basic_string::npos or any value not smaller than xtd::basic_string::size() - 1 is passed as pos, the whole string will be searched.
 

Additional Inherited Members

using value_type
 Represents the xtd::collections::generic::ienumerable value type.
 
using iterator
 Represents the iterator of xtd::collections::generic::ienumerable value type.
 
using const_iterator
 Represents the const iterator of xtd::collections::generic::ienumerable value type.
 
using iterator
 Represents the iterator of enumarable value type.
 
using const_iterator
 Represents the const iterator of enumarable value type.
 
using enumerable_type
 Represents the ienumerable enumerable type.
 
using source_type
 Represents the ienumerable source type.
 
using ienumerable
 Represents the ienumerable value type.
 
using list
 Represents the list value type.
 
 object ()=default
 Create a new instance of the ultimate base class object.
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance.
 
template<class object_t>
xtd::unique_ptr_object< object_t > memberwise_clone () const
 Creates a shallow copy of the current object.
 
virtual xtd::string to_string () const noexcept
 Returns a xtd::string that represents the current object.
 
virtual const_iterator begin () const
 Returns an iterator to the first element of the enumarable.
 
virtual iterator begin ()
 Returns an iterator to the first element of the enumarable.
 
virtual const_iterator cbegin () const
 Returns an iterator to the first element of the enumarable.
 
virtual const_iterator cend () const
 Returns an iterator to the element following the last element of the enumarable.
 
virtual const_iterator end () const
 Returns an iterator to the element following the last element of the enumarable.
 
virtual iterator end ()
 Returns an iterator to the element following the last element of the enumarable.
 
char_t aggregate (const std::function< char_t(const char_t &, const char_t &)> &func) const
 Applies an accumulator function over a sequence.
 
char_t aggregate (const char_t &seed, const std::function< char_t(const char_t &, const char_t &)> &func) const
 Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value.
 
accumulate_t aggregate (const accumulate_t &seed, const std::function< accumulate_t(const char_t &, const accumulate_t &)> &func) const
 Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value.
 
char_t aggregate (const char_t &seed, const std::function< char_t(const char_t &, const char_t &)> &func, const std::function< char_t(const char_t &)> &result_selector) const
 Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value.
 
result_t aggregate (const accumulate_t &seed, const std::function< accumulate_t(const char_t &, const accumulate_t &)> &func, const std::function< result_t(const accumulate_t &)> &result_selector) const
 Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value.
 
bool all (const std::function< bool(const char_t &)> &predicate) const
 Determines whether all elements of a sequence satisfy a condition.
 
bool any () const noexcept
 Determines whether a sequence contains any elements.
 
bool any (const std::function< bool(const char_t &)> &predicate) const
 Determines whether any element of a sequence satisfies a condition.
 
const ienumerable< char_t > & append (const char_t &element) const noexcept
 Appends a value to the end of the sequence.
 
const ienumerable< char_t > & as_enumerable () const noexcept
 Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
 
auto average () const noexcept
 Computes the average of a sequence of source_t values.
 
const ienumerable< result_t > & cast () const noexcept
 Casts the elements of an xtd::collections::generic::ienumerable to the specified type.
 
const ienumerable< xtd::array< char_t > > & chunk (size_t size) const
 Splits the elements of a sequence into chunks of size at most size.
 
const ienumerable< char_t > & concat (const ienumerable< char_t > &second) const noexcept
 Concatenates two sequences.
 
bool contains (const char_t &value) const noexcept
 Determines whether a sequence contains a specified element by using the default equality comparer.
 
bool contains (const char_t &value, const xtd::collections::generic::iequality_comparer< char_t > &comparer) const noexcept
 Determines whether a sequence contains a specified element by using a specified equality comparer.
 
size_t count () const noexcept
 Returns the number of elements in current sequence.
 
size_t count (const std::function< bool(const char_t &)> &predicate) const noexcept
 Returns a number that represents how many elements in the specified sequence satisfy a condition.
 
xtd::size count (const char_t &value) const noexcept
 Returns the number of elements with the specified value.
 
const ienumerable< key_value_pair< key_t, xtd::size > > & count_by (const std::function< key_t(const char_t &)> &key_selector) const noexcept
 Returns the count of elements in the current sequence grouped by key.
 
const ienumerable< key_value_pair< key_t, xtd::size > > & count_by (const std::function< key_t(const char_t &)> &key_selector, const iequality_comparer< key_t > &key_comparer) const noexcept
 Returns the count of elements in the current sequence grouped by key.
 
const ienumerable< char_t > & default_if_empty () const noexcept
 Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the current sequence is empty.
 
const ienumerable< char_t > & default_if_empty (const char_t &default_value) const noexcept
 Returns the elements of the specified sequence or the specified value in a singleton collection if the current sequence is empty.
 
char_t first_or_default (const std::function< bool(const char_t &)> &predicate, const char_t &default_value) const noexcept
 Returns the first element of the sequence that satisfies a condition, or a specified default value if no such element is found.
 
char_t first_or_default (const std::function< bool(const char_t &)> &predicate) const noexcept
 Returns the first element of the sequence that satisfies a condition or a default value if no such element is found.
 
char_t first_or_default (const char_t default_value) const noexcept
 Returns the first element of the sequence that satisfies a condition or a default value if no such element is found.
 
char_t first_or_default () const noexcept
 Returns the first element of the sequence that satisfies a condition or a default value if no such element is found.
 
const ienumerable< result_t > & select (const std::function< result_t(const char_t &)> &selector) const
 Projects each element of a sequence into a new form.
 
const ienumerable< char_t > & select (const std::function< char_t(const char_t &)> &selector) const
 Projects each element of a sequence into a new form.
 
const ienumerable< result_t > & select (const std::function< result_t(const char_t &, size_t index)> &selector) const
 Projects each element of a sequence into a new form by incorporating the element's index.
 
const ienumerable< char_t > & select (const std::function< char_t(const char_t &, size_t index)> &selector) const
 Projects each element of a sequence into a new form by incorporating the element's index.
 
const list< char_t > & to_list () const noexcept
 Creates a xtd::collections::generic::list <type_t> from an xtd::collections::generic::ienumerable <type_t>.
 
const ienumerable< char_t > & where (const std::function< bool(const char_t &)> &predicate) const
 Filters a sequence of values based on a predicate.
 
const ienumerable< char_t > & where (const std::function< bool(const char_t &, size_t)> &predicate) const
 Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function.
 
template<class object_a_t, class object_b_t>
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
template<class object_a_t, class object_b_t>
static bool reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 
static target_collection_t::const_iterator to_iterator (typename source_collection_t::const_iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept
 Converts source iterator to target iterator.
 
static target_collection_t::iterator to_iterator (typename source_collection_t::iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept
 Converts source iterator to target iterator.
 
static target_collection_t::const_iterator to_iterator (typename source_collection_t::const_iterator &value, source_collection_t &source_collection, target_collection_t &target_collection) noexcept
 Converts source iterator to target iterator.
 
static target_collection_t::iterator to_iterator (typename source_collection_t::iterator &value, source_collection_t &source_collection, target_collection_t &target_collection) noexcept
 Converts source iterator to target iterator.
 

Member Function Documentation

◆ compare()

template<class char_t, class traits_t, class allocator_t>
int32 xtd::basic_string< char_t, traits_t, allocator_t >::compare ( size_type pos1,
size_type count1,
const_pointer s,
size_type count2 ) const
inline

Compares two character sequences.

Parameters
pos1The position of the first character in this string to compare.
count1The number of characters of this string to compare.
spointer to the character string to compare to.
count2The number of characters of the given string to compare.
Returns
  • Negative value if *this appears before the character sequence specified by the arguments, in lexicographical order.
  • Zero if both character sequences compare equivalent.
  • Positive value if *this appears after the character sequence specified by the arguments, in lexicographical order.
Remarks
Compares a [pos1, pos1 + count1) substring of this string to the characters in the range [s, s + count2). The characters in [s, s + count2) may include null characters.
  • If count1 > size() - pos1, the substring is [pos1, size()).
A character sequence consisting of count1 characters starting at data1 is compared to a character sequence consisting of count2 characters starting at data2 as follows:
  • First, calculate the number of characters to compare, as if by size_type rlen = std::min(count1, count2).
  • Then compare the sequences by calling traits_t::compare(data1, data2, rlen). For standard strings this function performs character-by-character lexicographical comparison. If the result is zero (the character sequences are equal so far), then their sizes are compared as follows:
Condition Result Return value
traits_t::compare(data1, data2, rlen) < 0 data1 is less than data2 < 0
traits_t::compare(data1, data2, rlen) == 0 and size1 < size2 data1 is less than data2 < 0
traits_t::compare(data1, data2, rlen) == 0 and size1 == size2 data1 is equal to data2 0
traits_t::compare(data1, data2, rlen) == 0 and size1 > size2 data1 is greater than data2 > 0
traits_t::compare(data1, data2, rlen) > 0 data1 is greater than data2 > 0

◆ compare_to() [1/2]

template<class char_t, class traits_t, class allocator_t>
int32 xtd::basic_string< char_t, traits_t, allocator_t >::compare_to ( const object & value) const
inline

Compares this instance with a specified xtd::object and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified xtd::object.

Parameters
valueAn object that evaluates to a xtd::basic_string.
Returns
A 32-bit signed integer that indicates whether this instance precedes, follows, or appears in the same position in the sort order as the value parameter.
Value Condition
Less than zero This instance precedes value.
Zero This instance has the same position in the sort order as value.
Greater than zero This instance follows value.
Exceptions
xtd::argument_exception`value` is not a xtd::basic_string.

◆ compare_to() [2/2]

template<class char_t, class traits_t, class allocator_t>
int32 xtd::basic_string< char_t, traits_t, allocator_t >::compare_to ( const basic_string< char_t, traits_t, allocator_t > & value) const
inlineoverridevirtualnoexcept

Compares this instance with a specified xtd::basic_string object and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified string.

Parameters
valueThe string to compare with this instance.
Returns
A 32-bit signed integer that indicates whether this instance precedes, follows, or appears in the same position in the sort order as the value parameter.
Value Condition
Less than zero This instance precedes value.
Zero This instance has the same position in the sort order as value.
Greater than zero This instance follows value.

Implements xtd::icomparable< basic_string< char_t, traits_t, allocator_t > >.

◆ contains() [1/2]

template<class char_t, class traits_t, class allocator_t>
virtual bool xtd::basic_string< char_t, traits_t, allocator_t >::contains ( value_type value) const
inlinevirtualnoexcept

Returns a value indicating whether a specified char occurs within this basic_string.

Parameters
valueThe char to seek.
Returns
true if the value parameter occurs within this basic_string; otherwise, false.

◆ contains() [2/2]

template<class char_t, class traits_t, class allocator_t>
virtual bool xtd::basic_string< char_t, traits_t, allocator_t >::contains ( const basic_string< char_t, traits_t, allocator_t > & value) const
inlinevirtualnoexcept

Returns a value indicating whether a specified substring occurs within this basic_string.

Parameters
valueThe basic_string to seek.
Returns
true if the value parameter occurs within this basic_string, or if value is the empty basic_string (""); otherwise, false.

◆ equals() [1/3]

template<class char_t, class traits_t, class allocator_t>
bool xtd::basic_string< char_t, traits_t, allocator_t >::equals ( const object & obj) const
inlineoverridevirtualnoexcept

Determines whether this instance and a specified object, which must also be a xtd::basic_string object, have the same value.

Parameters
objThe basic_string to compare to this instance.
Returns
true if obj is a xtd::basic_string and its value is the same as this instance; otherwise, false.

Reimplemented from xtd::object.

◆ equals() [2/3]

template<class char_t, class traits_t, class allocator_t>
bool xtd::basic_string< char_t, traits_t, allocator_t >::equals ( const basic_string< char_t, traits_t, allocator_t > & value) const
inlineoverridevirtualnoexcept

Determines whether this instance and another specified xtd::basic_string object have the same value.

Parameters
valueThe basic_string to compare to this instance.
Returns
true if the value of the value parameter is the same as the value of this instance; otherwise, false.
Remarks
This method performs an ordinal (case-sensitive) comparison.

Implements xtd::iequatable< basic_string< char_t, traits_t, allocator_t > >.

◆ equals() [3/3]

template<class char_t, class traits_t, class allocator_t>
bool xtd::basic_string< char_t, traits_t, allocator_t >::equals ( const basic_string< char_t, traits_t, allocator_t > & value,
bool ignore_case ) const
inlinenoexcept

Determines whether this instance and another specified xtd::basic_string object have the same value, ignoring or honoring their case.

Parameters
valueThe basic_string to compare to this instance.
ignore_casetrue to ignore case when comparing this instance and value; otherwise, false
Returns
true if the value of the value parameter is the same as the value of this instance; otherwise, false.
Remarks
This method performs an ordinal comparison.

◆ ends_with() [1/5]

template<class char_t, class traits_t, class allocator_t>
bool xtd::basic_string< char_t, traits_t, allocator_t >::ends_with ( value_type value) const
inlinenoexcept

Determines whether the end of this basic_string matches the specified character.

Parameters
valueThe char_t to compare to the substring at the end of this instance.
Returns
true if value matches the end of this instance; otherwise, false.

◆ ends_with() [2/5]

template<class char_t, class traits_t, class allocator_t>
bool xtd::basic_string< char_t, traits_t, allocator_t >::ends_with ( value_type value,
bool ignore_case ) const
inlinenoexcept

Determines whether the end of this basic_string matches the specified character, ignoring or honoring their case.

Parameters
valueThe char_t to compare to the substring at the end of this instance.
ignore_casetrue to ignore case during the comparison; otherwise, false.
Returns
true if value matches the end of this instance; otherwise, false.

◆ ends_with() [3/5]

template<class char_t, class traits_t, class allocator_t>
bool xtd::basic_string< char_t, traits_t, allocator_t >::ends_with ( const basic_string< char_t, traits_t, allocator_t > & value) const
inlinenoexcept

Determines whether the end of this basic_string matches the specified basic_string.

Parameters
valueThe basic_string to compare to the substring at the end of this instance.
Returns
true if value matches the end of this instance; otherwise, false.

◆ ends_with() [4/5]

template<class char_t, class traits_t, class allocator_t>
bool xtd::basic_string< char_t, traits_t, allocator_t >::ends_with ( const basic_string< char_t, traits_t, allocator_t > & value,
bool ignore_case ) const
inlinenoexcept

Determines whether the end of this basic_string instance matches the specified basic_string, ignoring or honoring their case.

Parameters
valueThe string to compare to the substring at the end of this instance.
ignore_casetrue to ignore case during the comparison; otherwise, false.
Returns
bool true if value matches the end of the specified basic_string; otherwise, false.

◆ ends_with() [5/5]

template<class char_t, class traits_t, class allocator_t>
bool xtd::basic_string< char_t, traits_t, allocator_t >::ends_with ( const basic_string< char_t, traits_t, allocator_t > & value,
xtd::string_comparison comparison_type ) const
inlinenoexcept

Determines whether the end of this basic_string matches the specified basic_string when compared using the specified comparison option.

Parameters
valueThe string to compare to the substring at the end of this instance.
comparison_typeOne of the enumeration values that determines how this basic_string and value are compared.
Returns
bool true if value matches the end of the specified basic_string; otherwise, false.

◆ find() [1/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find ( const basic_string< char_t, traits_t, allocator_t > & str) const
inline

Finds the first substring equal to the given character sequence. Search begins at 0, i.e. the found substring must not begin in a position preceding 0.

Returns
Position of the first character of the found substring or xtd::basic_string::npos if no such substring is found.
Remarks
Finds the first substring equal to str.

◆ find() [2/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find ( const basic_string< char_t, traits_t, allocator_t > & str,
size_type pos ) const
inline

Finds the first substring equal to the given character sequence. Search begins at pos, i.e. the found substring must not begin in a position preceding pos.

Parameters
strThe string to search for.
posThe position at which to start the search
Returns
Position of the first character of the found substring or xtd::basic_string::npos if no such substring is found.
Remarks
Finds the first substring equal to str.

◆ find() [3/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find ( const_pointer s,
size_type pos,
size_type count ) const
inline

Finds the first substring equal to the given character sequence. Search begins at pos, i.e. the found substring must not begin in a position preceding pos.

Parameters
strThe string to search for.
posThe position at which to start the search
countThe length of substring to search for.
Returns
Position of the first character of the found substring or xtd::basic_string::npos if no such substring is found.
Remarks
Finds the first substring equal to the range [s, s + count).
This range may contain null characters. If [s, s + count) is not a valid range, the behavior is undefined.

◆ find() [4/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find ( const_pointer s) const
inline

Finds the first substring equal to the given character sequence. Search begins at 0, i.e. the found substring must not begin in a position preceding 0.

Parameters
sThe pointer to a character string to search for.
Returns
Position of the first character of the found substring or xtd::basic_string::npos if no such substring is found.
Remarks
Finds the first substring equal to the character string pointed to by s. The length of the string is determined by the first null character using traits_t::length(s).
If [s, s + traits_t::length(s)) is not a valid range, the behavior is undefined.

◆ find() [5/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find ( const_pointer s,
size_type pos ) const
inline

Finds the first substring equal to the given character sequence. Search begins at pos, i.e. the found substring must not begin in a position preceding pos.

Parameters
sThe pointer to a character string to search for.
posThe position at which to start the search
Returns
Position of the first character of the found substring or xtd::basic_string::npos if no such substring is found.
Remarks
Finds the first substring equal to the character string pointed to by s. The length of the string is determined by the first null character using traits_t::length(s).
If [s, s + traits_t::length(s)) is not a valid range, the behavior is undefined.

◆ find() [6/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find ( value_type ch) const
inline

Finds the first substring equal to the given character sequence. Search begins at 0, i.e. the found substring must not begin in a position preceding 0.

Parameters
chThe character to search for.
Returns
Position of the first character of the found substring or xtd::basic_string::npos if no such substring is found.
Remarks
Finds the first character ch (treated as a single-character substring by the formal rules below).

◆ find() [7/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find ( value_type ch,
size_type pos ) const
inline

Finds the first substring equal to the given character sequence. Search begins at pos, i.e. the found substring must not begin in a position preceding pos.

Parameters
chThe character to search for.
posThe position at which to start the search
Returns
Position of the first character of the found substring or xtd::basic_string::npos if no such substring is found.
Remarks
Finds the first character ch (treated as a single-character substring by the formal rules below).

◆ find_first_of() [1/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_first_of ( const basic_string< char_t, traits_t, allocator_t > & str) const
inline

Finds the first character equal to one of the characters in the given character sequence. The search considers only the range [pos, size()). If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned. @parzm str The string identifying characters to search for.

Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in str.

◆ find_first_of() [2/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_first_of ( const basic_string< char_t, traits_t, allocator_t > & str,
size_type pos ) const
inline

Finds the first character equal to one of the characters in the given character sequence. The search considers only the range [pos, size()). If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.

Parameters
strThe string identifying characters to search for.
posThe position at which to begin searching.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in str.

◆ find_first_of() [3/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_first_of ( const_pointer s,
size_type pos,
size_type count ) const
inline

Finds the first character equal to one of the characters in the given character sequence. The search considers only the range [pos, size()). If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.

Parameters
sThe pointer to a character string identifying characters to search for.
posThe position at which to begin searching.
countThe length of character string identifying characters to search for.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in the range [s, s + count). This range can include null characters.
If [s, s + count) is not a valid range, the behavior is undefined.

◆ find_first_of() [4/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_first_of ( const_pointer s) const
inline

Finds the first character equal to one of the characters in the given character sequence. The search considers only the range [pos, size()). If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.

Parameters
sThe pointer to a character string identifying characters to search for.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in character string pointed to by s. The length of the string is determined by the first null character using traits_t::length(s).
If [s, s + traits_t::length(s)) is not a valid range, the behavior is undefined.

◆ find_first_of() [5/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_first_of ( const_pointer s,
size_type pos ) const
inline

Finds the first character equal to one of the characters in the given character sequence. The search considers only the range [pos, size()). If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.

Parameters
sThe pointer to a character string identifying characters to search for.
posThe position at which to begin searching.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in character string pointed to by s. The length of the string is determined by the first null character using traits_t::length(s).
If [s, s + traits_t::length(s)) is not a valid range, the behavior is undefined.

◆ find_first_of() [6/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_first_of ( char_t ch) const
inline

Finds the first character equal to one of the characters in the given character sequence. The search considers only the range [pos, size()). If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.

Parameters
chThe character to search for.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to ch.

◆ find_first_of() [7/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_first_of ( char_t ch,
size_type pos ) const
inline

Finds the first character equal to one of the characters in the given character sequence. The search considers only the range [pos, size()). If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.

Parameters
chThe character to search for.
posThe position at which to begin searching.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to ch.

◆ find_first_not_of() [1/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_first_not_of ( const basic_string< char_t, traits_t, allocator_t > & str) const
inline

Finds the first character equal to none of the characters in the given character sequence. The search considers only the range [pos, size()). If all characters in the range can be found in the given character sequence, xtd::basic_string::npos will be returned. @parzm str The string identifying characters to search for.

Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in str.

◆ find_first_not_of() [2/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_first_not_of ( const basic_string< char_t, traits_t, allocator_t > & str,
size_type pos ) const
inline

Finds the first character equal to none of the characters in the given character sequence. The search considers only the range [pos, size()). If all characters in the range can be found in the given character sequence, xtd::basic_string::npos will be returned.

Parameters
strThe string identifying characters to search for.
posThe position at which to begin searching.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in str.

◆ find_first_not_of() [3/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_first_not_of ( const_pointer s,
size_type pos,
size_type count ) const
inline

Finds the first character equal to none of the characters in the given character sequence. The search considers only the range [pos, size()). If all characters in the range can be found in the given character sequence, xtd::basic_string::npos will be returned.

Parameters
sThe pointer to a character string identifying characters to search for.
posThe position at which to begin searching.
countThe length of character string identifying characters to search for.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in the range [s, s + count). This range can include null characters.
If [s, s + count) is not a valid range, the behavior is undefined.

◆ find_first_not_of() [4/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_first_not_of ( const_pointer s) const
inline

Finds the first character equal to none of the characters in the given character sequence. The search considers only the range [pos, size()). If all characters in the range can be found in the given character sequence, xtd::basic_string::npos will be returned.

Parameters
sThe pointer to a character string identifying characters to search for.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in character string pointed to by s. The length of the string is determined by the first null character using traits_t::length(s).
If [s, s + traits_t::length(s)) is not a valid range, the behavior is undefined.

◆ find_first_not_of() [5/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_first_not_of ( const_pointer s,
size_type pos ) const
inline

Finds the first character equal to none of the characters in the given character sequence. The search considers only the range [pos, size()). If all characters in the range can be found in the given character sequence, xtd::basic_string::npos will be returned.

Parameters
sThe pointer to a character string identifying characters to search for.
posThe position at which to begin searching.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in character string pointed to by s. The length of the string is determined by the first null character using traits_t::length(s).
If [s, s + traits_t::length(s)) is not a valid range, the behavior is undefined.

◆ find_first_not_of() [6/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_first_not_of ( char_t ch) const
inline

Finds the first character equal to none of the characters in the given character sequence. The search considers only the range [pos, size()). If all characters in the range can be found in the given character sequence, xtd::basic_string::npos will be returned.

Parameters
chThe character to search for.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to ch.

◆ find_first_not_of() [7/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_first_not_of ( char_t ch,
size_type pos ) const
inline

Finds the first character equal to none of the characters in the given character sequence. The search considers only the range [pos, size()). If all characters in the range can be found in the given character sequence, xtd::basic_string::npos will be returned.

Parameters
chThe character to search for.
posThe position at which to begin searching.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to ch.

◆ find_last_of() [1/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_last_of ( const basic_string< char_t, traits_t, allocator_t > & str) const
inline

Finds the last character equal to one of characters in the given character sequence. The exact search algorithm is not specified. The search considers only the range [​0​, pos]. If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned. @parzm str The string identifying characters to search for.

Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in str.

◆ find_last_of() [2/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_last_of ( const basic_string< char_t, traits_t, allocator_t > & str,
size_type pos ) const
inline

Finds the last character equal to one of characters in the given character sequence. The exact search algorithm is not specified. The search considers only the range [​0​, pos]. If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.

Parameters
strThe string identifying characters to search for.
posThe position at which to begin searching.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in str.

◆ find_last_of() [3/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_last_of ( const_pointer s,
size_type pos,
size_type count ) const
inline

Finds the last character equal to one of characters in the given character sequence. The exact search algorithm is not specified. The search considers only the range [​0​, pos]. If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.

Parameters
sThe pointer to a character string identifying characters to search for.
posThe position at which to begin searching.
countThe length of character string identifying characters to search for.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in the range [s, s + count). This range can include null characters.
If [s, s + count) is not a valid range, the behavior is undefined.

◆ find_last_of() [4/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_last_of ( const_pointer s) const
inline

Finds the last character equal to one of characters in the given character sequence. The exact search algorithm is not specified. The search considers only the range [​0​, pos]. If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.

Parameters
sThe pointer to a character string identifying characters to search for.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in character string pointed to by s. The length of the string is determined by the first null character using traits_t::length(s).
If [s, s + traits_t::length(s)) is not a valid range, the behavior is undefined.

◆ find_last_of() [5/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_last_of ( const_pointer s,
size_type pos ) const
inline

Finds the last character equal to one of characters in the given character sequence. The exact search algorithm is not specified. The search considers only the range [​0​, pos]. If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.

Parameters
sThe pointer to a character string identifying characters to search for.
posThe position at which to begin searching.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in character string pointed to by s. The length of the string is determined by the first null character using traits_t::length(s).
If [s, s + traits_t::length(s)) is not a valid range, the behavior is undefined.

◆ find_last_of() [6/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_last_of ( char_t ch) const
inline

Finds the last character equal to one of characters in the given character sequence. The exact search algorithm is not specified. The search considers only the range [​0​, pos]. If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.

Parameters
chThe character to search for.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to ch.

◆ find_last_of() [7/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_last_of ( char_t ch,
size_type pos ) const
inline

Finds the last character equal to one of characters in the given character sequence. The exact search algorithm is not specified. The search considers only the range [​0​, pos]. If none of the characters in the given character sequence is present in the range, xtd::basic_string::npos will be returned.

Parameters
chThe character to search for.
posThe position at which to begin searching.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to ch.

◆ find_last_not_of() [1/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_last_not_of ( const basic_string< char_t, traits_t, allocator_t > & str) const
inline

Finds the last character equal to none of the characters in the given character sequence. The search considers only the range [​0​, pos]. If all characters in the range can be found in the given character sequence,xtd::basic_string::npos will be returned. @parzm str The string identifying characters to search for.

Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in str.

◆ find_last_not_of() [2/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_last_not_of ( const basic_string< char_t, traits_t, allocator_t > & str,
size_type pos ) const
inline

Finds the last character equal to none of the characters in the given character sequence. The search considers only the range [​0​, pos]. If all characters in the range can be found in the given character sequence,xtd::basic_string::npos will be returned.

Parameters
strThe string identifying characters to search for.
posThe position at which to begin searching.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in str.

◆ find_last_not_of() [3/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_last_not_of ( const_pointer s,
size_type pos,
size_type count ) const
inline

Finds the last character equal to none of the characters in the given character sequence. The search considers only the range [​0​, pos]. If all characters in the range can be found in the given character sequence,xtd::basic_string::npos will be returned.

Parameters
sThe pointer to a character string identifying characters to search for.
posThe position at which to begin searching.
countThe length of character string identifying characters to search for.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in the range [s, s + count). This range can include null characters.
If [s, s + count) is not a valid range, the behavior is undefined.

◆ find_last_not_of() [4/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_last_not_of ( const_pointer s) const
inline

Finds the last character equal to none of the characters in the given character sequence. The search considers only the range [​0​, pos]. If all characters in the range can be found in the given character sequence,xtd::basic_string::npos will be returned.

Parameters
sThe pointer to a character string identifying characters to search for.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in character string pointed to by s. The length of the string is determined by the first null character using traits_t::length(s).
If [s, s + traits_t::length(s)) is not a valid range, the behavior is undefined.

◆ find_last_not_of() [5/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_last_not_of ( const_pointer s,
size_type pos ) const
inline

Finds the last character equal to none of the characters in the given character sequence. The search considers only the range [​0​, pos]. If all characters in the range can be found in the given character sequence,xtd::basic_string::npos will be returned.

Parameters
sThe pointer to a character string identifying characters to search for.
posThe position at which to begin searching.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to one of the characters in character string pointed to by s. The length of the string is determined by the first null character using traits_t::length(s).
If [s, s + traits_t::length(s)) is not a valid range, the behavior is undefined.

◆ find_last_not_of() [6/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_last_not_of ( char_t ch) const
inline

Finds the last character equal to none of the characters in the given character sequence. The search considers only the range [​0​, pos]. If all characters in the range can be found in the given character sequence,xtd::basic_string::npos will be returned.

Parameters
chThe character to search for.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to ch.

◆ find_last_not_of() [7/7]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::find_last_not_of ( char_t ch,
size_type pos ) const
inline

Finds the last character equal to none of the characters in the given character sequence. The search considers only the range [​0​, pos]. If all characters in the range can be found in the given character sequence,xtd::basic_string::npos will be returned.

Parameters
chThe character to search for.
posThe position at which to begin searching.
Returns
Position of the found character or xtd::basic_string::npos if no such character is found.
Remarks
Finds the first character equal to ch.

◆ get_allocator()

template<class char_t, class traits_t, class allocator_t>
allocator_type xtd::basic_string< char_t, traits_t, allocator_t >::get_allocator ( ) const
inline

Returns the allocator associated with the string.

Returns
The associated allocator.

◆ get_base_type()

template<class char_t, class traits_t, class allocator_t>
virtual const base_type & xtd::basic_string< char_t, traits_t, allocator_t >::get_base_type ( ) const
inlinevirtualnoexcept

Returns the underlying base type.

Returns
The underlying base type.

◆ get_hash_code()

template<class char_t, class traits_t, class allocator_t>
xtd::size xtd::basic_string< char_t, traits_t, allocator_t >::get_hash_code ( ) const
inlineoverridevirtualnoexcept

Returns the hash code for this basic_string.

Returns
A hash code.

Reimplemented from xtd::object.

◆ get_enumerator()

template<class char_t, class traits_t, class allocator_t>
enumerator_type xtd::basic_string< char_t, traits_t, allocator_t >::get_enumerator ( ) const
inlineoverridevirtualnoexcept

Returns an enumerator that iterates through a collection.

Returns
An xtd::collections::generic::enumerator object that can be used to iterate through the collection.

Implements xtd::collections::generic::ienumerable< char_t >.

◆ index_of() [1/6]

template<class char_t, class traits_t, class allocator_t>
xtd::size xtd::basic_string< char_t, traits_t, allocator_t >::index_of ( const basic_string< char_t, traits_t, allocator_t > & value) const
inlinenoexcept

Reports the index of the first occurrence of the specified basic_string in this basic_string.

Parameters
valueAn unicode character to seek
Returns
The index position of value if that character is found, or std::basic_string<char_t>::npos if it is not.

◆ index_of() [2/6]

template<class char_t, class traits_t, class allocator_t>
xtd::size xtd::basic_string< char_t, traits_t, allocator_t >::index_of ( const basic_string< char_t, traits_t, allocator_t > & value,
xtd::size start_index ) const
inline

Reports the index of the first occurrence of the specified character in this basic_string. The search starts at a specified character position.

Parameters
valueAn unicode character to seek
start_indexThe search starting position
Returns
The index position of value if that character is found, or std::basic_string<char_t>::npos if it is not.

◆ index_of() [3/6]

template<class char_t, class traits_t, class allocator_t>
xtd::size xtd::basic_string< char_t, traits_t, allocator_t >::index_of ( const basic_string< char_t, traits_t, allocator_t > & value,
xtd::size start_index,
xtd::size count ) const
inline

Reports the index of the first occurrence of the specified character in this basic_string. The search starts at a specified character position and examines a specified number of character positions.

Parameters
valueAn unicode character to seek
start_indexThe search starting position
countThe number of character positions to examine
Returns
The index position of value if that character is found, or std::basic_string<char_t>::npos if it is not.
Exceptions
xtd::index_out_of_range_exceptionstart_index + count are greater than the length of this instance.

◆ index_of() [4/6]

template<class char_t, class traits_t, class allocator_t>
xtd::size xtd::basic_string< char_t, traits_t, allocator_t >::index_of ( value_type value) const
inlinenoexcept

Reports the index of the first occurrence of the specified character in this basic_string.

Parameters
valueAn unicode character to seek
Returns
The index position of value if that character is found, or std::basic_string<char_t>::npos if it is not.

◆ index_of() [5/6]

template<class char_t, class traits_t, class allocator_t>
xtd::size xtd::basic_string< char_t, traits_t, allocator_t >::index_of ( value_type value,
xtd::size start_index ) const
inline

Reports the index of the first occurrence of the specified character in this basic_string. The search starts at a specified character position.

Parameters
valueAn unicode character to seek
start_indexThe search starting position
Returns
The index position of value if that character is found, or std::basic_string<char_t>::npos if it is not.

◆ index_of() [6/6]

template<class char_t, class traits_t, class allocator_t>
xtd::size xtd::basic_string< char_t, traits_t, allocator_t >::index_of ( value_type value,
xtd::size start_index,
xtd::size count ) const
inline

Reports the index of the first occurrence of the specified character in this basic_string. The search starts at a specified character position and examines a specified number of character positions.

Parameters
valueAn unicode character to seek
start_indexThe search starting position
countThe number of character positions to examine
Returns
The index position of value if that character is found, or std::basic_string<char_t>::npos if it is not.
Exceptions
xtd::index_out_of_range_exceptionstart_index + count are greater than the length of this instance.

◆ index_of_any() [1/3]

template<class char_t, class traits_t, class allocator_t>
xtd::size xtd::basic_string< char_t, traits_t, allocator_t >::index_of_any ( const xtd::array< value_type > & values) const
noexcept

Reports the index of the first occurrence in this instance of any character in a specified array of characters.

Parameters
valuesAn unicode character array containing one or more characters to seek
Returns
The index position of the first occurrence in this instance where any character in values was found; otherwise, std::basic_string<char_t>::npos if no character in values was found.

◆ index_of_any() [2/3]

template<class char_t, class traits_t, class allocator_t>
xtd::size xtd::basic_string< char_t, traits_t, allocator_t >::index_of_any ( const xtd::array< value_type > & values,
xtd::size start_index ) const

Reports the index of the first occurrence in this instance of any character in a specified array of characters. The search starts at a specified character position.

Parameters
valuesAn unicode character array containing one or more characters to seek
start_indexThe search starting position
Returns
The index position of the first occurrence in this instance where any character in values was found; otherwise, std::basic_string<char_t>::npos if no character in values was found.
Exceptions
xtd::index_out_of_range_exceptionstart_index + count are greater than the length of this instance.

◆ index_of_any() [3/3]

template<class char_t, class traits_t, class allocator_t>
xtd::size xtd::basic_string< char_t, traits_t, allocator_t >::index_of_any ( const xtd::array< value_type > & values,
xtd::size start_index,
xtd::size count ) const

Reports the index of the first occurrence in this instance of any character in a specified array of characters. The search starts at a specified character position.

Parameters
valuesAn unicode character array containing one or more characters to seek
start_indexThe search starting position
countThe number of character positions to examine.
Returns
The index position of the first occurrence in this instance where any character in values was found; otherwise, std::basic_string<char_t>::npos if no character in values was found.
Exceptions
xtd::index_out_of_range_exceptionstart_index + count are greater than the length of this instance.

◆ insert()

template<class char_t, class traits_t, class allocator_t>
basic_string xtd::basic_string< char_t, traits_t, allocator_t >::insert ( xtd::size start_index,
const basic_string< char_t, traits_t, allocator_t > & value ) const
inline

Inserts a specified instance of basic_string at a specified index position in this instance.

Parameters
start_indexThe index position of the insertion.
valueThe basic_string to insert.
Returns
A new basic_string equivalent to this instance but with value inserted at position start_index.
Remarks
If start_index is equal to the length of this instance, value is appended to the end of this instance.
For example, the return value of "abc".Insert(2, "XYZ") is "abXYZc".

◆ is_empty()

template<class char_t, class traits_t, class allocator_t>
bool xtd::basic_string< char_t, traits_t, allocator_t >::is_empty ( ) const
inlinenoexcept

Indicates whether this basic_string is an empty basic_string ("").

Returns
true if the value parameter is null or an empty basic_string (""); otherwise, false.
Deprecated
Replaced by xtd::basic_string::is_empty(const xtd::basic_string&) - Will be removed in version 0.4.0.

◆ last_index_of() [1/6]

template<class char_t, class traits_t, class allocator_t>
xtd::size xtd::basic_string< char_t, traits_t, allocator_t >::last_index_of ( const basic_string< char_t, traits_t, allocator_t > & value) const
inlinenoexcept

Reports the index of the last occurrence of the specified basic_string in this basic_string.

Parameters
valueAn unicode character to seek
Returns
The index position of value if that character is found, or std::basic_string<char_t>::npos if it is not.

◆ last_index_of() [2/6]

template<class char_t, class traits_t, class allocator_t>
xtd::size xtd::basic_string< char_t, traits_t, allocator_t >::last_index_of ( const basic_string< char_t, traits_t, allocator_t > & value,
xtd::size start_index ) const
inline

Reports the index of the last occurrence of the specified character in this basic_string. The search starts at a specified character position.

Parameters
valueAn unicode character to seek
start_indexThe search starting position
Returns
The index position of value if that character is found, or std::basic_string<char_t>::npos if it is not.
Exceptions
xtd::index_out_of_range_exceptionstart_index + count are greater than the length of this instance.

◆ last_index_of() [3/6]

template<class char_t, class traits_t, class allocator_t>
xtd::size xtd::basic_string< char_t, traits_t, allocator_t >::last_index_of ( const basic_string< char_t, traits_t, allocator_t > & value,
xtd::size start_index,
xtd::size count ) const
inline

Reports the index of the last occurrence of the specified character in this basic_string. The search starts at a specified character position and examines a specified number of character positions.

Parameters
valueAn unicode character to seek
start_indexThe search starting position
countThe number of character positions to examine
Returns
The index position of value if that character is found, or std::basic_string<char_t>::npos if it is not.
Exceptions
xtd::index_out_of_range_exceptionstart_index + count are greater than the length of this instance.

◆ last_index_of() [4/6]

template<class char_t, class traits_t, class allocator_t>
xtd::size xtd::basic_string< char_t, traits_t, allocator_t >::last_index_of ( value_type value) const
inlinenoexcept

Reports the index of the last occurrence of the specified character in this tring.

Parameters
valueAn unicode character to seek
Returns
The index position of value if that character is found, or std::basic_string<char_t>::npos if it is not.

◆ last_index_of() [5/6]

template<class char_t, class traits_t, class allocator_t>
xtd::size xtd::basic_string< char_t, traits_t, allocator_t >::last_index_of ( value_type value,
xtd::size start_index ) const
inline

Reports the index of the last occurrence of the specified character in this basic_string. The search starts at a specified character position.

Parameters
valueAn unicode character to seek
start_indexThe search starting position
Returns
The index position of value if that character is found, or std::basic_string<char_t>::npos if it is not.
Exceptions
xtd::index_out_of_range_exceptionstart_index + count are greater than the length of this instance.

◆ last_index_of() [6/6]

template<class char_t, class traits_t, class allocator_t>
xtd::size xtd::basic_string< char_t, traits_t, allocator_t >::last_index_of ( value_type value,
xtd::size start_index,
xtd::size count ) const
inline

Reports the index of the last occurrence of the specified character in this basic_string. The search starts at a specified character position and examines a specified number of character positions.

Parameters
strA basic_string to find last index of.
valueAn unicode character to seek
start_indexThe search starting position
countThe number of character positions to examine
Returns
The index position of value if that character is found, or std::basic_string<char_t>::npos if it is not.
Exceptions
xtd::index_out_of_range_exceptionstart_index + count are greater than the length of this instance.

◆ last_index_of_any() [1/3]

template<class char_t, class traits_t, class allocator_t>
xtd::size xtd::basic_string< char_t, traits_t, allocator_t >::last_index_of_any ( const xtd::array< value_type > & values) const
noexcept

Reports the index of the last occurrence in this instance of any character in a specified array of characters.

Parameters
valuesAn unicode character array containing one or more characters to seek
Returns
The index position of the first occurrence in this instance where any character in values was found; otherwise, std::basic_string<char_t>::npos if no character in values was found.

◆ last_index_of_any() [2/3]

template<class char_t, class traits_t, class allocator_t>
xtd::size xtd::basic_string< char_t, traits_t, allocator_t >::last_index_of_any ( const xtd::array< value_type > & values,
xtd::size start_index ) const

Reports the index of the last occurrence in this instance of any character in a specified array of characters. The search starts at a specified character position.

Parameters
valuesAn unicode character array containing one or more characters to seek
start_indexThe search starting position
Returns
The index position of the first occurrence in this instance where any character in values was found; otherwise, std::basic_string<char_t>::npos if no character in values was found.

◆ last_index_of_any() [3/3]

template<class char_t, class traits_t, class allocator_t>
xtd::size xtd::basic_string< char_t, traits_t, allocator_t >::last_index_of_any ( const xtd::array< value_type > & values,
xtd::size start_index,
xtd::size count ) const

Reports the index of the last occurrence in this instance of any character in a specified array of characters. The search starts at a specified character position.

Parameters
valuesAn unicode character array containing one or more characters to seek
start_indexThe search starting position
countThe number of character positions to examine.
Returns
The index position of the first occurrence in this instance where any character in values was found; otherwise, std::basic_string<char_t>::npos if no character in values was found.

◆ pad_left() [1/2]

template<class char_t, class traits_t, class allocator_t>
basic_string xtd::basic_string< char_t, traits_t, allocator_t >::pad_left ( xtd::size total_width) const
inlinenoexcept

Right-aligns the characters in this basic_string, padding with spaces on the left for a specified total length.

Parameters
total_widthThe number of characters in the resulting basic_string, equal to the number of original characters plus any additional padding characters.
Returns
A new basic_string that is equivalent to the specified basic_string, but right-aligned and padded on the left with as many spaces as needed to create a length of total_width. Or, if total_width is less than the length of the specified basic_string, a new basic_string object that is identical to the specified basic_string.
Remarks
An unicode space is defined as hexadecimal 0x20.
The pad_left(const std::basic_string<char_t>&, int) method pads the beginning of the returned basic_string. This means that, when used with right-to-left languages, it pads the right portion of the basic_string..

◆ pad_left() [2/2]

template<class char_t, class traits_t, class allocator_t>
basic_string xtd::basic_string< char_t, traits_t, allocator_t >::pad_left ( xtd::size total_width,
char32 padding_char ) const
inlinenoexcept

Right-aligns the characters in this basic_string, padding with spaces on the left for a specified total length.

Parameters
total_widthThe number of characters in the resulting basic_string, equal to the number of original characters plus any additional padding characters.
paddingCharAn unicode padding character.
Returns
A new basic_string that is equivalent to the specified basic_string, but right-aligned and padded on the left with as many spaces as needed to create a length of total_width. Or, if total_width is less than the length of the specified basic_string, a new basic_string object that is identical the specified basic_string.
Remarks
An unicode space is defined as hexadecimal 0x20.
The pad_left(const std::basic_string<char_t>&, int) method pads the beginning of the returned basic_string. This means that, when used with right-to-left languages, it pads the right portion of the basic_string..

◆ pad_right() [1/2]

template<class char_t, class traits_t, class allocator_t>
basic_string xtd::basic_string< char_t, traits_t, allocator_t >::pad_right ( xtd::size total_width) const
inlinenoexcept

Left-aligns the characters in this basic_string, padding with spaces on the right for a specified total length.

Parameters
totalWidthThe number of characters in the resulting basic_string, equal to the number of original characters plus any additional padding characters.
Returns
A new basic_string that is equivalent to the specified basic_string, but left-aligned and padded on the right with as many spaces as needed to create a length of totalWidth. Or, if totalWidth is less than the length of the specified basic_string, a new basic_string object that is identical to the specified basic_string.
Remarks
An unicode space is defined as hexadecimal 0x20.
The PadRight(const std::basic_string<char_t>&, int) method pads the end of the returned basic_string. This means that, when used with right-to-left languages, it pads the left portion of the basic_string..

◆ pad_right() [2/2]

template<class char_t, class traits_t, class allocator_t>
basic_string xtd::basic_string< char_t, traits_t, allocator_t >::pad_right ( xtd::size total_width,
char32 padding_char ) const
inlinenoexcept

Left-aligns the characters in this basic_string, padding with spaces on the right for a specified total length.

Parameters
totalWidthThe number of characters in the resulting basic_string, equal to the number of original characters plus any additional padding characters.
paddingCharAn unicode padding character.
Returns
A new basic_string that is equivalent to the specified basic_string, but left-aligned and padded on the tight with as many spaces as needed to create a length of totalWidth. Or, if totalWidth is less than the length of the specified basic_string, a new basic_string object that is identical to the specified basic_string.
Remarks
An unicode space is defined as hexadecimal 0x20.
The xtd::basic_string::pad_right method pads the end of the returned basic_string. This means that, when used with right-to-left languages, it pads the left portion of the basic_string..

◆ quoted() [1/3]

template<class char_t, class traits_t, class allocator_t>
basic_string xtd::basic_string< char_t, traits_t, allocator_t >::quoted ( ) const
inline

Allows insertion and extraction of quoted strings, such as the ones found in CSV or XML.

Returns
A new quoted basic_string.
Remarks
the delimiter is set to
" 
by default and the escape is set to \ by default.
for more information see std::quoted.

◆ quoted() [2/3]

template<class char_t, class traits_t, class allocator_t>
basic_string xtd::basic_string< char_t, traits_t, allocator_t >::quoted ( value_type delimiter) const
inline

Allows insertion and extraction of quoted strings, such as the ones found in CSV or XML ith specified delimiter.

Parameters
delimiterThe character to use as the delimiter, defaults to "</tt>. @return A new quoted basic_string. @remarks for more information see <a href="https://en.cppreference.com/w/cpp/io/manip/quoted" >std::quoted.

◆ quoted() [3/3]

template<class char_t, class traits_t, class allocator_t>
basic_string xtd::basic_string< char_t, traits_t, allocator_t >::quoted ( value_type delimiter,
value_type escape ) const
inline

Allows insertion and extraction of quoted strings, such as the ones found in CSV or XML ith specified delimiter and escape.

Parameters
delimiterThe character to use as the delimiter, defaults to "</tt>. @param escape The character to use as the escape character, defaults to <tt>\\</tt>. @return A new quoted basic_string. @remarks for more information see <a href="https://en.cppreference.com/w/cpp/io/manip/quoted" >std::quoted.

◆ remove() [1/2]

template<class char_t, class traits_t, class allocator_t>
basic_string xtd::basic_string< char_t, traits_t, allocator_t >::remove ( xtd::size start_index) const
inline

Deletes all the characters from this basic_string beginning at a specified position and continuing through the last position.

Parameters
start_indexThe position to begin deleting characters.
Returns
A new basic_string object that is equivalent to this basic_string less the removed characters.

◆ remove() [2/2]

template<class char_t, class traits_t, class allocator_t>
basic_string xtd::basic_string< char_t, traits_t, allocator_t >::remove ( xtd::size start_index,
xtd::size count ) const
inline

Deletes all the characters from this basic_string beginning at a specified position and continuing through the last position.

Parameters
start_indexThe position to begin deleting characters.
countThe number of characters to delete.
Returns
A new basic_string object that is equivalent to this basic_string less the removed characters.

◆ replace() [1/2]

template<class char_t, class traits_t, class allocator_t>
basic_string xtd::basic_string< char_t, traits_t, allocator_t >::replace ( value_type old_char,
value_type new_char ) const
inlinenoexcept

Replaces all occurrences of a specified char_t in this basic_string with another specified char_t.

Parameters
old_charA char_t to be replaced.
new_charA char_t to replace all occurrences of old_char.
Returns
A new basic_string equivalent to the specified basic_string but with all instances of old_char replaced with new_char.

◆ replace() [2/2]

template<class char_t, class traits_t, class allocator_t>
basic_string xtd::basic_string< char_t, traits_t, allocator_t >::replace ( const basic_string< char_t, traits_t, allocator_t > & old_string,
const basic_string< char_t, traits_t, allocator_t > & new_string ) const
inlinenoexcept

Replaces all occurrences of a specified basic_string in this basic_string with another specified basic_string.

Parameters
old_stringA basic_string to be replaced.
new_stringA basic_string to replace all occurrences of old_string.
Returns
A new basic_string equivalent to the specified basic_string but with all instances of old_string replaced with new_string.
Remarks
If new_string is empty, all occurrences of old_string are removed

◆ rfind() [1/2]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::rfind ( const_pointer s) const
inline

Finds the last substring that is equal to the given character sequence. The search begins at xtd::basic_string::nposand proceeds from right to left (thus, the found substring, if any, cannot begin in a position following xtd::basic_string::npos). If xtd::basic_string::npos or any value not smaller than xtd::basic_string::size() - 1 is passed as xtd::basic_string::npos, the whole string will be searched. / @return Position of the first character of the found substring or xtd::basic_string::npos if no such substring is found. / @remarks Finds the first substring equal tostr. size_type rfind(const basic_string& str) const {return chars_.rfind(str);} / @brief Finds the last substring that is equal to the given character sequence. The search begins atposand proceeds from right to left (thus, the found substring, if any, cannot begin in a position followingpos). If xtd::basic_string::npos or any value not smaller than xtd::basic_string::size() - 1 is passed aspos, the whole string will be searched. / @param str The string to search for. / @param pos The position at which to start the search / @return Position of the first character of the found substring or xtd::basic_string::npos if no such substring is found. / @remarks Finds the first substring equal tostr. size_type rfind(const basic_string& str, size_type pos) const {return chars_.rfind(str, pos);} / @brief Finds the last substring that is equal to the given character sequence. The search begins atposand proceeds from right to left (thus, the found substring, if any, cannot begin in a position followingpos). If xtd::basic_string::npos or any value not smaller than xtd::basic_string::size() - 1 is passed aspos, the whole string will be searched. / @param str The string to search for. / @param pos The position at which to start the search / @param count The length of substring to search for. / @return Position of the first character of the found substring or xtd::basic_string::npos if no such substring is found. / @remarks Finds the first substring equal to the range [s, s + count). / @remarks This range may contain null characters. If [s,s + count) is not a valid range, the behavior is undefined. size_type rfind(const_pointer s, size_type pos, size_type count) const {return chars_.rfind(s, pos, count);} / @brief Finds the last substring that is equal to the given character sequence. The search begins at xtd::basic_string::npos and proceeds from right to left (thus, the found substring, if any, cannot begin in a position following xtd::basic_string::npos). If xtd::basic_string::npos or any value not smaller than xtd::basic_string::size() - 1 is passed as xtd::basic_string::npos, the whole string will be searched.

Parameters
sThe pointer to a character string to search for.
Returns
Position of the first character of the found substring or xtd::basic_string::npos if no such substring is found.
Remarks
Finds the first substring equal to the character string pointed to by s. The length of the string is determined by the first null character using traits_t::length(s).
If [s, s + traits_t::length(s)) is not a valid range, the behavior is undefined.

◆ rfind() [2/2]

template<class char_t, class traits_t, class allocator_t>
size_type xtd::basic_string< char_t, traits_t, allocator_t >::rfind ( const_pointer s,
size_type pos ) const
inline

Finds the last substring that is equal to the given character sequence. The search begins at pos and proceeds from right to left (thus, the found substring, if any, cannot begin in a position following pos). If xtd::basic_string::npos or any value not smaller than xtd::basic_string::size() - 1 is passed as pos, the whole string will be searched.

Parameters
sThe pointer to a character string to search for.
posThe position at which to start the search
Returns
Position of the first character of the found substring or xtd::basic_string::npos if no such substring is found.
Remarks
Finds the first substring equal to the character string pointed to by s. The length of the string is determined by the first null character using traits_t::length(s).
If [s, s + traits_t::length(s)) is not a valid range, the behavior is undefined.

The documentation for this class was generated from the following file: