AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::utilities::string Namespace Reference

Functions

bool endsWith (const std::string &str, const std::string &suffix)
 Tests whether a string ends with another string https://stackoverflow.com/questions/20446201/how-to-check-if-string-ends-with-txt/20446257. More...
 
bool endsWith (const std::string &str, const char suffix)
 Tests whether a string ends with a char. More...
 
bool startsWith (const std::string &str, const std::string &prefix)
 Tests whether a string starts with another string. More...
 
bool startsWith (const std::string &str, const char prefix)
 Tests whether a string starts with a char. More...
 
void split (std::vector< std::string > &tokens, const std::string &str, const char delimiter)
 Splits the given string based on the given delimiter. More...
 
void toLower (std::string &str)
 Converts a string to lowercase. More...
 
void toUpper (std::string &str)
 Converts a string to uppercase. More...
 
std::vector< std::string > splitLastNTokens (const std::string &input, const std::size_t n, const char delim)
 Retrieves the last "n" tokens of a string split with the specified delimiter. More...
 

Function Documentation

◆ endsWith() [1/2]

bool axom::utilities::string::endsWith ( const std::string &  str,
const std::string &  suffix 
)
inline

Tests whether a string ends with another string https://stackoverflow.com/questions/20446201/how-to-check-if-string-ends-with-txt/20446257.

Parameters
[in]strstring to be searched
[in]suffixstring to be checked for
Returns
boolean value whether suffix was found at the end of str

Referenced by axom::inlet::isCollectionGroup().

◆ endsWith() [2/2]

bool axom::utilities::string::endsWith ( const std::string &  str,
const char  suffix 
)
inline

Tests whether a string ends with a char.

Parameters
[in]strstring to be searched
[in]suffixchar to be checked for
Returns
boolean value whether suffix was found at the end of str

◆ startsWith() [1/2]

bool axom::utilities::string::startsWith ( const std::string &  str,
const std::string &  prefix 
)
inline

Tests whether a string starts with another string.

Parameters
[in]strstring to be searched
[in]prefixstring to be checked for
Returns
boolean value whether prefix was found at start of str

◆ startsWith() [2/2]

bool axom::utilities::string::startsWith ( const std::string &  str,
const char  prefix 
)
inline

Tests whether a string starts with a char.

Parameters
[in]strstring to be searched
[in]prefixchar to be checked for
Returns
boolean value whether prefix was found at start of str

References split(), splitLastNTokens(), toLower(), and toUpper().

◆ split()

void axom::utilities::string::split ( std::vector< std::string > &  tokens,
const std::string &  str,
const char  delimiter 
)

Splits the given string based on the given delimiter.

Parameters
[out]tokensvector that the found tokens are appended to
[in]strstring to be tokenized
[in]delimiterchar to split string on

Referenced by startsWith().

◆ toLower()

void axom::utilities::string::toLower ( std::string &  str)

Converts a string to lowercase.

Parameters
[in,out]strstring to be converted

Referenced by startsWith().

◆ toUpper()

void axom::utilities::string::toUpper ( std::string &  str)

Converts a string to uppercase.

Parameters
[in,out]strstring to be converted

Referenced by startsWith().

◆ splitLastNTokens()

std::vector<std::string> axom::utilities::string::splitLastNTokens ( const std::string &  input,
const std::size_t  n,
const char  delim 
)

Retrieves the last "n" tokens of a string split with the specified delimiter.

Parameters
[in]inputThe string to split
[in]nThe number of tokens to retrieve
[in]delimThe delimiter to split with
Returns
A list of tokens (of size n )

Splits a string starting from the end of the string into a maximum of n tokens

Referenced by startsWith().