ExchangeFileContents
|
Help functions for the processing of strings. More...
Enumerations | |
enum | EnCoutColor { eCOLOR_DEFAULT = 0 , eCOLOR_BLACK = 1 , eCOLOR_BLUE = 2 , eCOLOR_GREEN = 3 , eCOLOR_LIGHTBLUE = 4 , eCOLOR_RED = 5 , eCOLOR_MAGENTA = 6 , eCOLOR_YELLOW = 7 , eCOLOR_LIGHTGRAY = 8 , eCOLOR_GRAY = 9 , eCOLOR_WHITE = 10 } |
enum | EnStrPos { eBEFORE , eBEHIND , eBOTH } |
Functions | |
template<typename T > | |
std::string | toHexstr (const T &rValue, std::size_t hex_len=sizeof(T)<< 1) |
__tool_export_dll bool | isAnInteger (const std::string &rstr) |
__tool_export_dll void | fillString (std::string &rstr, char cFillItem, std::size_t nNumber, EnStrPos ePos) |
__tool_export_dll char * | getFilledString (const char *pch, char cFillItem, std::size_t nNumber, EnStrPos ePos) |
__tool_export_dll std::string | getFilledString (const std::string &rstr, char cFillItem, std::size_t nNumber, EnStrPos ePos) |
__tool_export_dll void | tokenizeString (const std::string &rstrSource, std::vector< std::string > &rTokensVector, const std::string &rstrDelimiters=" ") |
__tool_export_dll void | tokenizeString (const std::string &rstrSource, std::vector< std::string > &rTokensVector, const char &rcDelimiters=' ') |
__tool_export_dll void | tokenizeString (const std::wstring &rwsSource, std::vector< std::wstring > &rTokensVector, wchar_t wcDelimiters=L' ') |
__tool_export_dll std::size_t | replaceAll (std::string &rstrText, const char pzOriginal, const char pzNew) |
__tool_export_dll std::size_t | replaceAll (std::string &rstrText, std::vector< std::size_t > &rPosVector, const char pzOriginal, const char pzNew) |
__tool_export_dll std::wstring | string2wstring (const std::string &rsSourceString) |
__tool_export_dll std::string | wstring2string (const std::wstring &rwsSourceString) |
__tool_export_dll WORD | setColorConsoleCout (EnCoutColor eForeGroundColor, EnCoutColor eBackGroundColor) |
__tool_export_dll void | resetColorConsoleCout (WORD wScreenBufferInfo) |
__tool_export_dll std::string | toLower (const std::string &rstr) |
Converts all uppercase letters of the passed string to lowercase. | |
__tool_export_dll std::wstring | toLower (const std::wstring &rstr) |
Converts all uppercase letters of the passed string to lowercase. | |
__tool_export_dll std::string | toUpper (const std::string &rstr) |
Converts all lowercase letters of the passed string to uppercase. | |
__tool_export_dll std::wstring | toUpper (const std::wstring &rstr) |
Converts all lowercase letters of the passed string to uppercase. | |
__tool_export_dll void | trimString (std::string &rstr, char c=' ', EnStrPos ePos=eBEFORE) |
Trim for std::string inspired by: | |
__tool_export_dll void | trimString (std::wstring &rstr, wchar_t c=' ', EnStrPos ePos=eBEFORE) |
Trim for std::string inspired by: | |
__tool_export_dll bool | insertIfNotAvailable (std::string &rsText, std::size_t nPos, const std::string &rsIns) |
Inserts a string at the position passed, if not already present. | |
__tool_export_dll bool | insertIfNotAvailable (std::wstring &rsText, std::size_t nPos, const std::wstring &rsIns) |
Inserts a string at the position passed, if not already present. | |
__tool_export_dll std::size_t | replaceAll (std::string &rsText, const std::string &rsFnd, const std::string &rsRep) |
Exchanges all searched substrings in a string with another passed string. | |
__tool_export_dll std::size_t | replaceAll (std::wstring &rsText, const std::wstring &rsFnd, const std::wstring &rsRep) |
Exchanges all searched substrings in a string with another passed string. | |
__tool_export_dll bool | compareWildcardString (const std::string &rsSearchString, const std::string &rsString) |
Compares two std::string's. | |
__tool_export_dll bool | compareWildcardString (const std::wstring &rsSearchString, const std::wstring &rsString) |
Compares two std::string's. | |
__tool_export_dll void | colorConsoleCout (const std::string &rsCoutText, EnCoutColor eForeGroundColor, EnCoutColor eBackGroundColor) |
Outputs a string to the console in color. | |
__tool_export_dll void | colorConsoleCout (const std::wstring &rsCoutText, EnCoutColor eForeGroundColor, EnCoutColor eBackGroundColor) |
Outputs a string to the console in color. | |
Help functions for the processing of strings.
Positioning in the string for StdStringFunctions::fillString(std::string&, char, std::size_t, EnStrPos)
Enumerator | |
---|---|
eBEFORE | It should be inserted or removed at the beginning. |
eBEHIND | It should be inserted or removed at the end. |
eBOTH | It should be inserted or removed at the beginning and at the end. |
__tool_export_dll void eut::StdStringFunctions::colorConsoleCout | ( | const std::string & | rsCoutText, |
EnCoutColor | eForeGroundColor, | ||
EnCoutColor | eBackGroundColor ) |
Outputs a string to the console in color.
[in] | rsCoutText | The text to be output. |
[in] | eForeGroundColor | The foreground, i.e. text color. |
[in] | eBackGroundColor | The background color. |
__tool_export_dll void eut::StdStringFunctions::colorConsoleCout | ( | const std::wstring & | rsCoutText, |
EnCoutColor | eForeGroundColor, | ||
EnCoutColor | eBackGroundColor ) |
Outputs a string to the console in color.
[in] | rsCoutText | The text to be output. |
[in] | eForeGroundColor | The foreground, i.e. text color. |
[in] | eBackGroundColor | The background color. |
__tool_export_dll bool eut::StdStringFunctions::compareWildcardString | ( | const std::string & | rsSearchString, |
const std::string & | rsString ) |
Compares two std::string's.
The search string can contain wildcards ('*' and '?').
Written by Jack Handy - jakkhandy@hotmail.com
Example:
[in] | rsSearchString | The search string with wildcards if necessary. |
[in] | rsString | The comparison string with which the search string is compared. |
__tool_export_dll bool eut::StdStringFunctions::compareWildcardString | ( | const std::wstring & | rsSearchString, |
const std::wstring & | rsString ) |
Compares two std::string's.
The search string can contain wildcards ('*' and '?').
Written by Jack Handy - jakkhandy@hotmail.com
Example:
[in] | rsSearchString | The search string with wildcards if necessary. |
[in] | rsString | The comparison string with which the search string is compared. |
__tool_export_dll void eut::StdStringFunctions::fillString | ( | std::string & | rstr, |
char | cFillItem, | ||
std::size_t | nNumber, | ||
EnStrPos | ePos ) |
Fills the string passed with characters at the beginning or end.
[in,out] | rstr | Reference to the string to be padded. |
[in] | cFillItem | The character to be padded. |
[in] | nNumber | The targeted string length. |
[in] | ePos | Specifies whether to fill at the beginning and/or at the end. |
__tool_export_dll char * eut::StdStringFunctions::getFilledString | ( | const char * | pch, |
char | cFillItem, | ||
std::size_t | nNumber, | ||
EnStrPos | ePos ) |
Fills a passed 0-terminated Char-Array with characters at the beginning or end.
[in,out] | pch | Pointer to the 0-terminated char array to be added. |
[in] | cFillItem | The character to be filled with. |
[in] | nNumber | The targeted string length. |
[in] | ePos | Specifies whether to fill at the beginning or at the end. |
__tool_export_dll std::string eut::StdStringFunctions::getFilledString | ( | const std::string & | rstr, |
char | cFillItem, | ||
std::size_t | nNumber, | ||
EnStrPos | ePos ) |
Fills a passed std::string with characters at the beginning or end.
[in,out] | rstr | String to be added. |
[in] | cFillItem | The character to be filled with. |
[in] | nNumber | The targeted string length. |
[in] | ePos | Specifies whether to fill at the beginning or at the end. |
__tool_export_dll bool eut::StdStringFunctions::insertIfNotAvailable | ( | std::string & | rsText, |
std::size_t | nPos, | ||
const std::string & | rsIns ) |
Inserts a string at the position passed, if not already present.
[in,out] | rsText | In this string, the string rsIns is inserted at the position nPos passed, if not already present. |
[in] | nPos | The position in rsText where is checked and inserted if necessary. |
[in] | rsIns | The character string to be checked and inserted if necessary. |
__tool_export_dll bool eut::StdStringFunctions::insertIfNotAvailable | ( | std::wstring & | rsText, |
std::size_t | nPos, | ||
const std::wstring & | rsIns ) |
Inserts a string at the position passed, if not already present.
[in,out] | rsText | In this string, the string rsIns is inserted at the position nPos passed, if not already present. |
[in] | nPos | The position in rsText where is checked and inserted if necessary. |
[in] | rsIns | The character string to be checked and inserted if necessary. |
__tool_export_dll bool eut::StdStringFunctions::isAnInteger | ( | const std::string & | rstr | ) |
Checks the passed string whether it represents an integer.
[in] | rstr | Reference to the string to be checked. |
__tool_export_dll std::size_t eut::StdStringFunctions::replaceAll | ( | std::string & | rsText, |
const std::string & | rsFnd, | ||
const std::string & | rsRep ) |
Exchanges all searched substrings in a string with another passed string.
[in,out] | rsText | In this string, all strings from strFnd are removed and the string from strRep is inserted instead. |
[in] | rsFnd | The string to be exchanged. |
[in] | rsRep | The string to be inserted. |
__tool_export_dll std::size_t eut::StdStringFunctions::replaceAll | ( | std::string & | rstrText, |
const char | pzOriginal, | ||
const char | pzNew ) |
Exchanges all searched characters in a string with another passed character.
[in,out] | rstrText | In this string, all characters from pzOriginal are removed and the string from pzNew is inserted instead. |
[in] | pzOriginal | The character to be exchanged. |
[in] | pzNew | The character to be inserted. |
__tool_export_dll std::size_t eut::StdStringFunctions::replaceAll | ( | std::string & | rstrText, |
std::vector< std::size_t > & | rPosVector, | ||
const char | pzOriginal, | ||
const char | pzNew ) |
Exchanges all searched characters in a string with another passed character and enters the respective positions in passed vector.
[in,out] | rstrText | In this string, all characters from pzOriginal are removed and the string from pzNew is inserted instead. |
[in,out] | rPosVector | The positions with the exchanged characters. |
[in] | pzOriginal | The character to be exchanged. |
[in] | pzNew | The character to be inserted. |
__tool_export_dll std::size_t eut::StdStringFunctions::replaceAll | ( | std::wstring & | rsText, |
const std::wstring & | rsFnd, | ||
const std::wstring & | rsRep ) |
Exchanges all searched substrings in a string with another passed string.
[in,out] | rsText | In this string, all strings from strFnd are removed and the string from strRep is inserted instead. |
[in] | rsFnd | The string to be exchanged. |
[in] | rsRep | The string to be inserted. |
__tool_export_dll void eut::StdStringFunctions::resetColorConsoleCout | ( | WORD | wScreenBufferInfo | ) |
Sets font to a color of the console to the default color for the next output.
[in] | wScreenBufferInfo | The CONSOLE_SCREEN_BUFFER_INFO Attribute. |
__tool_export_dll WORD eut::StdStringFunctions::setColorConsoleCout | ( | EnCoutColor | eForeGroundColor, |
EnCoutColor | eBackGroundColor ) |
Sets font to a color of the console to a color for the next output.
[in] | eForeGroundColor | The foreground, i.e. text color. |
[in] | eBackGroundColor | The background color. |
__tool_export_dll std::wstring eut::StdStringFunctions::string2wstring | ( | const std::string & | rsSourceString | ) |
Converts a std::string into a std::wstring.
[in] | rsSourceString | The std::string to be converted. |
A | "range_error" can be thrown when UTF-16 characters ate passed. |
std::string eut::StdStringFunctions::toHexstr | ( | const T & | rValue, |
std::size_t | hex_len = sizeof(T) << 1 ) |
Convert the given integer number value to a hex string.
Found: https://newbedev.com/integer-to-hex-string-in-c
[in] | rValue | The number value. |
[in] | hex_len | The size of the number value. |
__tool_export_dll void eut::StdStringFunctions::tokenizeString | ( | const std::string & | rstrSource, |
std::vector< std::string > & | rTokensVector, | ||
const char & | rcDelimiters = ' ' ) |
Returns from a string all substrings, which are separated by a character, in one vector.
[in] | rstrSource | The source string from which substrings are supplied. |
[in,out] | rTokensVector | The vector in which the substrings are delivered. |
[in] | rcDelimiters | The character that divides the source string into substrings. |
__tool_export_dll void eut::StdStringFunctions::tokenizeString | ( | const std::string & | rstrSource, |
std::vector< std::string > & | rTokensVector, | ||
const std::string & | rstrDelimiters = " " ) |
Returns from a string all substrings, which are separated by a character, in one vector.
[in] | rstrSource | The source string from which substrings are supplied. |
[in,out] | rTokensVector | The vector in which the substrings are delivered. |
[in] | rstrDelimiters | The character that divides the source string into substrings. |
__tool_export_dll void eut::StdStringFunctions::tokenizeString | ( | const std::wstring & | rwsSource, |
std::vector< std::wstring > & | rTokensVector, | ||
wchar_t | wcDelimiters = L' ' ) |
Returns from a wstring all substrings, which are separated by a character, in one vector.
[in] | rwsSource | The source string from which substrings are supplied. |
[in,out] | rTokensVector | The vector in which the substrings are delivered. |
[in] | wcDelimiters | The character that divides the source string into substrings. |
__tool_export_dll std::string eut::StdStringFunctions::toLower | ( | const std::string & | rstr | ) |
Converts all uppercase letters of the passed string to lowercase.
[in,out] | rstr | The reference to the string to be processed. |
__tool_export_dll std::wstring eut::StdStringFunctions::toLower | ( | const std::wstring & | rstr | ) |
Converts all uppercase letters of the passed string to lowercase.
[in,out] | rstr | The reference to the string to be processed. |
__tool_export_dll std::string eut::StdStringFunctions::toUpper | ( | const std::string & | rstr | ) |
Converts all lowercase letters of the passed string to uppercase.
[in,out] | rstr | The reference to the string to be processed. |
__tool_export_dll std::wstring eut::StdStringFunctions::toUpper | ( | const std::wstring & | rstr | ) |
Converts all lowercase letters of the passed string to uppercase.
[in,out] | rstr | The reference to the string to be processed. |
__tool_export_dll void eut::StdStringFunctions::trimString | ( | std::string & | rstr, |
char | c = ' ', | ||
EnStrPos | ePos = eBEFORE ) |
Trim for std::string inspired by:
Rodrigo C F Dias
Software Engineering Degree
Living in Natal, Brazil
[in,out] | rstr | Reference to the string to be freed from leading and trailing characters. |
[in] | c | The character to be removed. If rstr == "XXXTestX" and c =='X' and ePos == eBOTH, rstr == becomes "Test". |
[in] | ePos | Specifies whether to remove at the beginning and/or the end. |
__tool_export_dll void eut::StdStringFunctions::trimString | ( | std::wstring & | rstr, |
wchar_t | c = ' ', | ||
EnStrPos | ePos = eBEFORE ) |
Trim for std::string inspired by:
Rodrigo C F Dias
Software Engineering Degree
Living in Natal, Brazil
[in,out] | rstr | Reference to the string to be freed from leading and trailing characters. |
[in] | c | The character to be removed. If rstr == "XXXTestX" and c =='X' and ePos == eBOTH, rstr == becomes "Test". |
[in] | ePos | Specifies whether to remove at the beginning and/or the end. |
__tool_export_dll std::string eut::StdStringFunctions::wstring2string | ( | const std::wstring & | rwsSourceString | ) |
Converts a std::wstring into a std::string.
[in] | rwsSourceString | The std::wstring to be converted. |