|
Core Library
1.7.0.0
Library containing core utilities and tools for threading, networking, logging, INI and CSV file management etc.
|
The string_utils namespace. More...
Classes | |
| struct | deletable_facet |
Enumerations | |
| enum | eSplitStringResult { eSplitStringResult::trimmed, eSplitStringResult::notTrimmed } |
| Split string options enumeration. More... | |
| enum | eFloatStringFormat { eFloatStringFormat::normal, eFloatStringFormat::fixed, eFloatStringFormat::scientific } |
| Format float options enumeration. More... | |
Functions | |
| void CORE_LIBRARY_DLL_SHARED_API | PackStdString (std::string &line) |
| Tidy a string obtained from getline function. More... | |
| void CORE_LIBRARY_DLL_SHARED_API | SplitString (std::string &subStr1, std::string &subStr2, const std::string &toSplit, const std::string &delim, eSplitStringResult option) |
| Split a string into two parts given delimiters. More... | |
| template<typename T > | |
| std::string | FormatFloatString (const T value, const int precision=15, eFloatStringFormat formatting=eFloatStringFormat::normal) |
| Convert a floating point value to a formatted string representation. More... | |
| template<typename T > | |
| std::string | AutoFormatFloatString (const T value, int decimalPlaces=1) |
| Convert a floating point value to a string representation using the most suitable formatting. More... | |
| std::wstring CORE_LIBRARY_DLL_SHARED_API | RemoveIllegalChars (const std::wstring &text, const std::wstring &illegalChars=L"~#%&*{}<>?/+|\, wchar_t replacementChar=L '_') |
| Return a string with any illegal chars replaced with replacement char. More... | |
| std::string CORE_LIBRARY_DLL_SHARED_API | RemoveIllegalChars (const std::string &text, const std::string &illegalChars="~#%&*{}<>?/+|\, char replacementChar='_') |
| std::wstring CORE_LIBRARY_DLL_SHARED_API | StringToWString (const std::string &text) |
| Convert a std::string to std::wstring. More... | |
| std::string CORE_LIBRARY_DLL_SHARED_API | WStringToString (const std::wstring &text) |
| Convert a std::wstring to std::string. More... | |
| bool CORE_LIBRARY_DLL_SHARED_API | IsAlphaNumeric (const std::wstring &text) |
| Return a flag to indicate whether string contains only alphanumeric chars. More... | |
| bool CORE_LIBRARY_DLL_SHARED_API | IsAlphaNumeric (const std::string &text) |
| template<typename Iter > | |
| std::string | MakeHexString (Iter first, Iter last, bool useUppercase, bool insertSpaces) |
| Convert a range of data that is convertible to ints to a string of hex values. More... | |
| std::vector< std::string > CORE_LIBRARY_DLL_SHARED_API | TokeniseString (std::string const &text, std::string const &separator, bool keepEmptyTokens=false) |
| Tokenise a string separated by a separator substring and split it into tokens. More... | |
| std::string CORE_LIBRARY_DLL_SHARED_API | ReplaceTokens (std::string const &text, std::map< std::string, std::string > const &tokenMap) |
| Gieven a string containing tokens, replace tokens with specific string values. More... | |
The string_utils namespace.
|
strong |
|
strong |
| std::string core_lib::string_utils::AutoFormatFloatString | ( | const T | value, |
| int | decimalPlaces = 1 |
||
| ) |
Convert a floating point value to a string representation using the most suitable formatting.
| [in] | value | - Floating point value to convert to a string. |
| [in] | decimalPlaces | - Number of decimal places to present after the decimal point. return Resultant string. |
Convert a single or double precision floating point number to a string representaion.
| std::string core_lib::string_utils::FormatFloatString | ( | const T | value, |
| const int | precision = 15, |
||
| eFloatStringFormat | formatting = eFloatStringFormat::normal |
||
| ) |
Convert a floating point value to a formatted string representation.
| [in] | value | - Floating point value to convert to a string. |
| [in] | precision | - Precision to display the number to as a string. |
| [in] | formatting | - Formatting options. return Resultant string. |
Convert a single or double precision floating point number to a string representaion.
| bool core_lib::string_utils::IsAlphaNumeric | ( | const std::wstring & | text | ) |
Return a flag to indicate whether string contains only alphanumeric chars.
| [in] | text | - Source string potentially with illegal chars. |
| std::string core_lib::string_utils::MakeHexString | ( | Iter | first, |
| Iter | last, | ||
| bool | useUppercase, | ||
| bool | insertSpaces | ||
| ) |
Convert a range of data that is convertible to ints to a string of hex values.
| [in] | first | - Iterator to first item in range |
| [in] | last | - Iterator to end of range |
| [in] | useUppercase | - Use uppercase letters for hex values |
| [in] | insertSpaces | - Insert spaces between each byte value |
| void core_lib::string_utils::PackStdString | ( | std::string & | line | ) |
Tidy a string obtained from getline function.
| [in,out] | line | - A string obtained using getline. |
Safely convert string into sensible form due to bug in some implementations of std::getline() (looking at you Embarcadero C++ Builder) where size is greater than pos of null char.
| std::wstring core_lib::string_utils::RemoveIllegalChars | ( | const std::wstring & | text, |
| const std::wstring & | illegalChars = L"~#%&*{}\\:<>?/+|\"", |
||
| wchar_t | replacementChar = L'_' |
||
| ) |
Return a string with any illegal chars replaced with replacement char.
| [in] | text | - Source string potentially with illegal chars. |
| [in] | illegalChars | - String containing illegal chars to look for in text. |
| [in] | replacementChar | - String containing replacement. |
| std::string core_lib::string_utils::ReplaceTokens | ( | std::string const & | text, |
| std::map< std::string, std::string > const & | tokenMap | ||
| ) |
Gieven a string containing tokens, replace tokens with specific string values.
| [in] | text | - string to replace tokens in |
| [in] | tokenMap | - map of token strings and the string values to replace the tokens with in 'text' arg. |
| void core_lib::string_utils::SplitString | ( | std::string & | subStr1, |
| std::string & | subStr2, | ||
| const std::string & | toSplit, | ||
| const std::string & | delim, | ||
| eSplitStringResult | option | ||
| ) |
Split a string into two parts given delimiters.
| [out] | subStr1 | - First output substring. |
| [out] | subStr2 | - Second output substring. |
| [in] | toSplit | - Input string to be split into two. |
| [in] | delim | - Delimiters to look for to split around. |
| [in] | option | - Options to formt resultant substrings. |
Given an input string and a string containing delimiters the input string is split into two parts either side of the deilimiter string. If none of the delimiters can be found then a std::invalid_argument exception is thrown. If the string will be split into more than two substrings then a std::runtime_error exception is thrown.
| std::wstring core_lib::string_utils::StringToWString | ( | const std::string & | text | ) |
Convert a std::string to std::wstring.
| [in] | text | - Source string. |
| std::vector< std::string > core_lib::string_utils::TokeniseString | ( | std::string const & | text, |
| std::string const & | separator, | ||
| bool | keepEmptyTokens = false |
||
| ) |
Tokenise a string separated by a separator substring and split it into tokens.
| [in] | text | - string to tokenise |
| [in] | separator | - separator string |
| [in] | keepEmptyTokens | - keep empty tokens in result vector |
| std::string core_lib::string_utils::WStringToString | ( | const std::wstring & | text | ) |
Convert a std::wstring to std::string.
| [in] | text | - Source string |