StringUtility.cpp File Reference
Implements functions for manipulating strings.
More...
#include <sstream>
#include "Utility/StringUtility.h"
Functions |
| bool | IsInteger (const std::string &str, int *val) |
| | Determines if the given string is an integer.
|
| bool | IsWholeInteger (const std::string &str, int *val) |
| | Determines if the given string is strictly an integer.
|
| bool | IsFloat (const std::string &str, float *val) |
| | Determines if the given string is a float.
|
| bool | IsBoolean (const std::string &str, bool *val) |
| | Determines if the given string is a boolean (0, 1, T, F, True, False, etc.).
|
| void | Replace (std::string &str, const char *match, char replace) |
| | Replaces matching characters with a spacific single char.
|
| void | Replace (std::string &str, const char *match, const char *replace) |
| | Replaces matching characters with a spacific string.
|
| std::string | Trim (const std::string &str, const char *what) |
| | Trims leading and ending characters from a string.
|
| std::vector< std::string > | Split (const std::string &str, const char *delim, bool skipDeliminator) |
| | Splits a string into multiple substrings.
|
| size_t | Split (const std::string &str, const char *delim, std::vector< std::string > &result, bool skipDeliminator) |
| | Splits a string into multiple substrings.
|
Detailed Description
Implements functions for manipulating strings.
- Author:
- Joe Forte
- Date:
- 9/13/2008
Function Documentation
| bool IsBoolean |
( |
const std::string & |
str, |
|
|
bool * |
val = NULL | |
|
) |
| | |
Determines if the given string is a boolean (0, 1, T, F, True, False, etc.).
- Parameters:
-
| [in] | str | the string to check. |
| [out] | val | the bool that the string represents. Defaults to NULL. |
- Returns:
- true if str represents a boolean, false otherwise.
| bool IsFloat |
( |
const std::string & |
str, |
|
|
float * |
val = NULL | |
|
) |
| | |
Determines if the given string is a float.
- Parameters:
-
| [in] | str | the string to check. |
| [out] | val | the float that the string represents. Defaults to NULL. |
- Returns:
- true if str represents an float, false otherwise.
| bool IsInteger |
( |
const std::string & |
str, |
|
|
int * |
val = NULL | |
|
) |
| | |
Determines if the given string is an integer.
- Parameters:
-
| [in] | str | the string to check. |
| [out] | val | the integer that the string represents. Defaults to NULL. |
- Returns:
- true if str represents an integer, false otherwise.
| bool IsWholeInteger |
( |
const std::string & |
str, |
|
|
int * |
val = NULL | |
|
) |
| | |
Determines if the given string is strictly an integer.
- Parameters:
-
| [in] | str | the string to check. |
| [out] | val | the integer that the string represents. Defaults to NULL. |
- Returns:
- true if str represents an integer, false otherwise.
| void Replace |
( |
std::string & |
str, |
|
|
const char * |
match, |
|
|
const char * |
replace | |
|
) |
| | |
Replaces matching characters with a spacific string.
- Parameters:
-
| [in] | str | the string to alter. |
| [in] | match | the characters to match. |
| [in] | replace | the character string to replace matches with. |
| void Replace |
( |
std::string & |
str, |
|
|
const char * |
match, |
|
|
char |
replace | |
|
) |
| | |
Replaces matching characters with a spacific single char.
- Parameters:
-
| [in] | str | the string to alter. |
| [in] | match | the characters to match. |
| [in] | replace | the character to replace matches with. |
| size_t Split |
( |
const std::string & |
str, |
|
|
const char * |
delim, |
|
|
std::vector< std::string > & |
result, |
|
|
bool |
skipDeliminator = true | |
|
) |
| | |
Splits a string into multiple substrings.
- Parameters:
-
| [in] | str | the string to split. |
| [in] | delim | a string of deliminating characters. Each individual character in the string is considered a deliminator. |
| [out] | result | stores the split substrings of str. |
| [in] | skipDeliminator | set to false to not have deliminators present in the output. Defaults to true. |
- Returns:
- The number of substrings added to result.
| std::vector<std::string> Split |
( |
const std::string & |
str, |
|
|
const char * |
delim = " ", |
|
|
bool |
skipDeliminator = true | |
|
) |
| | |
Splits a string into multiple substrings.
- Parameters:
-
| [in] | str | the string to split. |
| [in] | delim | a string of deliminating characters. Each individual character in the string is considered a deliminator. Defaults to " ". |
| [in] | skipDeliminator | set to false to not have deliminators present in the output. Defaults to true. |
- Returns:
- The vector of substrings split from str.
| std::string Trim |
( |
const std::string & |
str, |
|
|
const char * |
what = " \t\n\r" | |
|
) |
| | |
Trims leading and ending characters from a string.
- Parameters:
-
| [in] | str | the string to trim. |
| [in] | what | the characters to be trimed. Defaults to space and newline characters. |
- Returns:
- the trimmed string.