xmscore  1.0
StringUtil.h File Reference
#include <iomanip>
#include <set>
#include <string>
#include <type_traits>
#include <vector>
#include <xmscore/stl/vector.h>

Go to the source code of this file.

Classes

class  xms::StTemp2DigitExponents
 When constructed std::cout will temporarily output 2-digit exponents for floating point numbers. Destructor will revert back. Should be able to remove this upon changing to Visual Studio 2015. More...
 
class  xms::StCommaNumpunct
 Used to format numbers with comma separators. More...
 

Enumerations

enum  xms::PrecFlags {
  xms::STR_FLOAT = 0x01, xms::STR_SCIENTIFIC = 0x02, xms::STR_USEMAXPREC = 0x04, xms::STR_FULLWIDTH = 0x08,
  xms::STR_WITHCOMMAS = 0x10
}
 Bitwise flags used by stPrecision(), and STR() More...
 

Functions

bool xms::stEqualNoCase (const std::string &a, const std::string &b)
 Returns true if a and b are equal while ignoring capitalization. More...
 
bool xms::stFindNoCase (const std::string &a, const std::string &b)
 Returns true if a contains b while ignoring capitalization. More...
 
VecStr xms::stSplit (const std::string &a_source, const std::string &a_delimiterList, bool a_delimiterCompressOn)
 Breaks string into vector of strings based on one or more delimiters. More...
 
VecStr xms::stExplode (const std::string &source, const std::string &a_delimiter)
 Breaks the string into a vector of strings based on the delimiter. More...
 
std::string xms::stImplode (const std::vector< std::string > &source, const std::string &delim)
 Joins the vector, inserting delim between each item. More...
 
int xms::stIndexOfElem (const VecStr &a_container, const std::string &str)
 Iterates through a vec of strings and looks for the string. Case sensitive. More...
 
std::string & xms::stLeft (std::string &a_source, size_t const a_length)
 Modifies a_source to contain the first (leftmost) a_length characters. More...
 
std::string xms::stLeftCopy (const std::string &a_source, size_t const a_length)
 Extracts first (leftmost) a_length characters from a_source returning a copy. More...
 
std::string & xms::stRemove (std::string &str, char source)
 Removes all instances of char source from str and returns a reference to str. More...
 
std::string xms::stRemoveCopy (const std::string &str, char source)
 Returns a copy of str with all instances of char source removed. More...
 
std::string & xms::stReplace (std::string &str, char source, char dest)
 Returns a reference to str, and replaces every instance of source replaced with dest. More...
 
std::string & xms::stReplace (std::string &str, const std::string &source, const std::string &dest)
 Returns a reference to str, and replaces every instance of source replaced with dest. More...
 
std::string xms::stReplaceCopy (const std::string &str, char source, char dest)
 Returns a copy of str with every instance of source replaced with dest. More...
 
std::string xms::stReplaceCopy (const std::string &str, const std::string &source, const std::string &dest)
 Returns a copy of str with every instance of source replaced with dest. More...
 
std::string & xms::stRight (std::string &a_source, size_t const a_length)
 Modifies a_source to contain the last (rightmost) a_length characters. More...
 
std::string xms::stRightCopy (const std::string &a_source, size_t const a_length)
 Extracts last (rightmost) a_length characters from a_source returning a copy. More...
 
std::string xms::stSimplified (const std::string &str)
 Removes all white space from the passed string. More...
 
bool xms::stContains (const std::string &a_container, const std::string &a_substr)
 Checks if first string contains second. Case insensitive. More...
 
bool xms::stVectorContainsString (const VecStr &a_container, const std::string &str)
 Checks if a vec of strings contains a string. Case sensitive. More...
 
std::string & xms::stToLower (std::string &str)
 Modifies str to be all lowercase. More...
 
std::string xms::stToLowerCopy (const std::string &str)
 Returns a new string that is str with all characters lowercase. More...
 
std::string & xms::stToUpper (std::string &str)
 Modifies str to be all uppercase. More...
 
std::string xms::stToUpperCopy (const std::string &str)
 Returns a new string that is str with all characters uppercase. More...
 
std::string & xms::stTrim (std::string &str, const std::string &delim)
 Trim the leading and trailing delim characters from a string. More...
 
std::string xms::stTrimCopy (const std::string &str, const std::string &delim)
 Trims the white space from a string. This involves creating a copy of the string (twice I believe), so don't call this unless you really don't want the original string modified. More...
 
std::string & xms::stTrimLeft (std::string &str, const std::string &delim)
 Trims the leading delim characters from a string. More...
 
std::string & xms::stTrimRight (std::string &str, const std::string &delim)
 Trims the trailing delim characters from a string. More...
 
unsigned int xms::stCountChar (const std::string &str, char c)
 Counts the number of a given character in a string. More...
 
bool xms::stNumeric (const std::string &str)
 Determines whether the given string is a valid number. More...
 
bool xms::stScientificNotation (const std::string &str, bool check_numeric)
 Determines whether the given string is a number in scientific notation. More...
 
void xms::stChangeExtendedAscii (std::string &str, bool to_extended)
 Replaces the Windows Latin-1 extended ASCII characters with standard ASCII and vice-versa. More...
 
bool xms::stMakeUnique (const std::set< std::string > &set_str, std::string &str)
 Changes str to "str (2)" etc. if it is in set of set_str. More...
 
bool xms::stStringToInt (const std::string &s, int &i, int base)
 Convert a string to an int. More...
 
bool xms::stStringToDouble (const std::string &s, double &d)
 Convert a string to an double. More...
 
int xms::stPrecision (double value, int &flags, int length)
 Returns precision, or the number of digits to the right of the decimal needed to display the [value]. This is used in conjunction with FloatToString() or STR() to get the string. The precision is calculated such that the total string length (including the minus sign, decimal, E etc.) will never end up longer than length (by default, 15 characters) so all edit fields can be about 60 dialog units wide on PC. More...
 
std::string xms::STRstd (double a_value, int a_n, int width, int flags)
 Get a properly formatted string from a double. More...
 
std::string xms::STRstd (float value, int n, int width, int flags)
 Get a properly formatted string from a float. More...
 
template<typename T >
std::string xms::STRstd (T a_value, int a_n=0, int width=0, int flags=0)
 
std::string xms::STRstd (std::string value)
 This version is needed because the template parameter could be a string. More...
 

Variables

static const char * xms::ST_WHITESPACE = " \t\n\f\r\v"
 Whitespace characters.
 

Detailed Description

Definition in file StringUtil.h.

Enumeration Type Documentation

◆ PrecFlags

Bitwise flags used by stPrecision(), and STR()

Enumerator
STR_FLOAT 

Float, not double.

STR_SCIENTIFIC 

Use scientific notation.

STR_USEMAXPREC 

Use maximum precision.

STR_FULLWIDTH 

Use full width.

STR_WITHCOMMAS 

Use commas in string.

Definition at line 31 of file StringUtil.h.

Function Documentation

◆ stChangeExtendedAscii()

void xms::stChangeExtendedAscii ( std::string &  str,
bool  to_extended 
)

Replaces the Windows Latin-1 extended ASCII characters with standard ASCII and vice-versa.

Parameters
[in,out]strThe string to modify.
[in]to_extendedtrue to add extended ASCII, false to remove it

Definition at line 117 of file StringUtil.cpp.

References xms::stChangeExtendedAscii(), and xms::stReplace().

Referenced by xms::stChangeExtendedAscii().

◆ stContains()

bool xms::stContains ( const std::string &  a_container,
const std::string &  a_substr 
)

Checks if first string contains second. Case insensitive.

Parameters
[in]a_containerContainer to search if it includes a substr.
[in]a_substrSubstring to search for in the container.
Returns
True if a_container contains an occurrence of a_substr, otherwise False.

Definition at line 509 of file StringUtil.cpp.

References xms::stContains().

Referenced by xms::stContains().

◆ stCountChar()

unsigned int xms::stCountChar ( const std::string &  str,
char  c 
)

Counts the number of a given character in a string.

Parameters
[in]strThe string.
[in]cThe char.
Returns
The count.

Definition at line 70 of file StringUtil.cpp.

References xms::stCountChar().

Referenced by xms::stCountChar().

◆ stEqualNoCase()

bool xms::stEqualNoCase ( const std::string &  a,
const std::string &  b 
)

Returns true if a and b are equal while ignoring capitalization.

Parameters
[in]aFirst string.
[in]bSecond string.
Returns
true or false.

Definition at line 554 of file StringUtil.cpp.

References xms::stEqualNoCase().

Referenced by xms::stEqualNoCase().

◆ stExplode()

VecStr xms::stExplode ( const std::string &  source,
const std::string &  a_delimiter 
)

Breaks the string into a vector of strings based on the delimiter.

Parameters
[in]sourceThe string.
[in]a_delimiterThe delimiter. The whole string is THE delimiter.
Returns
Vector of strings.

a_delimiter is not a list of delimiters, it is THE delimiter. Use stSplit method if you need to specify multiple different delimiter characters or need to handle multiple adjacent delimiters (ie. "1 2 3")

Definition at line 144 of file StringUtil.cpp.

References xms::stExplode().

Referenced by xms::stExplode().

◆ stFindNoCase()

bool xms::stFindNoCase ( const std::string &  a,
const std::string &  b 
)

Returns true if a contains b while ignoring capitalization.

Parameters
[in]aString to search.
[in]bSubstring searching for.
Returns
true or false.

Definition at line 563 of file StringUtil.cpp.

References xms::stFindNoCase(), and xms::stToLowerCopy().

Referenced by xms::stFindNoCase().

◆ stImplode()

std::string xms::stImplode ( const std::vector< std::string > &  source,
const std::string &  delim 
)

Joins the vector, inserting delim between each item.

Parameters
[in]sourceA vector of strings.
[in]delimThe delimiter to be inserted between each string.
Returns
A string.

Definition at line 216 of file StringUtil.cpp.

References xms::stImplode().

Referenced by xms::stImplode().

◆ stIndexOfElem()

int xms::stIndexOfElem ( const VecStr a_container,
const std::string &  str 
)

Iterates through a vec of strings and looks for the string. Case sensitive.

Parameters
[in]a_containerVec of strings to iterate through.
[in]strElement we're searching for.
Returns
Index of the position of the element. If not found it returns -1.

Definition at line 239 of file StringUtil.cpp.

References xms::stIndexOfElem().

Referenced by xms::stIndexOfElem().

◆ stLeft()

std::string & xms::stLeft ( std::string &  a_source,
size_t const  a_length 
)

Modifies a_source to contain the first (leftmost) a_length characters.

Parameters
[in,out]a_sourceThe string that is modified.
[in]a_lengthNumber of leftmost characters to keep.
Returns
A reference to a_source.

Definition at line 466 of file StringUtil.cpp.

References xms::stLeft(), and XM_ASSERT.

Referenced by xms::stLeft(), and xms::stLeftCopy().

◆ stLeftCopy()

std::string xms::stLeftCopy ( const std::string &  a_source,
size_t const  a_length 
)

Extracts first (leftmost) a_length characters from a_source returning a copy.

Parameters
[in]a_sourceThe string.
[in]a_lengthNumber of leftmost characters to keep.
Returns
The new string.

Definition at line 452 of file StringUtil.cpp.

References xms::stLeft(), xms::stLeftCopy(), and XM_ASSERT.

Referenced by xms::stLeftCopy().

◆ stMakeUnique()

bool xms::stMakeUnique ( const std::set< std::string > &  set_str,
std::string &  str 
)

Changes str to "str (2)" etc. if it is in set of set_str.

Parameters
[in]set_strA set of strings.
[in,out]strA string that's made unique if it is in set_str.
Returns
false if already unique, true if updated.

Definition at line 572 of file StringUtil.cpp.

References xms::stMakeUnique().

Referenced by xms::stMakeUnique().

◆ stNumeric()

bool xms::stNumeric ( const std::string &  str)

Determines whether the given string is a valid number.

Parameters
[in]strThe string.
Returns
true or false.

Definition at line 87 of file StringUtil.cpp.

References xms::stNumeric(), and xms::stTrimCopy().

Referenced by xms::stNumeric(), and xms::stScientificNotation().

◆ stPrecision()

int xms::stPrecision ( double  value,
int &  flags,
int  length 
)

Returns precision, or the number of digits to the right of the decimal needed to display the [value]. This is used in conjunction with FloatToString() or STR() to get the string. The precision is calculated such that the total string length (including the minus sign, decimal, E etc.) will never end up longer than length (by default, 15 characters) so all edit fields can be about 60 dialog units wide on PC.

Parameters
[in]valueThe value.
[out]flagsCan be either 0, or STR_FLOAT, STR_SCIENTIFIC, or STR_FLOAT | STR_SCIENTIFIC. So, if your number is a float, or you want it in scientific notation, you can specify that with the flags.
[in]lengthNumber characters available to display the number
Returns
The precision.

Definition at line 673 of file StringUtil.cpp.

References xms::EQ_EPS(), xms::GT_EPS(), xms::LT_EPS(), xms::Miabs(), xms::Round(), xms::stPrecision(), xms::STR_FLOAT, xms::STR_SCIENTIFIC, and xms::stRemove().

Referenced by xms::StCommaNumpunct::do_grouping(), xms::stPrecision(), and xms::STRstd().

◆ stRemove()

std::string & xms::stRemove ( std::string &  str,
char  source 
)

Removes all instances of char source from str and returns a reference to str.

Parameters
[in,out]strThe string to be modified.
[in]sourceThe character to be removed.
Returns
A reference to str.

Definition at line 403 of file StringUtil.cpp.

References xms::stRemove().

Referenced by xms::stPrecision(), xms::stRemove(), and xms::stRemoveCopy().

◆ stRemoveCopy()

std::string xms::stRemoveCopy ( const std::string &  str,
char  source 
)

Returns a copy of str with all instances of char source removed.

Parameters
[in,out]strThe string.
[in]sourceThe character to be removed.
Returns
The new string.
See also
http://stackoverflow.com/questions/20326356/

Definition at line 392 of file StringUtil.cpp.

References xms::stRemove(), and xms::stRemoveCopy().

Referenced by xms::stRemoveCopy().

◆ stReplace() [1/2]

std::string & xms::stReplace ( std::string &  str,
char  source,
char  dest 
)

Returns a reference to str, and replaces every instance of source replaced with dest.

Parameters
[in,out]strThe string to be modified.
[in]sourceThe character to be replaced.
[in]destThe character replacing source.
Returns
Reference to str.

Definition at line 345 of file StringUtil.cpp.

References xms::stReplace().

Referenced by xms::stChangeExtendedAscii(), xms::stReplace(), and xms::stReplaceCopy().

◆ stReplace() [2/2]

std::string & xms::stReplace ( std::string &  str,
const std::string &  source,
const std::string &  dest 
)

Returns a reference to str, and replaces every instance of source replaced with dest.

Parameters
[in,out]strThe string to be modified.
[in]sourceThe sub string to be replaced.
[in]destThe sub string replacing source.
Returns
Reference to str.

Definition at line 367 of file StringUtil.cpp.

References xms::stReplace().

◆ stReplaceCopy() [1/2]

std::string xms::stReplaceCopy ( const std::string &  str,
char  source,
char  dest 
)

Returns a copy of str with every instance of source replaced with dest.

Parameters
[in,out]strThe string.
[in]sourceThe character to be replaced.
[in]destThe character replacing source.
Returns
The new string.

Definition at line 318 of file StringUtil.cpp.

References xms::stReplace(), and xms::stReplaceCopy().

Referenced by xms::stReplaceCopy().

◆ stReplaceCopy() [2/2]

std::string xms::stReplaceCopy ( const std::string &  str,
const std::string &  source,
const std::string &  dest 
)

Returns a copy of str with every instance of source replaced with dest.

Parameters
[in,out]strThe string.
[in]sourceThe sub string to be replaced.
[in]destThe sub string replacing source.
Returns
The new string.

Definition at line 331 of file StringUtil.cpp.

References xms::stReplace(), and xms::stReplaceCopy().

◆ stRight()

std::string & xms::stRight ( std::string &  a_source,
size_t const  a_length 
)

Modifies a_source to contain the last (rightmost) a_length characters.

Parameters
[in,out]a_sourceThe string that is modified.
[in]a_lengthNumber of rightmost characters to keep.
Returns
A reference to a_source.

Definition at line 537 of file StringUtil.cpp.

References xms::stRight(), and XM_ASSERT.

Referenced by xms::stRight(), and xms::stRightCopy().

◆ stRightCopy()

std::string xms::stRightCopy ( const std::string &  a_source,
size_t const  a_length 
)

Extracts last (rightmost) a_length characters from a_source returning a copy.

Parameters
[in]a_sourceThe string.
[in]a_lengthNumber of rightmost characters to keep.
Returns
The new string.

Definition at line 484 of file StringUtil.cpp.

References xms::stRight(), xms::stRightCopy(), and XM_ASSERT.

Referenced by xms::stRightCopy().

◆ STRstd() [1/4]

template<typename T >
std::string xms::STRstd ( a_value,
int  a_n = 0,
int  width = 0,
int  flags = 0 
)
inline

brief Formats an integral type (int, unsigned int, etc ) as a std::string. Ignores precision (n) arg (always 0) and only honors flags STR_SCIENTIFIC and STR_FULLWIDTH.

This overload is needed when called from a template function.

Parameters
a_value= the value.
a_n= ignored
width= the MAX num characters (15 by default)
flags=
See also
STRstd for doubles for documentation.
Returns
The string.

Definition at line 127 of file StringUtil.h.

References xms::STR_SCIENTIFIC, and xms::STRstd().

Referenced by xms::StCommaNumpunct::do_grouping().

◆ STRstd() [2/4]

std::string xms::STRstd ( double  a_value,
int  a_n,
int  width,
int  flags 
)

Get a properly formatted string from a double.

The reason for the short name is so that we can easily replace code like this: fprintf(fp, "%g %g", value1, value2); with code like this: fprintf(fp, "%s %s", STR(value1), STR(value2));

Parameters
a_value= the floating point number to be formatted as a string
a_n= the MAX precision, -1 (default) is auto compute
width= the MAX num characters (15 by default)
flags= bitwise flags: STR_FLOAT = 1 Treat value as floating point value (i.e. only 7 digits of precision are available) STR_SCIENTIFIC = 2 Force use of scientific notation STR_USEMAXPREC = 4 This only applies when a_n is not -1. a_n value is the desired precision. When this flag is set, the returned string may have less precision because trailing zeros are removed. When this flag is not set, they are not removed. Example: a_n = 3 and a_value = 5.0003 With this flag, returned string is "5.0". Without this flag, the returned string is "5.000". STR_FULLWIDTH = 8 Forces string to be 'width' in length. If the number is less than this width, it is padded with spaces on the right side. STR_WITHCOMMAS = 16 Includes commas in the number (345,000.0). Does account for different locales.
Returns
std::string of the number.

Definition at line 995 of file StringUtil.cpp.

References xms::LT_TOL(), xms::Miabs(), xms::stPrecision(), xms::STR_FULLWIDTH, xms::STR_SCIENTIFIC, xms::STR_USEMAXPREC, xms::STR_WITHCOMMAS, xms::STRstd(), xms::stTrimRight(), and XM_ASSERT.

Referenced by xms::daWrite3DoubleLine(), xms::daWriteDoubleLine(), xms::daWriteVecDbl(), xms::daWriteVecPt3d(), and xms::STRstd().

◆ STRstd() [3/4]

std::string xms::STRstd ( float  value,
int  n,
int  width,
int  flags 
)

Get a properly formatted string from a float.

The reason for the short name is so that we can easily replace code like this: fprintf(fp, "%g %g", value1, value2); with code like this: fprintf(fp, "%s %s", STR(value1), STR(value2));

Parameters
value= the floating point number to be formatted as a string
n= the MAX precision, -1 (default) is auto compute
width= the MAX num characters (15 by default)
flags= bitwise flags: STR_FLOAT = 1 Treat value as floating point value (i.e. only 7 digits of precision are available) STR_SCIENTIFIC = 2 Force use of scientific notation STR_USEMAXPREC = 4 This only applies when a_n is not -1. a_n value is the desired precision. When this flag is set, the returned string may have less precision because trailing zeros are removed. When this flag is not set, they are not removed. Example: a_n = 3 and a_value = 5.0003 With this flag, returned string is "5.0". Without this flag, the returned string is "5.000". STR_FULLWIDTH = 8 Forces string to be 'width' in length. If the number is less than this width, it is padded with spaces on the right side. STR_WITHCOMMAS = 16 Includes commas in the number (345,000.0). Does account for different locales.
Returns
std::string of the number.

Definition at line 1168 of file StringUtil.cpp.

References xms::STRstd().

◆ STRstd() [4/4]

std::string xms::STRstd ( std::string  value)

This version is needed because the template parameter could be a string.

Parameters
value= the value.
Returns
The string.

Definition at line 1178 of file StringUtil.cpp.

References xms::STRstd().

◆ stScientificNotation()

bool xms::stScientificNotation ( const std::string &  str,
bool  check_numeric 
)

Determines whether the given string is a number in scientific notation.

Parameters
[in]strThe string to modify.
check_numericPass false if you are sure your string is a number.
Returns
true or false.

Definition at line 103 of file StringUtil.cpp.

References xms::stNumeric(), and xms::stScientificNotation().

Referenced by xms::stScientificNotation().

◆ stSimplified()

std::string xms::stSimplified ( const std::string &  str)

Removes all white space from the passed string.

Parameters
[in]strThe string to be modified.
Returns
Modified string.

Definition at line 497 of file StringUtil.cpp.

References xms::stSimplified().

Referenced by xms::stSimplified().

◆ stSplit()

VecStr xms::stSplit ( const std::string &  a_source,
const std::string &  a_delimiterList,
bool  a_delimiterCompressOn 
)

Breaks string into vector of strings based on one or more delimiters.

Parameters
[in]a_sourceThe string to be split.
[in]a_delimiterListString where each character is a delimeter.
[in]a_delimiterCompressOnIf true, consecutive delimeters are treated as one.
Returns
A vector of strings.
See also
http://stackoverflow.com/questions/236129/split-a-string-in-c

Definition at line 182 of file StringUtil.cpp.

References xms::stSplit(), and xms::stTrimCopy().

Referenced by xms::stSplit().

◆ stStringToDouble()

bool xms::stStringToDouble ( const std::string &  s,
double &  d 
)

Convert a string to an double.

Better than stringstream or boost::lexical_cast. See: http://stackoverflow.com/questions/194465/how-to-parse-a-string-to-an-int-in-c

Parameters
[in]sThe string.
[out]dThe double.
Returns
true if successful

Definition at line 646 of file StringUtil.cpp.

References xms::stStringToDouble().

Referenced by xms::stStringToDouble().

◆ stStringToInt()

bool xms::stStringToInt ( const std::string &  s,
int &  i,
int  base 
)

Convert a string to an int.

Better than stringstream or boost::lexical_cast. See: http://stackoverflow.com/questions/194465/how-to-parse-a-string-to-an-int-in-c

Parameters
[in]sThe string.
[out]iThe double.
[in]baseNumeric base.
Returns
true if successful

Definition at line 625 of file StringUtil.cpp.

References xms::stStringToInt().

Referenced by xms::stStringToInt().

◆ stToLower()

std::string & xms::stToLower ( std::string &  str)

Modifies str to be all lowercase.

Parameters
[in,out]strString to be modified.
Returns
A reference to str.

Definition at line 421 of file StringUtil.cpp.

References xms::stToLower().

Referenced by xms::stToLower(), and xms::stToLowerCopy().

◆ stToLowerCopy()

std::string xms::stToLowerCopy ( const std::string &  str)

Returns a new string that is str with all characters lowercase.

Parameters
strThe string.
Returns
The new string.

Definition at line 412 of file StringUtil.cpp.

References xms::stToLower(), and xms::stToLowerCopy().

Referenced by xms::stFindNoCase(), and xms::stToLowerCopy().

◆ stToUpper()

std::string & xms::stToUpper ( std::string &  str)

Modifies str to be all uppercase.

Parameters
[in,out]strString to be modified.
Returns
A reference to str.

Definition at line 441 of file StringUtil.cpp.

References xms::stToUpper().

Referenced by xms::stToUpper(), and xms::stToUpperCopy().

◆ stToUpperCopy()

std::string xms::stToUpperCopy ( const std::string &  str)

Returns a new string that is str with all characters uppercase.

Parameters
strThe string.
Returns
The new string.

Definition at line 432 of file StringUtil.cpp.

References xms::stToUpper(), and xms::stToUpperCopy().

Referenced by xms::stToUpperCopy().

◆ stTrim()

std::string & xms::stTrim ( std::string &  str,
const std::string &  delim 
)

Trim the leading and trailing delim characters from a string.

Parameters
[in,out]strThe string to be modified.
[in]delimAll the characters you want to be trimmed.
Returns
A reference to str.

Definition at line 306 of file StringUtil.cpp.

References xms::stTrim(), xms::stTrimLeft(), and xms::stTrimRight().

Referenced by xms::stTrim(), and xms::stTrimCopy().

◆ stTrimCopy()

std::string xms::stTrimCopy ( const std::string &  str,
const std::string &  delim 
)

Trims the white space from a string. This involves creating a copy of the string (twice I believe), so don't call this unless you really don't want the original string modified.

Parameters
[in,out]strThe string.
[in]delimAll the characters you want to be trimmed.
Returns
The new string.

Definition at line 258 of file StringUtil.cpp.

References xms::stTrim(), and xms::stTrimCopy().

Referenced by xms::stNumeric(), xms::stSplit(), and xms::stTrimCopy().

◆ stTrimLeft()

std::string & xms::stTrimLeft ( std::string &  str,
const std::string &  delim 
)

Trims the leading delim characters from a string.

Parameters
[in,out]strThe string to be modified.
[in]delimAll the characters you want to be trimmed.
Returns
A reference to str.

Definition at line 270 of file StringUtil.cpp.

References xms::stTrimLeft().

Referenced by xms::stTrim(), and xms::stTrimLeft().

◆ stTrimRight()

std::string & xms::stTrimRight ( std::string &  str,
const std::string &  delim 
)

Trims the trailing delim characters from a string.

Parameters
[in,out]strThe string to be modified.
[in]delimAll the characters you want to be trimmed.
Returns
A reference to str.

Definition at line 288 of file StringUtil.cpp.

References xms::stTrimRight().

Referenced by xms::STRstd(), xms::stTrim(), and xms::stTrimRight().

◆ stVectorContainsString()

bool xms::stVectorContainsString ( const VecStr a_container,
const std::string &  str 
)

Checks if a vec of strings contains a string. Case sensitive.

Parameters
[in]a_containerVec of strings to iterate through.
[in]strString to search for in the container.
Returns
True if a_container contains a str, otherwise False.

Definition at line 527 of file StringUtil.cpp.

References xms::stVectorContainsString().

Referenced by xms::stVectorContainsString().