SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Static Public Member Functions | List of all members
smtk::common::StringUtil Class Reference

Static Public Member Functions

static std::string & trim (std::string &s)
 Trim whitespace from both ends of a string (in place).
 
static std::string & trimLeft (std::string &s)
 Trim whitespace from start of string (in place).
 
static std::string & trimRight (std::string &s)
 Trim whitespace from end of string (in place).
 
static std::string & lower (std::string &s)
 Transform string to all-lowercase letters (in place).
 
static std::string & upper (std::string &s)
 Transform string to all-uppercase letters (in place).
 
static std::vector< std::string > split (const std::string &s, const std::string &sep, bool omitEmpty, bool trim)
 Split string into a vector of strings at each occurrence of sep (including or omitting empty strings at double-separators)
 
static std::size_t replaceAll (std::string &source, const std::string &search, const std::string &replacement)
 Perform in-place replacement of search with replacement. More...
 
static bool toBoolean (const std::string &s, bool &value)
 Converts a string to a boolean. More...
 
static bool mixedAlphanumericComparator (const std::string &aa, const std::string &bb)
 A comparator for strings that sorts mixed numeric substrings properly. More...
 

Member Function Documentation

◆ mixedAlphanumericComparator()

bool smtk::common::StringUtil::mixedAlphanumericComparator ( const std::string &  aa,
const std::string &  bb 
)
static

A comparator for strings that sorts mixed numeric substrings properly.

Compare two strings character by character until the first mismatch or one runs out of characters. Upon a mismatch, if both characters have digits, convert to floating-point numbers and choose the return value on whether aa's number is less than bb (true). Otherwise, the return value is true if aa's next character evaluates to less than bb's next character.

See also
DescriptivePhrase::compareByTitle

◆ replaceAll()

std::size_t smtk::common::StringUtil::replaceAll ( std::string &  source,
const std::string &  search,
const std::string &  replacement 
)
static

Perform in-place replacement of search with replacement.

The returned integer is the number of occurrences of search in source that were replaced with replacement.

◆ toBoolean()

bool smtk::common::StringUtil::toBoolean ( const std::string &  s,
bool &  value 
)
static

Converts a string to a boolean.

If the string s can be converted to a boolean then the function returns true and value is set to the converted value. The function will trim s and convert it to lower case. The current acceptable values are: 1, t, true, yes, 0, f, false, no.


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