Library of Assembled Shared Sources
Extended_string

Detailed Description

extra std::string functionality

Author
Bram de Greve [BdG]

ExtendedString is not an extended std::string implementation as the name might suggest, but a set of functions that provide extra functionality on very standard std::string strings. Most of them are inspired by the string module of Python, as you will notice. Others are std::string implementations of C functions operating on char arrays

Functions

template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::tolower (const std::basic_string< Char, Traits, Alloc > &input, const std::locale &locale)
 convert std::basic_string to lower case by using user locale
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::toupper (const std::basic_string< Char, Traits, Alloc > &input, const std::locale &locale)
 convert std::basic_string to upper case by using user locale
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::replace_all (const std::basic_string< Char, Traits, Alloc > &input, const std::basic_string< Char, Traits, Alloc > &to_be_replaced, const std::basic_string< Char, Traits, Alloc > &replacement)
 replace all instances of to_be_replaced in input by replacement.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::replace_all (const std::basic_string< Char, Traits, Alloc > &input, const Char *to_be_replaced, const Char *replacement)
 replace all instances of to_be_replaced in input by replacement.
 
template<typename Char, typename Traits, typename Alloc>
bool lass::num::lass::stde::begins_with (const std::basic_string< Char, Traits, Alloc > &input, const std::basic_string< Char, Traits, Alloc > &prefix)
 returns true if input begins with the input prefix
 
template<typename Char, typename Traits, typename Alloc>
bool lass::num::lass::stde::begins_with (const std::basic_string< Char, Traits, Alloc > &input, const Char *prefix)
 returns true if input begins with the input prefix
 
template<typename Char, typename Traits, typename Alloc>
bool lass::num::lass::stde::begins_with (const std::basic_string< Char, Traits, Alloc > &input, Char prefix)
 returns true if input begins with the input prefix
 
template<typename Char, typename Traits, typename Alloc>
bool lass::num::lass::stde::ends_with (const std::basic_string< Char, Traits, Alloc > &input, const std::basic_string< Char, Traits, Alloc > &suffix)
 returns true if input ends with the input suffix
 
template<typename Char, typename Traits, typename Alloc>
bool lass::num::lass::stde::ends_with (const std::basic_string< Char, Traits, Alloc > &input, const Char *suffix)
 returns true if input ends with the input suffix
 
template<typename Char, typename Traits, typename Alloc>
bool lass::num::lass::stde::ends_with (const std::basic_string< Char, Traits, Alloc > &input, Char suffix)
 returns true if input ends with the input suffix
 
template<typename Char, typename Traits, typename Alloc>
std::vector< std::basic_string< Char, Traits, Alloc > > lass::num::lass::stde::split (const std::basic_string< Char, Traits, Alloc > &to_be_split)
 Reflects the Python function split without seperator argument.
 
template<typename Char, typename Traits, typename Alloc>
std::vector< std::basic_string< Char, Traits, Alloc > > lass::num::lass::stde::split (const std::basic_string< Char, Traits, Alloc > &to_be_split, const std::basic_string< Char, Traits, Alloc > &seperator, size_t max_split)
 Reflects the Python function split without seperator argument.
 
template<typename Char, typename Traits, typename Alloc>
std::vector< std::basic_string< Char, Traits, Alloc > > lass::num::lass::stde::split (const std::basic_string< Char, Traits, Alloc > &to_be_split, const Char *seperator, size_t max_split)
 Reflects the Python function split without seperator argument.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::lstrip (const std::basic_string< Char, Traits, Alloc > &to_be_stripped, const std::basic_string< Char, Traits, Alloc > &to_be_removed)
 Return a copy of the string to_be_stripped with leading characters removed.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::lstrip (const std::basic_string< Char, Traits, Alloc > &to_be_stripped)
 Return a copy of the string to_be_stripped with leading whitespace removed.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::rstrip (const std::basic_string< Char, Traits, Alloc > &to_be_stripped, const std::basic_string< Char, Traits, Alloc > &to_be_removed)
 Return a copy of the string to_be_stripped with trailing characters removed.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::rstrip (const std::basic_string< Char, Traits, Alloc > &to_be_stripped)
 Return a copy of the string to_be_stripped with trailing whitespace removed.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::strip (const std::basic_string< Char, Traits, Alloc > &to_be_stripped, const std::basic_string< Char, Traits, Alloc > &to_be_removed)
 Return a copy of the string to_be_stripped with both leading and trailing characters removed.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::strip (const std::basic_string< Char, Traits, Alloc > &to_be_stripped)
 Return a copy of the string to_be_stripped with leading and trailing whitespace removed.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::stde::tolower (const std::basic_string< Char, Traits, Alloc > &input, const std::locale &locale)
 convert std::basic_string to lower case by using user locale
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::stde::toupper (const std::basic_string< Char, Traits, Alloc > &input, const std::locale &locale)
 convert std::basic_string to upper case by using user locale
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::stde::replace_all (const std::basic_string< Char, Traits, Alloc > &input, const std::basic_string< Char, Traits, Alloc > &to_be_replaced, const std::basic_string< Char, Traits, Alloc > &replacement)
 replace all instances of to_be_replaced in input by replacement.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::stde::replace_all (const std::basic_string< Char, Traits, Alloc > &input, const Char *to_be_replaced, const Char *replacement)
 replace all instances of to_be_replaced in input by replacement.
 
template<typename Char, typename Traits, typename Alloc>
bool lass::stde::begins_with (const std::basic_string< Char, Traits, Alloc > &input, const std::basic_string< Char, Traits, Alloc > &prefix)
 returns true if input begins with the input prefix
 
template<typename Char, typename Traits, typename Alloc>
bool lass::stde::begins_with (const std::basic_string< Char, Traits, Alloc > &input, const Char *prefix)
 returns true if input begins with the input prefix
 
template<typename Char, typename Traits, typename Alloc>
bool lass::stde::begins_with (const std::basic_string< Char, Traits, Alloc > &input, Char prefix)
 returns true if input begins with the input prefix
 
template<typename Char, typename Traits, typename Alloc>
bool lass::stde::ends_with (const std::basic_string< Char, Traits, Alloc > &input, const std::basic_string< Char, Traits, Alloc > &suffix)
 returns true if input ends with the input suffix
 
template<typename Char, typename Traits, typename Alloc>
bool lass::stde::ends_with (const std::basic_string< Char, Traits, Alloc > &input, const Char *suffix)
 returns true if input ends with the input suffix
 
template<typename Char, typename Traits, typename Alloc>
bool lass::stde::ends_with (const std::basic_string< Char, Traits, Alloc > &input, Char suffix)
 returns true if input ends with the input suffix
 
template<typename Char, typename Traits, typename Alloc>
std::vector< std::basic_string< Char, Traits, Alloc > > lass::stde::split (const std::basic_string< Char, Traits, Alloc > &to_be_split)
 Reflects the Python function split without seperator argument.
 
template<typename Char, typename Traits, typename Alloc>
std::vector< std::basic_string< Char, Traits, Alloc > > lass::stde::split (const std::basic_string< Char, Traits, Alloc > &to_be_split, const std::basic_string< Char, Traits, Alloc > &seperator, size_t max_split)
 Reflects the Python function split without seperator argument.
 
template<typename Char, typename Traits, typename Alloc>
std::vector< std::basic_string< Char, Traits, Alloc > > lass::stde::split (const std::basic_string< Char, Traits, Alloc > &to_be_split, const Char *seperator, size_t max_split)
 Reflects the Python function split without seperator argument.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::stde::lstrip (const std::basic_string< Char, Traits, Alloc > &to_be_stripped, const std::basic_string< Char, Traits, Alloc > &to_be_removed)
 Return a copy of the string to_be_stripped with leading characters removed.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::stde::lstrip (const std::basic_string< Char, Traits, Alloc > &to_be_stripped)
 Return a copy of the string to_be_stripped with leading whitespace removed.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::stde::rstrip (const std::basic_string< Char, Traits, Alloc > &to_be_stripped, const std::basic_string< Char, Traits, Alloc > &to_be_removed)
 Return a copy of the string to_be_stripped with trailing characters removed.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::stde::rstrip (const std::basic_string< Char, Traits, Alloc > &to_be_stripped)
 Return a copy of the string to_be_stripped with trailing whitespace removed.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::stde::strip (const std::basic_string< Char, Traits, Alloc > &to_be_stripped, const std::basic_string< Char, Traits, Alloc > &to_be_removed)
 Return a copy of the string to_be_stripped with both leading and trailing characters removed.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::stde::strip (const std::basic_string< Char, Traits, Alloc > &to_be_stripped)
 Return a copy of the string to_be_stripped with leading and trailing whitespace removed.
 

Function Documentation

◆ split() [1/4]

template<typename Char, typename Traits, typename Alloc>
std::vector< std::basic_string< Char, Traits, Alloc > > lass::num::lass::stde::split ( const std::basic_string< Char, Traits, Alloc > & to_be_split)

Reflects the Python function split without seperator argument.

Return a vector of the words of the string to_be_split. The words are separated by arbitrary strings of whitespace characters (space, tab, newline, return, formfeed).

If to_be_split is empty, then the result will have an empty vector.

Definition at line 211 of file basic_ops.h.

◆ split() [2/4]

template<typename Char, typename Traits, typename Alloc>
std::vector< std::basic_string< Char, Traits, Alloc > > lass::num::lass::stde::split ( const std::basic_string< Char, Traits, Alloc > & to_be_split,
const std::basic_string< Char, Traits, Alloc > & seperator,
size_t max_split )

Reflects the Python function split without seperator argument.

Return a vector of the words of the string to_be_split. The second argument seperator specifies a string to be used as the word separator. The returned vector will then have one more item than the number of non-overlapping occurrences of the separator in the string.

The optional third argument max_split defaults to 0. If it is nonzero, at most max_split number of splits occur, and the remainder of the string is returned as the final element of the list (thus, the list will have at most max_split + 1 elements).

If to_be_split is empty, then the result will have an empty string as only element.

Definition at line 259 of file basic_ops.h.

◆ lstrip() [1/2]

template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::lstrip ( const std::basic_string< Char, Traits, Alloc > & to_be_stripped,
const std::basic_string< Char, Traits, Alloc > & to_be_removed )

Return a copy of the string to_be_stripped with leading characters removed.

The characters in the string to_be_removed will be stripped from the beginning of the string to_be_stripped.

Definition at line 343 of file basic_ops.h.

◆ rstrip() [1/2]

template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::rstrip ( const std::basic_string< Char, Traits, Alloc > & to_be_stripped,
const std::basic_string< Char, Traits, Alloc > & to_be_removed )

Return a copy of the string to_be_stripped with trailing characters removed.

The characters in the string to_be_removed will be stripped from the ending of the string to_be_stripped.

Definition at line 373 of file basic_ops.h.

◆ strip() [1/2]

template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::strip ( const std::basic_string< Char, Traits, Alloc > & to_be_stripped,
const std::basic_string< Char, Traits, Alloc > & to_be_removed )

Return a copy of the string to_be_stripped with both leading and trailing characters removed.

The characters in the string to_be_removed will be stripped from both the beginning and the ending of the string to_be_stripped.

Definition at line 403 of file basic_ops.h.

◆ split() [3/4]

template<typename Char, typename Traits, typename Alloc>
std::vector< std::basic_string< Char, Traits, Alloc > > lass::stde::split ( const std::basic_string< Char, Traits, Alloc > & to_be_split)

Reflects the Python function split without seperator argument.

Return a vector of the words of the string to_be_split. The words are separated by arbitrary strings of whitespace characters (space, tab, newline, return, formfeed).

If to_be_split is empty, then the result will have an empty vector.

Definition at line 210 of file extended_string.inl.

Referenced by split().

◆ split() [4/4]

template<typename Char, typename Traits, typename Alloc>
std::vector< std::basic_string< Char, Traits, Alloc > > lass::stde::split ( const std::basic_string< Char, Traits, Alloc > & to_be_split,
const std::basic_string< Char, Traits, Alloc > & seperator,
size_t max_split )

Reflects the Python function split without seperator argument.

Return a vector of the words of the string to_be_split. The second argument seperator specifies a string to be used as the word separator. The returned vector will then have one more item than the number of non-overlapping occurrences of the separator in the string.

The optional third argument max_split defaults to 0. If it is nonzero, at most max_split number of splits occur, and the remainder of the string is returned as the final element of the list (thus, the list will have at most max_split + 1 elements).

If to_be_split is empty, then the result will have an empty string as only element.

Definition at line 258 of file extended_string.inl.

References lass::stde::slist< T, Alloc >::size().

◆ lstrip() [2/2]

template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::stde::lstrip ( const std::basic_string< Char, Traits, Alloc > & to_be_stripped,
const std::basic_string< Char, Traits, Alloc > & to_be_removed )

Return a copy of the string to_be_stripped with leading characters removed.

The characters in the string to_be_removed will be stripped from the beginning of the string to_be_stripped.

Definition at line 342 of file extended_string.inl.

Referenced by lstrip().

◆ rstrip() [2/2]

template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::stde::rstrip ( const std::basic_string< Char, Traits, Alloc > & to_be_stripped,
const std::basic_string< Char, Traits, Alloc > & to_be_removed )

Return a copy of the string to_be_stripped with trailing characters removed.

The characters in the string to_be_removed will be stripped from the ending of the string to_be_stripped.

Definition at line 372 of file extended_string.inl.

Referenced by rstrip().

◆ strip() [2/2]

template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::stde::strip ( const std::basic_string< Char, Traits, Alloc > & to_be_stripped,
const std::basic_string< Char, Traits, Alloc > & to_be_removed )

Return a copy of the string to_be_stripped with both leading and trailing characters removed.

The characters in the string to_be_removed will be stripped from both the beginning and the ending of the string to_be_stripped.

Definition at line 402 of file extended_string.inl.

Referenced by strip().