cpp-strings 1.0.4
Pythonic c++ strings
Loading...
Searching...
No Matches
pcs::CppStringT< CharT, TraitsT, AllocatorT > Class Template Reference

This is the templated base class for all CppString classes. More...

#include <cppstrings.h>

Inheritance diagram for pcs::CppStringT< CharT, TraitsT, AllocatorT >:

Classes

class  NotFoundException
class  TransTable
 The internal class of translation tables, used with methods CppStringT::maketrans and CppStringT::translate. More...

Public Types

using allocator_type = MyBaseClass::allocator_type
using const_iterator = MyBaseClass::const_iterator
using const_pointer = MyBaseClass::const_pointer
using const_reference = MyBaseClass::const_reference
using const_reverse_iterator = MyBaseClass::const_reverse_iterator
using difference_type = MyBaseClass::difference_type
using iterator = MyBaseClass::iterator
using MyBaseClass = std::basic_string<CharT, TraitsT, AllocatorT>
using pointer = MyBaseClass::pointer
using reference = MyBaseClass::reference
using reverse_iterator = MyBaseClass::reverse_iterator
using size_type = MyBaseClass::size_type
using traits_type = MyBaseClass::traits_type
using value_type = MyBaseClass::value_type

Public Member Functions

CppStringT capitalize () noexcept
 Returns a copy of the string with its first character capitalized and the rest lowercased.
CppStringT center (const size_type width, const value_type fillch=value_type(' ')) const noexcept
 Returns a copy of the string centered in a string of length width.
constexpr bool contains (const CppStringT &substr) const noexcept
 Returns true if this string contains the passed string, or false otherwise.
constexpr bool contains_n (const CppStringT &sub, const size_type start, const size_type count=-1) const noexcept
 Returns true if the passed string is found within the slice str[start:start+count-1], or false otherwise.
constexpr size_type count (const CppStringT &sub, const size_type start=0, const size_type end=-1) const noexcept
 Returns the number of non-overlapping occurrences of substring sub in the range [start, end].
constexpr size_type count_n (const CppStringT &sub, const size_type length) const noexcept
 Returns the number of non-overlapping occurrences of substring sub in the range [0, length-1].
constexpr size_type count_n (const CppStringT &sub, const size_type start, const size_type length) const noexcept
 Returns the number of non-overlapping occurrences of substring sub in the range [start, start+length-1].
 CppStringT (const CharT *s)
 CppStringT (const CharT *s, size_type count)
 CppStringT (const CharT ch)
 CppStringT (const CppStringT &other)
 CppStringT (const CppStringT &other, const AllocatorT &alloc)
 CppStringT (const CppStringT &other, size_type pos)
 CppStringT (const CppStringT &other, size_type pos, size_type count) noexcept
 CppStringT (const MyBaseClass &other)
 CppStringT (const MyBaseClass &other, const AllocatorT &alloc)
 CppStringT (CppStringT &&other) noexcept
 CppStringT (CppStringT &&other, const AllocatorT &alloc) noexcept
template<class InputIt>
 CppStringT (InputIt first, InputIt last)
 CppStringT (MyBaseClass &&other)
 CppStringT (MyBaseClass &&other, const AllocatorT &alloc)
 CppStringT (MyBaseClass::size_type count, CharT ch)
 CppStringT (std::initializer_list< CharT > ilist)
template<class StringViewLike>
 CppStringT (StringViewLike &svl)
template<class StringViewLike>
 CppStringT (StringViewLike &svl, size_type pos, size_type n)
const bool endswith (const CppStringT &suffix) const noexcept
 Returns true if the string ends with the specified suffix, otherwise returns false. Test runs on the whole string.
const bool endswith (const CppStringT &suffix, const size_type end) const noexcept
 Returns true if the string ends with the specified suffix, otherwise returns false. Test begins at start of string and stops at end position.
const bool endswith (const CppStringT &suffix, const size_type start, const size_type end) const noexcept
 Returns true if the string ends with the specified suffix, otherwise returns false. Test begins at start position and stops at end position.
const bool endswith (const std::initializer_list< CppStringT > &suffixes, const size_type start, const size_type end) const noexcept
 Returns true if the string ends with any of the specified suffixes, otherwise returns false. Test begins at start position and stops at end position.
const bool endswith_n (const CppStringT &suffix, const size_type count) const noexcept
 Returns true if the string ends with the specified suffix, otherwise returns false. Test begins at position 0 and stops after count positions.
const bool endswith_n (const CppStringT &suffix, const size_type start, const size_type count) const noexcept
 Returns true if the string ends with the specified suffix, otherwise returns false. Test begins at start position and stops after count positions.
const bool endswith_n (const std::initializer_list< CppStringT > &suffixes, const size_type start, const size_type count) const noexcept
 Returns true if the string ends with any of the specified suffixes, otherwise returns false. Test begins at start position and stops after count positions.
CppStringT expand_tabs (const size_type tabsize=8) const noexcept
 Returns a copy of the string where all tab characters are replaced by one or more spaces, depending on the current column and the given tab size.
constexpr size_type find (const CppStringT &sub, const size_type start=0, const size_type end=-1) const noexcept
 Returns the lowest index in the string where substring sub is found within the slice str[start:end], or -1 (i.e. 'npos') if sub is not found.
constexpr size_type find_n (const CppStringT &sub, const size_type count) const noexcept
 Returns the lowest index in the string where substring sub is found within the slice str[0:count-1], or -1 (i.e. 'npos') if sub is not found.
constexpr size_type find_n (const CppStringT &sub, const size_type start, const size_type count) const noexcept
 Returns the lowest index in the string where substring sub is found within the slice str[start:start+count-1], or -1 (i.e. 'npos') if sub is not found.
template<class... ArgsT>
CppStringTformat (const std::basic_format_string< char, std::type_identity_t< ArgsT >... > frmt, ArgsT &&... args)
template<typename T, class... ArgsT>
CppStringTformat (const std::basic_format_string< T, std::type_identity_t< ArgsT >... > frmt, ArgsT &&... args)
 Formats this string according to c++20 std::format() specification. Returns this string.
template<class... ArgsT>
CppStringTformat (const std::basic_format_string< wchar_t, std::type_identity_t< ArgsT >... > frmt, ArgsT &&... args)
constexpr size_type index (const CppStringT &sub, const size_type start=0, const size_type end=-1) const
 Like find(const CppStringT&), but raises NotFoundException when the substring sub is not found.
constexpr size_type index_n (const CppStringT &sub, const size_type count) const
 Like find_n(sub, count), but raises NotFoundException when the substring is not found.
constexpr size_type index_n (const CppStringT &sub, const size_type start, const size_type count) const
 Like find_n(sub, start, count), but raises NotFoundException when the substring is not found.
const bool is_words_sep () const noexcept
 Returns true if there are only whitespace and punctuation characters in the string and there is at least one character, or false otherwise.
const bool isalnum () const noexcept
 Returns true if all characters in the string are alphanumeric and there is at least one character, or false otherwise.
const bool isalpha () const noexcept
 Returns true if all characters in the string are alphabetic and there is at least one character, or false otherwise.
const bool isascii () const noexcept
 Returns true if the string is empty or all characters in the string are ASCII, or false otherwise.
const bool isdecimal () const noexcept
 Returns true if all characters in the string are decimal characters and there is at least one character, or false otherwise.
const bool isdigit () const noexcept
 Returns true if all characters in the string are digits and there is at least one character, or false otherwise.
const bool isidentifier () const noexcept
 Returns true if the string is not empty and is a valid identifier according to the language definition, or false otherwise.
const bool islower () const noexcept
 Returns true if all cased characters in the string are lowercase and there is at least one cased character, or false otherwise.
const bool isnumeric () const noexcept
 Returns true if all characters in the string are numeric characters, and there is at least one character, or false otherwise.
const bool isprintable () const noexcept
 Returns true if all characters in the string are printable or if the string is empty, or false otherwise.
const bool ispunctuation () const noexcept
 Returns true if the string contains only one character and if this character belongs to the ASCII punctuation set.
const bool isspace () const noexcept
 Returns true if there are only whitespace characters in the string and there is at least one character, or false otherwise.
const bool istitle () const noexcept
 Returns true if the string is a titlecased string and there is at least one character, or false otherwise.
const bool isupper () const noexcept
 Returns true if all cased characters in the string are uppercase and there is at least one cased character, or false otherwise.
const CppStringT join () const noexcept
 Empty parameters list signature. Returns a copy of current string.
template<class... NextCppStringsT>
requires (sizeof...(others) > 0)
CppStringT join (const CppStringT &first, const NextCppStringsT &... others) const noexcept
 Returns a string which is the concatenation of the strings in the parameters list.
CppStringT join (const CppStringT &s) const noexcept
 Single parameter signature. Returns a copy of this parameter.
template<const std::size_t N>
CppStringT join (const std::array< CppStringT, N > &strs) const noexcept
 Returns a string which is the concatenation of the strings in the array parameter.
CppStringT join (const std::vector< CppStringT > &strs) const noexcept
 Returns a string which is the concatenation of the strings in the vector parameter.
CppStringT ljust (const size_type width, const value_type fillch=value_type(' ')) const noexcept
 Returns the string left justified in a string of length width.
CppStringTlower () noexcept
 In-place replaces all characters of the string with their lowercase conversion. Returns a reference to string.
CppStringT lstrip () const noexcept
 Returns a copy of the string with leading whitespaces removed.
CppStringT lstrip (const CppStringT &removedchars) const noexcept
 Returns a copy of the string with leading characters removed.
CppStringT operator() (const long long start, const long long stop, const long long step=1) const noexcept
 Generates a new string according to the specified slicing values.
template<typename IntT>
requires std::is_signed_v<IntT>
CppStringT operator() (Slice< IntT > slice) const noexcept
 Generates a new string according to the specified slice.
CppStringT operator* (std::int64_t count) const noexcept
 Generates a new string with count times the content of this string.
CppStringToperator= (const CppStringT &) noexcept=default
 Default copy assignment.
CppStringToperator= (CppStringT &&) noexcept=default
 Default move assignment.
std::vector< CppStringTpartition (const CppStringT &sep) const noexcept
 Splits the string at the first occurrence of sep, and returns a 3-items vector containing the part before the separator, the separator itself, and the part after the separator.
CppStringT removeprefix (const CppStringT &prefix) const noexcept
 If the string starts with the prefix string, returns a new string with the prefix removed. Otherwise, returns a copy of the original string.
CppStringT removesuffix (const CppStringT &suffix) const noexcept
 If the string ends with the suffix string, returns a new string with the suffix removed. Otherwise, returns a copy of the original string.
CppStringT replace (const CppStringT &old, const CppStringT &new_, size_type count=-1) const noexcept
 Returns a copy of the string with first count occurrences of substring 'old' replaced by 'new_'.
constexpr size_type rfind (const CppStringT &sub) const noexcept
 Returns the highest index in the string where C-substring sub is found in the whole string, or -1 (i.e. 'npos') if sub is not found.
constexpr size_type rfind (const CppStringT &sub, const size_type start) const noexcept
 Returns the highest index in the string where substring sub is found starting at start position in string, or -1 (i.e. 'npos') if sub is not found.
constexpr size_type rfind (const CppStringT &sub, const size_type start, const size_type end) const noexcept
 Returns the highest index in the string where substring sub is found within the slice str[start:end], or -1 (i.e. 'npos') if sub is not found.
constexpr size_type rfind_n (const CppStringT &sub, const size_type count) const noexcept
 Returns the highest index in the string where substring sub is found within the slice str[0:count-1], or -1 (i.e. 'npos') if sub is not found.
constexpr size_type rfind_n (const CppStringT &sub, const size_type start, const size_type count) const noexcept
 Returns the highest index in the string where substring sub is found within the slice str[start:start+count-1], or -1 (i.e. 'npos') if sub is not found.
constexpr size_type rindex (const CppStringT &sub) const
 Like rfind(sub), but raises NotFoundException when the substring is not found.
constexpr size_type rindex (const CppStringT &sub, const size_type start) const
 Like rfind(sub, start), but raises NotFoundException when the substring is not found.
constexpr size_type rindex (const CppStringT &sub, const size_type start, const size_type end) const
 Like rfind(sub, start, end), but raises NotFoundException when the substring is not found.
constexpr size_type rindex_n (const CppStringT &sub, const size_type count) const
 Like rfind_n(sub, count), but raises NotFoundException when the substring is not found.
constexpr size_type rindex_n (const CppStringT &sub, const size_type start, const size_type count) const
 Like rfind_n(sub, start, count), but raises NotFoundException when the substring is not found.
CppStringT rjust (const size_type width, const value_type fillch=value_type(' ')) const noexcept
 Returns the string right justified in a string of length width.
std::vector< CppStringTrpartition (const CppStringT &sep) const noexcept
 Splits the string at the last occurrence of sep, and returns a 3-items vector containing the part before the separator, the separator itself, and the part after the separator.
std::vector< CppStringTrsplit () noexcept
 Returns a vector of the words in the whole string, as seperated with whitespace strings.
std::vector< CppStringTrsplit (const CppStringT &sep) noexcept
 Returns a vector of the words in the whole string, using sep as the delimiter string.
std::vector< CppStringTrsplit (const CppStringT &sep, const size_type maxsplit) noexcept
 Returns a vector of the words in the string, using sep as the delimiter string. At most maxsplit splits are done, the rightmost ones.
std::vector< CppStringTrsplit (const size_type maxsplit) noexcept
 Returns a vector of the words in the string, as seperated with whitespace strings. At most maxsplit splits are done, the rightmost ones.
CppStringT rstrip () const noexcept
 Returns a copy of the string with trailing whitespaces removed.
CppStringT rstrip (const CppStringT &removedchars) const noexcept
 Returns a copy of the string with trailing characters removed.
std::vector< CppStringTsplit () noexcept
 Returns a vector of the words in the whole string, as seperated with whitespace strings.
std::vector< CppStringTsplit (const CppStringT &sep) noexcept
 Returns a vector of the words in the whole string, using sep as the delimiter string.
std::vector< CppStringTsplit (const CppStringT &sep, const size_type maxsplit) noexcept
 Returns a vector of the words in the string, using sep as the delimiter string. At most maxsplit splits are done, the leftmost ones.
std::vector< CppStringTsplit (const size_type maxsplit) noexcept
 Returns a vector of the words in the string, as seperated with whitespace strings. At most maxsplit splits are done, the leftmost ones.
std::vector< CppStringTsplitlines (const bool keep_end=false) const noexcept
 Return a list of the lines in the string, breaking at line boundaries.
const bool startswith (const CppStringT &prefix) const noexcept
 Returns true if the string starts with the specified prefix, otherwise returns false. Test runs on the whole string.
const bool startswith (const CppStringT &prefix, const size_type start) const noexcept
 Returns true if the string starts with the specified prefix, otherwise returns false. Test begins at start position and stops at end of string.
const bool startswith (const CppStringT &prefix, const size_type start, const size_type end) const noexcept
 Returns true if the string starts with the specified prefix, otherwise returns false. Test begins at start position and stops at end position.
const bool startswith (const std::initializer_list< CppStringT > &prefixes, const size_type start, const size_type end) const noexcept
 Returns true if the string starts with any of the specified prefixes, otherwise returns false. Test begins at start position and stops at end of string.
const bool startswith_n (const CppStringT &prefix, const size_type count) const noexcept
 Returns true if the string starts with the specified suffix, otherwise returns false. Test begins at position 0 and stops after count positions.
const bool startswith_n (const CppStringT &prefix, const size_type start, const size_type count) const noexcept
 Returns true if the string starts with the specified suffix, otherwise returns false. Test begins at start position and stops after count positions.
const bool startswith_n (const std::initializer_list< CppStringT > &prefix, const size_type start, const size_type count) const noexcept
 Returns true if the string starts with any of the specified suffixes, otherwise returns false. Test begins at start position and stops after count positions.
CppStringT strip () const noexcept
 Returns a copy of the string with the leading and trailing whitespaces removed.
CppStringT strip (const CppStringT &removedchars) const noexcept
 Returns a copy of the string with the leading and trailing characters removed.
CppStringT substr (const size_type start, const size_type count=-1) const noexcept
 Returns a copy of the string, starting at index start and ending after count characters.
CppStringT swapcase () const noexcept
 Returns a copy of the string with uppercase characters converted to lowercase and vice versa.
CppStringT title () const noexcept
 Returns a titlecased copy of the string where words start with an uppercase character and the remaining characters are lowercase.
CppStringT translate (TransTable &table) noexcept
 Returns a copy of the string in which each character has been mapped through the given translation table.
CppStringTupper () noexcept
 In-place replaces all characters of the string with their uppercase conversion. Returns a reference to string.
CppStringT zfill (const size_type width) const noexcept
 Returns a copy of the string left filled with ASCII '0' digits to make a string of length width.

Static Public Member Functions

static const value_type lower (const value_type ch) noexcept
 Returns lowercase conversion of the character.
static const value_type upper (const value_type ch) noexcept
 Returns uppercase conversion of the character.

Detailed Description

template<class CharT, class TraitsT, class AllocatorT>
class pcs::CppStringT< CharT, TraitsT, AllocatorT >

This is the templated base class for all CppString classes.

Users should instantiate any specialization of this base class rather than this base class itself:

Member Function Documentation

◆ capitalize()

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::capitalize ( )
inlinenoexcept

Returns a copy of the string with its first character capitalized and the rest lowercased.

◆ center()

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::center ( const size_type width,
const value_type fillch = value_type(' ') ) const
inlinenodiscardnoexcept

Returns a copy of the string centered in a string of length width.

Padding is done using the specified fillchar (default is an ASCII space). A copy of the original string is returned if width is less than or equal to the length of the string. The original string remains unchanged.

◆ contains()

template<class CharT, class TraitsT, class AllocatorT>
bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::contains ( const CppStringT< CharT, TraitsT, AllocatorT > & substr) const
inlinenodiscardconstexprnoexcept

Returns true if this string contains the passed string, or false otherwise.

This is a c++ implementation of Python keyword 'in' applied to strings.

Referenced by pcs::CppStringT< char >::contains_n().

◆ contains_n()

template<class CharT, class TraitsT, class AllocatorT>
bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::contains_n ( const CppStringT< CharT, TraitsT, AllocatorT > & sub,
const size_type start,
const size_type count = -1 ) const
inlinenodiscardconstexprnoexcept

Returns true if the passed string is found within the slice str[start:start+count-1], or false otherwise.

This is a c++ implementation of Python keyword 'in' applied to Python sliced strings.

◆ count()

template<class CharT, class TraitsT, class AllocatorT>
size_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::count ( const CppStringT< CharT, TraitsT, AllocatorT > & sub,
const size_type start = 0,
const size_type end = -1 ) const
inlinenodiscardconstexprnoexcept

Returns the number of non-overlapping occurrences of substring sub in the range [start, end].

Referenced by pcs::CppStringT< char >::count_n(), and pcs::CppStringT< char >::count_n().

◆ count_n() [1/2]

template<class CharT, class TraitsT, class AllocatorT>
size_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::count_n ( const CppStringT< CharT, TraitsT, AllocatorT > & sub,
const size_type length ) const
inlinenodiscardconstexprnoexcept

Returns the number of non-overlapping occurrences of substring sub in the range [0, length-1].

◆ count_n() [2/2]

template<class CharT, class TraitsT, class AllocatorT>
size_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::count_n ( const CppStringT< CharT, TraitsT, AllocatorT > & sub,
const size_type start,
const size_type length ) const
inlinenodiscardconstexprnoexcept

Returns the number of non-overlapping occurrences of substring sub in the range [start, start+length-1].

◆ endswith() [1/4]

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::endswith ( const CppStringT< CharT, TraitsT, AllocatorT > & suffix) const
inlinenodiscardnoexcept

Returns true if the string ends with the specified suffix, otherwise returns false. Test runs on the whole string.

◆ endswith() [2/4]

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::endswith ( const CppStringT< CharT, TraitsT, AllocatorT > & suffix,
const size_type end ) const
inlinenodiscardnoexcept

Returns true if the string ends with the specified suffix, otherwise returns false. Test begins at start of string and stops at end position.

◆ endswith() [3/4]

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::endswith ( const CppStringT< CharT, TraitsT, AllocatorT > & suffix,
const size_type start,
const size_type end ) const
inlinenodiscardnoexcept

Returns true if the string ends with the specified suffix, otherwise returns false. Test begins at start position and stops at end position.

Referenced by pcs::CppStringT< char >::endswith_n(), pcs::CppStringT< char >::endswith_n(), pcs::CppStringT< char >::endswith_n(), and pcs::CppStringT< char >::removesuffix().

◆ endswith() [4/4]

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::endswith ( const std::initializer_list< CppStringT< CharT, TraitsT, AllocatorT > > & suffixes,
const size_type start,
const size_type end ) const
inlinenodiscardnoexcept

Returns true if the string ends with any of the specified suffixes, otherwise returns false. Test begins at start position and stops at end position.

◆ endswith_n() [1/3]

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::endswith_n ( const CppStringT< CharT, TraitsT, AllocatorT > & suffix,
const size_type count ) const
inlinenodiscardnoexcept

Returns true if the string ends with the specified suffix, otherwise returns false. Test begins at position 0 and stops after count positions.

◆ endswith_n() [2/3]

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::endswith_n ( const CppStringT< CharT, TraitsT, AllocatorT > & suffix,
const size_type start,
const size_type count ) const
inlinenodiscardnoexcept

Returns true if the string ends with the specified suffix, otherwise returns false. Test begins at start position and stops after count positions.

◆ endswith_n() [3/3]

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::endswith_n ( const std::initializer_list< CppStringT< CharT, TraitsT, AllocatorT > > & suffixes,
const size_type start,
const size_type count ) const
inlinenodiscardnoexcept

Returns true if the string ends with any of the specified suffixes, otherwise returns false. Test begins at start position and stops after count positions.

◆ expand_tabs()

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::expand_tabs ( const size_type tabsize = 8) const
inlinenodiscardnoexcept

Returns a copy of the string where all tab characters are replaced by one or more spaces, depending on the current column and the given tab size.

◆ find()

template<class CharT, class TraitsT, class AllocatorT>
size_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::find ( const CppStringT< CharT, TraitsT, AllocatorT > & sub,
const size_type start = 0,
const size_type end = -1 ) const
inlinenodiscardconstexprnoexcept

Returns the lowest index in the string where substring sub is found within the slice str[start:end], or -1 (i.e. 'npos') if sub is not found.

Note: this method should be used only if you need to know the position of sub. To check if sub is a substring or not, use the method contains().

CAUTION: empty substrings are considered to be in the string if start and end positions are both less than the string size and if start <= end.

See also
find_n(), rfind() and rfind_n().
index(), index_n(), rindex() and rindex_n().

Referenced by pcs::CppStringT< char >::count(), pcs::CppStringT< char >::index(), pcs::CppStringT< char >::partition(), pcs::CppStringT< char >::replace(), and pcs::CppStringT< char >::split().

◆ find_n() [1/2]

template<class CharT, class TraitsT, class AllocatorT>
size_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::find_n ( const CppStringT< CharT, TraitsT, AllocatorT > & sub,
const size_type count ) const
inlinenodiscardconstexprnoexcept

Returns the lowest index in the string where substring sub is found within the slice str[0:count-1], or -1 (i.e. 'npos') if sub is not found.

Note: this method should be used only if you need to know the position of sub. To check if sub is a substring or not, use the method contains_n().

CAUTION: empty substrings are considered to be in the string if start and end positions are both less than the string size and if start <= end. The returned position is 0.

See also
find(), rfind() and rfind_n().
index(), index_n(), rindex() and rindex_n().

◆ find_n() [2/2]

template<class CharT, class TraitsT, class AllocatorT>
size_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::find_n ( const CppStringT< CharT, TraitsT, AllocatorT > & sub,
const size_type start,
const size_type count ) const
inlinenodiscardconstexprnoexcept

Returns the lowest index in the string where substring sub is found within the slice str[start:start+count-1], or -1 (i.e. 'npos') if sub is not found.

Note: this method should be used only if you need to know the position of sub. To check if sub is a substring or not, use the method contains_n().

CAUTION: empty substrings are considered to be in the string if start and end positions are both less than the string size and if start <= end. The returned position is 0.

See also
find(), rfind() and rfind_n().
index(), index_n(), rindex() and rindex_n().

Referenced by pcs::CppStringT< char >::find(), and pcs::CppStringT< char >::find_n().

◆ format() [1/3]

template<class CharT, class TraitsT, class AllocatorT>
template<class... ArgsT>
CppStringT & pcs::CppStringT< CharT, TraitsT, AllocatorT >::format ( const std::basic_format_string< char, std::type_identity_t< ArgsT >... > frmt,
ArgsT &&... args )
inline
Parameters
frmtspecialzation for char's

◆ format() [2/3]

template<class CharT, class TraitsT, class AllocatorT>
template<typename T, class... ArgsT>
CppStringT & pcs::CppStringT< CharT, TraitsT, AllocatorT >::format ( const std::basic_format_string< T, std::type_identity_t< ArgsT >... > frmt,
ArgsT &&... args )
inline

Formats this string according to c++20 std::format() specification. Returns this string.

◆ format() [3/3]

template<class CharT, class TraitsT, class AllocatorT>
template<class... ArgsT>
CppStringT & pcs::CppStringT< CharT, TraitsT, AllocatorT >::format ( const std::basic_format_string< wchar_t, std::type_identity_t< ArgsT >... > frmt,
ArgsT &&... args )
inline
Parameters
frmtspecialzation for wchar_t's

◆ index()

template<class CharT, class TraitsT, class AllocatorT>
size_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::index ( const CppStringT< CharT, TraitsT, AllocatorT > & sub,
const size_type start = 0,
const size_type end = -1 ) const
inlinenodiscardconstexpr

Like find(const CppStringT&), but raises NotFoundException when the substring sub is not found.

See also
index_n(), rindex() and rindex_n().
find(), find_n(), rfind() and rfind_n().

Referenced by pcs::CppStringT< char >::index_n(), and pcs::CppStringT< char >::index_n().

◆ index_n() [1/2]

template<class CharT, class TraitsT, class AllocatorT>
size_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::index_n ( const CppStringT< CharT, TraitsT, AllocatorT > & sub,
const size_type count ) const
inlinenodiscardconstexpr

Like find_n(sub, count), but raises NotFoundException when the substring is not found.

See also
index_n(), rindex() and rindex_n().
find(), find_n(), rfind() and rfind_n().

◆ index_n() [2/2]

template<class CharT, class TraitsT, class AllocatorT>
size_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::index_n ( const CppStringT< CharT, TraitsT, AllocatorT > & sub,
const size_type start,
const size_type count ) const
inlinenodiscardconstexpr

Like find_n(sub, start, count), but raises NotFoundException when the substring is not found.

See also
index_n(), rindex() and rindex_n().
find(), find_n(), rfind() and rfind_n().

◆ is_words_sep()

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::is_words_sep ( ) const
inlinenodiscardnoexcept

Returns true if there are only whitespace and punctuation characters in the string and there is at least one character, or false otherwise.

◆ isalnum()

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::isalnum ( ) const
inlinenodiscardnoexcept

Returns true if all characters in the string are alphanumeric and there is at least one character, or false otherwise.

◆ isalpha()

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::isalpha ( ) const
inlinenodiscardnoexcept

Returns true if all characters in the string are alphabetic and there is at least one character, or false otherwise.

◆ isascii()

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::isascii ( ) const
inlinenodiscardnoexcept

Returns true if the string is empty or all characters in the string are ASCII, or false otherwise.

◆ isdecimal()

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::isdecimal ( ) const
inlinenodiscardnoexcept

Returns true if all characters in the string are decimal characters and there is at least one character, or false otherwise.

Decimal characters are those that can be used to form numbers in base 10, e.g. U+0660, ARABIC-INDIC DIGIT ZERO. Formally a decimal character is a character in the Unicode General Category �Nd�.

Referenced by pcs::CppStringT< char >::isdigit(), and pcs::CppStringT< char >::isnumeric().

◆ isdigit()

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::isdigit ( ) const
inlinenodiscardnoexcept

Returns true if all characters in the string are digits and there is at least one character, or false otherwise.

Digits include decimal characters and digits that need special handling, such as the compatibility superscript digits. This covers digits which cannot be used to form numbers in base 10, like the Kharosthi numbers. Formally, a digit is a character that has the property value Numeric_Type=Digit or Numeric_Type =Decimal.

CAUTION: current implementation of library cpp-strings does not implement above algorithm. It just returns the same result as 'isdecimal()' which is NOT what Python str library does.

◆ isidentifier()

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::isidentifier ( ) const
inlinenodiscardnoexcept

Returns true if the string is not empty and is a valid identifier according to the language definition, or false otherwise.

CAUTION: the current implementation of this method does not deal with the proper c++ defintiion of identifiers (see https://en.cppreference.com/w/cpp/language/identifiers and https://www.unicode.org/reports/tr31/#Table_Lexical_Classes_for_Identifiers).

While the specification of identifiers in c++ is this one:

identifier ::= XID_Start XID_Continue* XID_Start ::= ID_Start XID_Continue* ID_Start ::= <characters derived from the Unicode General_Category of uppercase letters, lowercase letters, titlecase letters, modifier letters, other letters, letter numbers, plus Other_ID_Start, minus Pattern_Syntax and Pattern_White_Space code points> XID_Continue ::= <characters derived from ID_Continue as per Unicode specs Section 5.1, NFKC Modifications (https://www.unicode.org/reports/tr31/#NFKC_Modifications)> ID_Continue ::= ID_Start | <characters having the Unicode General_Category of nonspacing marks, spacing combining marks, decimal number, connector punctuation, plus Other_ID_Continue, minus Pattern_Syntax and Pattern_White_Space code points>

the currently implemented rule is this simpler one:

identifier ::= ID_Start id_continue* id_continue ::= ID_Start | decimal_number

◆ islower()

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::islower ( ) const
inlinenodiscardnoexcept

Returns true if all cased characters in the string are lowercase and there is at least one cased character, or false otherwise.

◆ isnumeric()

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::isnumeric ( ) const
inlinenodiscardnoexcept

Returns true if all characters in the string are numeric characters, and there is at least one character, or false otherwise.

CAUTION: current implementation just returns isdecimal() result, while the description of isnumeric() should be this one: Numeric characters include digit characters, and all characters that have the Unicode numeric value property. Formally, numeric characters are those with the property value Numeric_Type=Digit, Numeric_Type=Decimal or Numeric_Type=Numeric.

◆ isprintable()

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::isprintable ( ) const
inlinenodiscardnoexcept

Returns true if all characters in the string are printable or if the string is empty, or false otherwise.

Nonprintable characters are those characters defined in the Unicode character database as "Other" or "Separator", excepting the ASCII space (0x20) which is considered printable.

◆ ispunctuation()

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::ispunctuation ( ) const
inlinenodiscardnoexcept

Returns true if the string contains only one character and if this character belongs to the ASCII punctuation set.

◆ isspace()

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::isspace ( ) const
inlinenodiscardnoexcept

Returns true if there are only whitespace characters in the string and there is at least one character, or false otherwise.

◆ istitle()

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::istitle ( ) const
inlinenodiscardnoexcept

Returns true if the string is a titlecased string and there is at least one character, or false otherwise.

For instance uppercase characters may only follow uncased characters and lowercase characters only cased ones.

CAUTION: current implementation only tests for uppercase characters following whitespaces and lowercase characters anywhere else.

◆ isupper()

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::isupper ( ) const
inlinenodiscardnoexcept

Returns true if all cased characters in the string are uppercase and there is at least one cased character, or false otherwise.

◆ join() [1/5]

template<class CharT, class TraitsT, class AllocatorT>
const CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::join ( ) const
inlinenodiscardnoexcept

Empty parameters list signature. Returns a copy of current string.

Referenced by pcs::CppStringT< char >::join().

◆ join() [2/5]

template<class CharT, class TraitsT, class AllocatorT>
template<class... NextCppStringsT>
requires (sizeof...(others) > 0)
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::join ( const CppStringT< CharT, TraitsT, AllocatorT > & first,
const NextCppStringsT &... others ) const
inlinenodiscardnoexcept

Returns a string which is the concatenation of the strings in the parameters list.

The separator between elements is the string to which this method is applied.

◆ join() [3/5]

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::join ( const CppStringT< CharT, TraitsT, AllocatorT > & s) const
inlinenodiscardnoexcept

Single parameter signature. Returns a copy of this parameter.

◆ join() [4/5]

template<class CharT, class TraitsT, class AllocatorT>
template<const std::size_t N>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::join ( const std::array< CppStringT< CharT, TraitsT, AllocatorT >, N > & strs) const
inlinenodiscardnoexcept

Returns a string which is the concatenation of the strings in the array parameter.

The separator between elements is the string to which this method is applied.

Referenced by pcs::CppStringT< char >::title().

◆ join() [5/5]

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::join ( const std::vector< CppStringT< CharT, TraitsT, AllocatorT > > & strs) const
inlinenodiscardnoexcept

Returns a string which is the concatenation of the strings in the vector parameter.

The separator between elements is the string to which this method is applied.

◆ ljust()

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::ljust ( const size_type width,
const value_type fillch = value_type(' ') ) const
inlinenodiscardnoexcept

Returns the string left justified in a string of length width.

Padding is done using the specified fillchar (default is an ASCII space). The original string is returned if width is less than or equal to len(s).

Referenced by pcs::CppStringT< char >::zfill().

◆ lower() [1/2]

template<class CharT, class TraitsT, class AllocatorT>
CppStringT & pcs::CppStringT< CharT, TraitsT, AllocatorT >::lower ( )
inlinenoexcept

In-place replaces all characters of the string with their lowercase conversion. Returns a reference to string.

Notice: uses the currently set std::locale, which is the "C" one by default or any other one as previously set by the user.

Referenced by pcs::CppStringT< char >::capitalize(), and pcs::CppStringT< char >::lower().

◆ lower() [2/2]

template<class CharT, class TraitsT, class AllocatorT>
const value_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::lower ( const value_type ch)
inlinestaticnodiscardnoexcept

Returns lowercase conversion of the character.

Notice: uses the currently set std::locale, which is the "C" one by default or any other one as previously set by the user.

◆ lstrip() [1/2]

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::lstrip ( ) const
inlinenodiscardnoexcept

Returns a copy of the string with leading whitespaces removed.

◆ lstrip() [2/2]

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::lstrip ( const CppStringT< CharT, TraitsT, AllocatorT > & removedchars) const
inlinenodiscardnoexcept

Returns a copy of the string with leading characters removed.

The passed string specifies the set of characters to be removed. The chars argument is not a prefix; rather, all combinations of its values are stripped. To remove a prefix, rather call method 'removeprefix()'.

Referenced by pcs::CppStringT< char >::strip(), and pcs::CppStringT< char >::strip().

◆ operator()() [1/2]

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::operator() ( const long long start,
const long long stop,
const long long step = 1 ) const
inlinenodiscardnoexcept

Generates a new string according to the specified slicing values.

◆ operator()() [2/2]

template<class CharT, class TraitsT, class AllocatorT>
template<typename IntT>
requires std::is_signed_v<IntT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::operator() ( Slice< IntT > slice) const
inlinenodiscardnoexcept

Generates a new string according to the specified slice.

A slice is a range specified as [start, stop, step]. It may also be specified as [start, stop] in which case step = 1, or as [stop] in wich case start = 0 and step = 1. Values may be negative: negative step means reverse running and negative start or stop is relative to the end of the string. Notice: the stop value specifies an out of bounds index.

See also
class Slice and all its inheriting classes.

◆ operator*()

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::operator* ( std::int64_t count) const
inlinenodiscardnoexcept

Generates a new string with count times the content of this string.

◆ operator=() [1/2]

template<class CharT, class TraitsT, class AllocatorT>
CppStringT & pcs::CppStringT< CharT, TraitsT, AllocatorT >::operator= ( const CppStringT< CharT, TraitsT, AllocatorT > & )
defaultnoexcept

Default copy assignment.

◆ operator=() [2/2]

template<class CharT, class TraitsT, class AllocatorT>
CppStringT & pcs::CppStringT< CharT, TraitsT, AllocatorT >::operator= ( CppStringT< CharT, TraitsT, AllocatorT > && )
defaultnoexcept

Default move assignment.

◆ partition()

template<class CharT, class TraitsT, class AllocatorT>
std::vector< CppStringT > pcs::CppStringT< CharT, TraitsT, AllocatorT >::partition ( const CppStringT< CharT, TraitsT, AllocatorT > & sep) const
inlinenodiscardnoexcept

Splits the string at the first occurrence of sep, and returns a 3-items vector containing the part before the separator, the separator itself, and the part after the separator.

If the separator is not found, returns a 3-items vector containing the string itself, followed by two empty strings.

◆ removeprefix()

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::removeprefix ( const CppStringT< CharT, TraitsT, AllocatorT > & prefix) const
inlinenodiscardnoexcept

If the string starts with the prefix string, returns a new string with the prefix removed. Otherwise, returns a copy of the original string.

◆ removesuffix()

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::removesuffix ( const CppStringT< CharT, TraitsT, AllocatorT > & suffix) const
inlinenodiscardnoexcept

If the string ends with the suffix string, returns a new string with the suffix removed. Otherwise, returns a copy of the original string.

◆ replace()

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::replace ( const CppStringT< CharT, TraitsT, AllocatorT > & old,
const CppStringT< CharT, TraitsT, AllocatorT > & new_,
size_type count = -1 ) const
inlinenodiscardnoexcept

Returns a copy of the string with first count occurrences of substring 'old' replaced by 'new_'.

◆ rfind() [1/3]

template<class CharT, class TraitsT, class AllocatorT>
size_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::rfind ( const CppStringT< CharT, TraitsT, AllocatorT > & sub) const
inlinenodiscardconstexprnoexcept

Returns the highest index in the string where C-substring sub is found in the whole string, or -1 (i.e. 'npos') if sub is not found.

Note that this is an offset from the start of the string, not the end.

Note: this method should be used only if you need to know the position of sub. To check if sub is a substring or not, use the method contains().

CAUTION: empty substrings are considered to be in the string if start and end positions are both less than the string size and if start <= end. The returned position is the size of the string.

See also
find(), find_n() and rfind_n().
index(), index_n(), rindex() and rindex_n().

◆ rfind() [2/3]

template<class CharT, class TraitsT, class AllocatorT>
size_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::rfind ( const CppStringT< CharT, TraitsT, AllocatorT > & sub,
const size_type start ) const
inlinenodiscardconstexprnoexcept

Returns the highest index in the string where substring sub is found starting at start position in string, or -1 (i.e. 'npos') if sub is not found.

Note that this is an offset from the start of the string, not the end.

Note: this method should be used only if you need to know the position of sub. To check if sub is a substring or not, use the method contains().

CAUTION: empty substrings are considered to be in the string if start and end positions are both less than the string size and if start <= end. The returned position is the size of the string.

See also
find(), find_n() and rfind_n().
index(), index_n(), rindex() and rindex_n().

◆ rfind() [3/3]

template<class CharT, class TraitsT, class AllocatorT>
size_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::rfind ( const CppStringT< CharT, TraitsT, AllocatorT > & sub,
const size_type start,
const size_type end ) const
inlinenodiscardconstexprnoexcept

Returns the highest index in the string where substring sub is found within the slice str[start:end], or -1 (i.e. 'npos') if sub is not found.

Note that this is an offset from the start of the string, not the end.

Note: this method should be used only if you need to know the position of sub. To check if sub is a substring or not, use the method contains().

CAUTION: empty substrings are considered to be in the string if start and end positions are both less than the string size and if start <= end. The returned position is the size of the string.

See also
find(), find_n() and rfind_n().
index(), index_n(), rindex() and rindex_n().

Referenced by pcs::CppStringT< char >::rfind(), pcs::CppStringT< char >::rfind(), pcs::CppStringT< char >::rfind_n(), pcs::CppStringT< char >::rfind_n(), pcs::CppStringT< char >::rindex(), pcs::CppStringT< char >::rpartition(), and pcs::CppStringT< char >::rsplit().

◆ rfind_n() [1/2]

template<class CharT, class TraitsT, class AllocatorT>
size_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::rfind_n ( const CppStringT< CharT, TraitsT, AllocatorT > & sub,
const size_type count ) const
inlinenodiscardconstexprnoexcept

Returns the highest index in the string where substring sub is found within the slice str[0:count-1], or -1 (i.e. 'npos') if sub is not found.

Note: this method should be used only if you need to know the position of sub. To check if sub is a substring or not, use the method contains_n().

See also
find(), find_n() and rfind().
index(), index_n(), rindex() and rindex_n().

◆ rfind_n() [2/2]

template<class CharT, class TraitsT, class AllocatorT>
size_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::rfind_n ( const CppStringT< CharT, TraitsT, AllocatorT > & sub,
const size_type start,
const size_type count ) const
inlinenodiscardconstexprnoexcept

Returns the highest index in the string where substring sub is found within the slice str[start:start+count-1], or -1 (i.e. 'npos') if sub is not found.

Note: this method should be used only if you need to know the position of sub. To check if sub is a substring or not, use the method contains_n().

See also
find(), find_n() and rfind().
index(), index_n(), rindex() and rindex_n().

◆ rindex() [1/3]

template<class CharT, class TraitsT, class AllocatorT>
size_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::rindex ( const CppStringT< CharT, TraitsT, AllocatorT > & sub) const
inlinenodiscardconstexpr

Like rfind(sub), but raises NotFoundException when the substring is not found.

See also
index(), index_n() and rindex_n().
find(), find_n(), rfind() and rfind_n().

◆ rindex() [2/3]

template<class CharT, class TraitsT, class AllocatorT>
size_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::rindex ( const CppStringT< CharT, TraitsT, AllocatorT > & sub,
const size_type start ) const
inlinenodiscardconstexpr

Like rfind(sub, start), but raises NotFoundException when the substring is not found.

See also
index(), index_n() and rindex_n().
find(), find_n(), rfind() and rfind_n().

◆ rindex() [3/3]

template<class CharT, class TraitsT, class AllocatorT>
size_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::rindex ( const CppStringT< CharT, TraitsT, AllocatorT > & sub,
const size_type start,
const size_type end ) const
inlinenodiscardconstexpr

◆ rindex_n() [1/2]

template<class CharT, class TraitsT, class AllocatorT>
size_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::rindex_n ( const CppStringT< CharT, TraitsT, AllocatorT > & sub,
const size_type count ) const
inlinenodiscardconstexpr

Like rfind_n(sub, count), but raises NotFoundException when the substring is not found.

See also
index_n(), rindex() and rindex_n().
find(), find_n(), rfind() and rfind_n().

◆ rindex_n() [2/2]

template<class CharT, class TraitsT, class AllocatorT>
size_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::rindex_n ( const CppStringT< CharT, TraitsT, AllocatorT > & sub,
const size_type start,
const size_type count ) const
inlinenodiscardconstexpr

Like rfind_n(sub, start, count), but raises NotFoundException when the substring is not found.

See also
index_n(), rindex() and rindex_n().
find(), find_n(), rfind() and rfind_n().

◆ rjust()

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::rjust ( const size_type width,
const value_type fillch = value_type(' ') ) const
inlinenodiscardnoexcept

Returns the string right justified in a string of length width.

Padding is done using the specified fillchar (default is an ASCII space). The original string is returned if width is less than or equal to len(s).

◆ rpartition()

template<class CharT, class TraitsT, class AllocatorT>
std::vector< CppStringT > pcs::CppStringT< CharT, TraitsT, AllocatorT >::rpartition ( const CppStringT< CharT, TraitsT, AllocatorT > & sep) const
inlinenodiscardnoexcept

Splits the string at the last occurrence of sep, and returns a 3-items vector containing the part before the separator, the separator itself, and the part after the separator.

If the separator is not found, returns a 3-items vector containing the string itself, followed by two empty strings.

◆ rsplit() [1/4]

template<class CharT, class TraitsT, class AllocatorT>
std::vector< CppStringT > pcs::CppStringT< CharT, TraitsT, AllocatorT >::rsplit ( )
inlinenodiscardnoexcept

Returns a vector of the words in the whole string, as seperated with whitespace strings.

Notice: consecutive whitespaces are each regarded as a single separator. So, they each separate empty strings.

Referenced by pcs::CppStringT< char >::rsplit().

◆ rsplit() [2/4]

template<class CharT, class TraitsT, class AllocatorT>
std::vector< CppStringT > pcs::CppStringT< CharT, TraitsT, AllocatorT >::rsplit ( const CppStringT< CharT, TraitsT, AllocatorT > & sep)
inlinenodiscardnoexcept

Returns a vector of the words in the whole string, using sep as the delimiter string.

◆ rsplit() [3/4]

template<class CharT, class TraitsT, class AllocatorT>
std::vector< CppStringT > pcs::CppStringT< CharT, TraitsT, AllocatorT >::rsplit ( const CppStringT< CharT, TraitsT, AllocatorT > & sep,
const size_type maxsplit )
inlinenodiscardnoexcept

Returns a vector of the words in the string, using sep as the delimiter string. At most maxsplit splits are done, the rightmost ones.

◆ rsplit() [4/4]

template<class CharT, class TraitsT, class AllocatorT>
std::vector< CppStringT > pcs::CppStringT< CharT, TraitsT, AllocatorT >::rsplit ( const size_type maxsplit)
inlinenodiscardnoexcept

Returns a vector of the words in the string, as seperated with whitespace strings. At most maxsplit splits are done, the rightmost ones.

◆ rstrip() [1/2]

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::rstrip ( ) const
inlinenodiscardnoexcept

Returns a copy of the string with trailing whitespaces removed.

Referenced by pcs::CppStringT< char >::strip(), and pcs::CppStringT< char >::strip().

◆ rstrip() [2/2]

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::rstrip ( const CppStringT< CharT, TraitsT, AllocatorT > & removedchars) const
inlinenodiscardnoexcept

Returns a copy of the string with trailing characters removed.

The passed string specifies the set of characters to be removed. The chars argument is not a prefix; rather, all combinations of its values are stripped. To remove a suffix, rather call method 'removesuffix()'.

◆ split() [1/4]

template<class CharT, class TraitsT, class AllocatorT>
std::vector< CppStringT > pcs::CppStringT< CharT, TraitsT, AllocatorT >::split ( )
inlinenodiscardnoexcept

Returns a vector of the words in the whole string, as seperated with whitespace strings.

Notice: consecutive whitespaces are each regarded as a single separator. So, they each separate empty strings.

Referenced by pcs::CppStringT< char >::rsplit(), pcs::CppStringT< char >::rsplit(), pcs::CppStringT< char >::split(), and pcs::CppStringT< char >::title().

◆ split() [2/4]

template<class CharT, class TraitsT, class AllocatorT>
std::vector< CppStringT > pcs::CppStringT< CharT, TraitsT, AllocatorT >::split ( const CppStringT< CharT, TraitsT, AllocatorT > & sep)
inlinenodiscardnoexcept

Returns a vector of the words in the whole string, using sep as the delimiter string.

Notice: consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example, "1,,2".split(",") returns {"1", "", "2"}). The sep argument may consist of multiple characters (for example, "1<>2<>3".split("<>") returns {"1", "2", "3"]). Splitting an empty string with a specified separator returns {""}.

◆ split() [3/4]

template<class CharT, class TraitsT, class AllocatorT>
std::vector< CppStringT > pcs::CppStringT< CharT, TraitsT, AllocatorT >::split ( const CppStringT< CharT, TraitsT, AllocatorT > & sep,
const size_type maxsplit )
inlinenodiscardnoexcept

Returns a vector of the words in the string, using sep as the delimiter string. At most maxsplit splits are done, the leftmost ones.

◆ split() [4/4]

template<class CharT, class TraitsT, class AllocatorT>
std::vector< CppStringT > pcs::CppStringT< CharT, TraitsT, AllocatorT >::split ( const size_type maxsplit)
inlinenodiscardnoexcept

Returns a vector of the words in the string, as seperated with whitespace strings. At most maxsplit splits are done, the leftmost ones.

◆ splitlines()

template<class CharT, class TraitsT, class AllocatorT>
std::vector< CppStringT > pcs::CppStringT< CharT, TraitsT, AllocatorT >::splitlines ( const bool keep_end = false) const
inlinenodiscardnoexcept

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

This method splits on the following line boundaries. In particular, the boundaries are a superset of universal newlines: '
' Line Feed '\r' Carriage Return '\r
' Carriage Return + Line Feed '\v' or '\x0b' Line Tabulation '\f' or '\x0c' Form Feed '\x1c' File Separator '\x1d' Group Separator '\x1e' Record Separator Next separators values, detected by Python method splitlines(), are currently NOT detected by CppStrings '\x85' Next Line (C1 Control Code) '\u2028' Line Separator '\u2029' Paragraph Separator

◆ startswith() [1/4]

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::startswith ( const CppStringT< CharT, TraitsT, AllocatorT > & prefix) const
inlinenodiscardnoexcept

Returns true if the string starts with the specified prefix, otherwise returns false. Test runs on the whole string.

◆ startswith() [2/4]

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::startswith ( const CppStringT< CharT, TraitsT, AllocatorT > & prefix,
const size_type start ) const
inlinenodiscardnoexcept

Returns true if the string starts with the specified prefix, otherwise returns false. Test begins at start position and stops at end of string.

◆ startswith() [3/4]

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::startswith ( const CppStringT< CharT, TraitsT, AllocatorT > & prefix,
const size_type start,
const size_type end ) const
inlinenodiscardnoexcept

Returns true if the string starts with the specified prefix, otherwise returns false. Test begins at start position and stops at end position.

Referenced by pcs::CppStringT< char >::removeprefix(), pcs::CppStringT< char >::startswith(), and pcs::CppStringT< char >::startswith_n().

◆ startswith() [4/4]

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::startswith ( const std::initializer_list< CppStringT< CharT, TraitsT, AllocatorT > > & prefixes,
const size_type start,
const size_type end ) const
inlinenodiscardnoexcept

Returns true if the string starts with any of the specified prefixes, otherwise returns false. Test begins at start position and stops at end of string.

◆ startswith_n() [1/3]

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::startswith_n ( const CppStringT< CharT, TraitsT, AllocatorT > & prefix,
const size_type count ) const
inlinenodiscardnoexcept

Returns true if the string starts with the specified suffix, otherwise returns false. Test begins at position 0 and stops after count positions.

◆ startswith_n() [2/3]

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::startswith_n ( const CppStringT< CharT, TraitsT, AllocatorT > & prefix,
const size_type start,
const size_type count ) const
inlinenodiscardnoexcept

Returns true if the string starts with the specified suffix, otherwise returns false. Test begins at start position and stops after count positions.

◆ startswith_n() [3/3]

template<class CharT, class TraitsT, class AllocatorT>
const bool pcs::CppStringT< CharT, TraitsT, AllocatorT >::startswith_n ( const std::initializer_list< CppStringT< CharT, TraitsT, AllocatorT > > & prefix,
const size_type start,
const size_type count ) const
inlinenodiscardnoexcept

Returns true if the string starts with any of the specified suffixes, otherwise returns false. Test begins at start position and stops after count positions.

◆ strip() [1/2]

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::strip ( ) const
inlinenodiscardnoexcept

Returns a copy of the string with the leading and trailing whitespaces removed.

◆ strip() [2/2]

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::strip ( const CppStringT< CharT, TraitsT, AllocatorT > & removedchars) const
inlinenodiscardnoexcept

Returns a copy of the string with the leading and trailing characters removed.

The passed string specifies the set of characters to be removed. The chars argument is not a prefix; rather, all combinations of its values are stripped.

◆ substr()

◆ swapcase()

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::swapcase ( ) const
inlinenodiscardnoexcept

Returns a copy of the string with uppercase characters converted to lowercase and vice versa.

Note that it is not necessarily true that s.swapcase().swapcase() == s.

◆ title()

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::title ( ) const
inlinenodiscardnoexcept

Returns a titlecased copy of the string where words start with an uppercase character and the remaining characters are lowercase.

Referenced by pcs::CppStringT< char >::istitle().

◆ translate()

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::translate ( TransTable & table)
inlinenodiscardnoexcept

Returns a copy of the string in which each character has been mapped through the given translation table.

The table must be of type CppStringT::TransTable. When a character to be translated is not available as an entry in the tranlation table, it is set as is in the resulting string.

◆ upper() [1/2]

template<class CharT, class TraitsT, class AllocatorT>
CppStringT & pcs::CppStringT< CharT, TraitsT, AllocatorT >::upper ( )
inlinenoexcept

In-place replaces all characters of the string with their uppercase conversion. Returns a reference to string.

Notice: uses the currently set std::locale, which is the "C" one by default or any other one as previously set by the user.

Referenced by pcs::CppStringT< char >::upper().

◆ upper() [2/2]

template<class CharT, class TraitsT, class AllocatorT>
const value_type pcs::CppStringT< CharT, TraitsT, AllocatorT >::upper ( const value_type ch)
inlinestaticnodiscardnoexcept

Returns uppercase conversion of the character.

Notice: uses the currently set std::locale, which is the "C" one by default or any other one as previously set by the user.

◆ zfill()

template<class CharT, class TraitsT, class AllocatorT>
CppStringT pcs::CppStringT< CharT, TraitsT, AllocatorT >::zfill ( const size_type width) const
inlinenodiscardnoexcept

Returns a copy of the string left filled with ASCII '0' digits to make a string of length width.

A leading sign prefix ('+'/'-') is handled by inserting the padding after the sign character rather than before. The original string is returned if width is less than or equal to len(s).


The documentation for this class was generated from the following file:
  • cppstrings.h