Ocean
|
This class provides string convert functionalities. More...
Public Member Functions | |
template<> | |
std::string | toString (const bool &value) |
Static Public Member Functions | |
static std::string | toAString (const char value) |
Converts a value to a string with 8bit character. More... | |
static std::string | toAString (const unsigned char value) |
Converts a value to a string with 8bit character. More... | |
static std::string | toAString (const double value, const unsigned int precision=5u) |
Converts a value to a string with 8bit character using a fixed notation. More... | |
static std::string | toAString (const float value, const unsigned int precision=5u) |
Converts a value to a string with 8bit character using a fixed notation. More... | |
static std::string | toAStringScientific (const double value, const unsigned int precision=5u) |
Converts a value to a string with 8bit character using a scientific notation. More... | |
static std::string | toAStringScientific (const float value, const unsigned int precision=5u) |
Converts a value to a string with 8bit character using a scientific notation. More... | |
static std::string | toAString (const int value) |
Converts a value to a string with 8bit character. More... | |
static std::string | toAString (const unsigned int value) |
Converts a value to a string with 8bit character. More... | |
static std::string | toAString (const long value) |
Converts a value to a string with 8bit character. More... | |
static std::string | toAString (const long long value) |
Converts a value to a string with 8bit character. More... | |
static std::string | toAString (const unsigned long long value) |
Converts a value to a string with 8bit character. More... | |
static std::string | toAString (const long unsigned int value) |
Converts a value to a string with 8bit character. More... | |
static std::string | toAString (const short value) |
Converts a value to a string with 8bit character. More... | |
static std::string | toAString (const unsigned short value) |
Converts a value to a string with 8bit character. More... | |
static std::string | toAString (const unsigned int value, const unsigned int minimalChars) |
Converts a value to a string with a minimal number of characters. More... | |
static std::string | toAStringHex (const char value, const bool upperCases=true) |
Converts a value to a string with 8bit character as hexadecimal notation. More... | |
static std::string | toAStringHex (const unsigned char value, const bool upperCases=true) |
Converts a value to a string with 8bit character as hexadecimal notation. More... | |
static std::string | toAStringHex (const double value, const bool upperCases=true) |
Converts a value to a string with 8bit character as hexadecimal notation. More... | |
static std::string | toAStringHex (const float value, const bool upperCases=true) |
Converts a value to a string with 8bit character as hexadecimal notation. More... | |
static std::string | toAStringHex (const int value, const bool upperCases=true) |
Converts a value to a string with 8bit character as hexadecimal notation. More... | |
static std::string | toAStringHex (const unsigned int value, const bool upperCases=true) |
Converts a value to a string with 8bit character as hexadecimal notation. More... | |
static std::string | toAStringHex (const long long value, const bool upperCases=true) |
Converts a value to a string with 8bit character as hexadecimal notation. More... | |
static std::string | toAStringHex (const unsigned long long value, const bool upperCases=true) |
Converts a value to a string with 8bit character as hexadecimal notation. More... | |
static std::string | toAStringHex (const long unsigned int value, const bool upperCases=true) |
Converts a value to a string with 8bit character as hexadecimal notation. More... | |
static std::string | toAStringHex (const short value, const bool upperCases=true) |
Converts a value to a string with 8bit character as hexadecimal notation. More... | |
static std::string | toAStringHex (const unsigned short value, const bool upperCases=true) |
Converts a value to a string with 8bit character as hexadecimal notation. More... | |
static std::string | toAStringHex (const uint8_t *data, const size_t size, const bool upperCases=true) |
Converts memory to a string with hexadecimal notation. More... | |
static std::string | toAStringHexReverse (const uint8_t *data, const size_t size, const bool upperCases=true) |
Converts memory to a string with hexadecimal notation in a reverse order. More... | |
static std::string | toLower (const std::string &value) |
Converts a string to a string with lower characters only. More... | |
static std::string | toUpper (const std::string &value) |
Converts a string to a string with upper characters only. More... | |
static std::string | trimFront (const std::string &value, const char character=' ') |
Trims the front of a string. More... | |
static std::string | trimBack (const std::string &value, const char character=' ') |
Trims the back of a string. More... | |
static std::string | trim (const std::string &value, const char character=' ') |
Trims the front and the back of a string. More... | |
static std::string | replace (std::string &&value, const std::string &oldString, const std::string &newString, const bool onlyFirstOccurrence) |
Replaces a sub-string inside a string with a different string. More... | |
static std::string | replaceCharacters (const std::string &value, const char oldCharacter, const char newCharacter) |
Replaces characters with a specified value by a new character. More... | |
static std::string | exchangeCharacters (const std::string &value, const char character0, const char character1) |
Exchanges two characters within a string. More... | |
static std::string | removeCharacters (const std::string &value, const char character) |
Removes characters with a specified value from a string. More... | |
template<typename TChar > | |
static std::basic_string< TChar > | insertCharacter (const std::basic_string< TChar > &value, const TChar &character, size_t interval, bool startAtFront) |
Inserts a specified character into a string in regular intervals. More... | |
static bool | isBoolean (const std::string &stringValue, const bool matchCase=true, const bool acceptInteger=false, bool *value=nullptr) |
Returns whether a given string stores a boolean value. More... | |
static bool | isInteger32 (const std::string &stringValue, int32_t *value=nullptr) |
Returns whether a given string stores a 32bit integer value. More... | |
static bool | isUnsignedInteger64 (const std::string &stringValue, uint64_t *value=nullptr) |
Returns whether a given string stores an unsigned 64bit integer value. More... | |
static bool | isHexValue64 (const char *hexString, size_t length, const bool needPrefix=false, unsigned long long *value=nullptr) |
Returns whether a given string stores an hexadecimal value with up to 64 bits. More... | |
static bool | isNumber (const std::string &stringValue, const bool acceptInteger=false, double *value=nullptr) |
Returns whether a given string stores a number value. More... | |
static std::string | toAString (const wchar_t value) |
Converts a value to a string with 8bit character. More... | |
static std::string | toAString (const char *value) |
Converts a value to a string with 8bit character. More... | |
static std::string | toAString (const wchar_t *value) |
Converts a value to a string with 8bit character. More... | |
static std::string | toAString (const std::string &value) |
Converts a value to a string with 8bit character. More... | |
static std::string | toAString (const std::wstring &value) |
Converts a value to a string with 8bit character. More... | |
static std::wstring | toWString (const char value) |
Converts a value to a wstring. More... | |
static std::wstring | toWString (const char *value) |
Converts a value to a wstring. More... | |
static std::wstring | toWString (const wchar_t *value) |
Converts a value to a wstring. More... | |
static std::wstring | toWString (const unsigned short *value) |
Converts a value to a wstring. More... | |
static std::wstring | toWString (const unsigned char value) |
Converts a value to a wstring. More... | |
static std::wstring | toWString (const double value, const unsigned int precision=5u) |
Converts a value to a wstring using a fixed notation. More... | |
static std::wstring | toWString (const float value, const unsigned int precision=5u) |
Converts a value to a wstring using a fixed notation. More... | |
static std::wstring | toWStringScientific (const double value, const unsigned int precision=5u) |
Converts a value to a wstring using a scientific notation. More... | |
static std::wstring | toWStringScientific (const float value, const unsigned int precision=5u) |
Converts a value to a wstring using a scientific notation. More... | |
static std::wstring | toWString (const int value) |
Converts a value to a wstring. More... | |
static std::wstring | toWString (const unsigned int value) |
Converts a value to a wstring. More... | |
static std::wstring | toWString (const long value) |
Converts a value to a wstring. More... | |
static std::wstring | toWString (const long long value) |
Converts a value to a wstring. More... | |
static std::wstring | toWString (const unsigned long long value) |
Converts a value to a wstring. More... | |
static std::wstring | toWString (const short value) |
Converts a value to a wstring. More... | |
static std::wstring | toWString (const unsigned short value) |
Converts a value to a wstring. More... | |
static std::wstring | toWString (const long unsigned int value) |
Converts a value to a wstring. More... | |
static std::wstring | toWString (const wchar_t value) |
Converts a value to a wstring. More... | |
static std::wstring | toWString (const unsigned int value, const unsigned int minimalChars) |
Converts a value to a wstring with a minimal number of characters. More... | |
static std::wstring | toWString (const std::string &value) |
Converts a value to a wstring. More... | |
static std::wstring | toWString (const std::wstring &value) |
Converts a value to a wstring. More... | |
static std::wstring | trimFront (const std::wstring &value, const wchar_t character=L' ') |
Trims the front of a string. More... | |
static std::wstring | trimBack (const std::wstring &value, const wchar_t character=L' ') |
Trims the back of a string. More... | |
static std::wstring | trim (const std::wstring &value, const wchar_t character=L' ') |
Trims the front and the back of a string. More... | |
static std::string | trimWhitespace (const std::string &text) |
Returns the specified text with all whitespace characters removed from the left and right side. More... | |
static std::wstring | trimWhitespace (const std::wstring &text) |
Returns the specified text with all whitespace characters removed from the left and right side. More... | |
static std::wstring | replaceCharacters (const std::wstring &value, const wchar_t oldCharacter, const wchar_t newCharacter) |
Replaces characters with a specified value by a new character. More... | |
static std::wstring | exchangeCharacters (const std::wstring &value, const wchar_t character0, const wchar_t character1) |
Exchanges two characters within a string. More... | |
static std::wstring | removeCharacters (const std::wstring &value, const wchar_t character) |
Removes characters with a specified value from a string. More... | |
Static Private Member Functions | |
template<typename TChar , typename T > | |
static std::basic_string< TChar > | toString (const T &value) |
Converts a value of an arbitrary primitive type into a string (supported types are: ordinal types, floating point types, bool, string, char arrays) More... | |
template<typename TChar > | |
static std::basic_string< TChar > | trimWhitespaceString (const std::basic_string< TChar > &text) |
Returns the specified text with all whitespace characters removed from the left and right side. More... | |
This class provides string convert functionalities.
|
static |
Exchanges two characters within a string.
value | The string in which the character will be exchanged |
character0 | One of both characters to exchange |
character1 | The second character to exchange |
|
static |
Exchanges two characters within a string.
value | The string in which the character will be exchanged |
character0 | One of both characters to exchange |
character1 | The second character to exchange |
|
static |
Inserts a specified character into a string in regular intervals.
The specified character will neither be added to the front of the string nor to the end of the string.
This function can be used e.g., to add (thousands) separators to integer values.
value | The string to which the character will be inserted |
character | The character to be inserted |
interval | The number of string characters that will stay together (between each block the specified character will be inserted), with range [0, infinity) |
startAtFront | True, to start at the front of the string; False, to start at the back of the string |
TChar | The data type of the character of the string |
|
static |
Returns whether a given string stores a boolean value.
A boolean value must be 'true' or 'false'.
Any beginning or ending white space will violate the value conditions, therefore provide a trimmed string value.
stringValue | String to be checked |
matchCase | True, if the sting must match the lower case, otherwise any case is accepted |
acceptInteger | True, if '1' and '0' will be accepted as 'true' and 'false' |
value | Optional the value is returned |
|
static |
Returns whether a given string stores an hexadecimal value with up to 64 bits.
The hexadecimal value may have a prefix "0x" and may contain up to 16 characters of digits or letters ['a', 'f'] or ['A' - 'F']. Any beginning or ending white space will violate the value conditions, therefore provide a trimmed string value.
hexString | The hexadecimal value given as string, must be valid |
length | The number of characters the given string contains, with range [1, 18] |
needPrefix | True, to accept hexadecimal values only if they start with "0x"; False, to accept also hexadecimal values with the prefix |
value | Optional resulting decimal value of the given hexadecimal value; nullptr, if the value is not of interest |
|
static |
Returns whether a given string stores a 32bit integer value.
An integer value may have a prefix sign ('+' or '-') followed by digits.
Any beginning or ending white space will violate the value conditions, therefore provide a trimmed string value.
stringValue | String to be checked |
value | Optional the value is returned |
|
static |
Returns whether a given string stores a number value.
Any beginning or ending white space will violate the value conditions, therefore provide a trimmed string value.
stringValue | String to be checked |
acceptInteger | True, if also strict integers will be accepted |
value | Optional the value is returned |
|
static |
Returns whether a given string stores an unsigned 64bit integer value.
An integer value may have a prefix sign ('+') followed by digits.
Any beginning or ending white space will violate the value conditions, therefore provide a trimmed string value.
stringValue | String to be checked |
value | Optional the value is returned |
|
static |
Removes characters with a specified value from a string.
value | The string from which the characters will be removed |
character | The character which will be removed |
|
static |
Removes characters with a specified value from a string.
value | The string from which the characters will be removed |
character | The character which will be removed |
|
static |
Replaces a sub-string inside a string with a different string.
value | The string in which the replacement will take place, can be empty |
oldString | The sub-string to be replaced, empty to replace nothing |
newString | The sub-string which will be placed at the location of the old string, can be empty |
onlyFirstOccurrence | True, to stop after the first replacement; False, to continue with the remaining string |
|
static |
Replaces characters with a specified value by a new character.
value | The string in which the character will be replaced |
oldCharacter | The character which will be replaced |
newCharacter | The character which will be set at the position of the old characters |
|
static |
Replaces characters with a specified value by a new character.
value | The string in which the character will be replaced |
oldCharacter | The character which will be replaced |
newCharacter | The character which will be set at the position of the old characters |
|
static |
Converts a value to a string with 8bit character.
value | The value to convert, may be nullptr |
|
static |
Converts a value to a string with 8bit character.
value | The value to convert |
|
static |
Converts a value to a string with 8bit character using a fixed notation.
value | The value to convert, with range (-infinity, infinity) |
precision | Optional floating-point precision field, with range [1, infinity) |
|
static |
Converts a value to a string with 8bit character using a fixed notation.
value | The value to convert, with range (-infinity, infinity) |
precision | Optional floating-point precision field, with range [1, infinity) |
|
static |
Converts a value to a string with 8bit character.
value | The value to convert |
|
static |
Converts a value to a string with 8bit character.
value | The value to convert |
|
static |
Converts a value to a string with 8bit character.
value | The value to convert |
|
static |
Converts a value to a string with 8bit character.
value | The value to convert |
|
static |
Converts a value to a string with 8bit character.
value | The value to convert |
|
static |
Converts a value to a string with 8bit character.
value | The value to convert |
|
static |
Converts a value to a string with 8bit character.
value | The value to convert |
|
static |
Converts a value to a string with 8bit character.
value | The value to convert |
|
static |
Converts a value to a string with 8bit character.
value | The value to convert |
|
static |
Converts a value to a string with a minimal number of characters.
Zero (prefix) are used to fill the missing part.
value | The value to be converted |
minimalChars | Number of minimal characters to be created |
|
static |
Converts a value to a string with 8bit character.
value | The value to convert |
|
static |
Converts a value to a string with 8bit character.
value | The value to convert |
|
static |
Converts a value to a string with 8bit character.
value | The value to convert, may be nullptr |
|
static |
Converts a value to a string with 8bit character.
value | The value to convert |
|
static |
Converts a value to a string with 8bit character as hexadecimal notation.
value | The value to convert |
upperCases | True, to use upper case characters; False, to use lower case characters |
|
static |
Converts a value to a string with 8bit character as hexadecimal notation.
value | The value to convert |
upperCases | True, to use upper case characters; False, to use lower case characters |
|
static |
Converts a value to a string with 8bit character as hexadecimal notation.
value | The value to convert |
upperCases | True, to use upper case characters; False, to use lower case characters |
|
static |
Converts a value to a string with 8bit character as hexadecimal notation.
value | The value to convert |
upperCases | True, to use upper case characters; False, to use lower case characters |
|
static |
Converts a value to a string with 8bit character as hexadecimal notation.
value | The value to convert |
upperCases | True, to use upper case characters; False, to use lower case characters |
|
static |
Converts a value to a string with 8bit character as hexadecimal notation.
value | The value to convert |
upperCases | True, to use upper case characters; False, to use lower case characters |
|
static |
Converts a value to a string with 8bit character as hexadecimal notation.
value | The value to convert |
upperCases | True, to use upper case characters; False, to use lower case characters |
|
static |
Converts memory to a string with hexadecimal notation.
data | The memory to convert, can be nullptr if size == 0 |
size | The size of the memory in bytes, with range [0, infinity) |
upperCases | True, to use upper case characters; False, to use lower case characters |
|
static |
Converts a value to a string with 8bit character as hexadecimal notation.
value | The value to convert |
upperCases | True, to use upper case characters; False, to use lower case characters |
|
static |
Converts a value to a string with 8bit character as hexadecimal notation.
value | The value to convert |
upperCases | True, to use upper case characters; False, to use lower case characters |
|
static |
Converts a value to a string with 8bit character as hexadecimal notation.
value | The value to convert |
upperCases | True, to use upper case characters; False, to use lower case characters |
|
static |
Converts a value to a string with 8bit character as hexadecimal notation.
value | The value to convert |
upperCases | True, to use upper case characters; False, to use lower case characters |
|
static |
Converts memory to a string with hexadecimal notation in a reverse order.
data | The memory to convert, can be nullptr if size == 0 |
size | The size of the memory in bytes, with range [0, infinity) |
upperCases | True, to use upper case characters; False, to use lower case characters |
|
static |
Converts a value to a string with 8bit character using a scientific notation.
value | The value to convert, with range (-infinity, infinity) |
precision | Optional floating-point precision field, with range [1, infinity) |
|
static |
Converts a value to a string with 8bit character using a scientific notation.
value | The value to convert, with range (-infinity, infinity) |
precision | Optional floating-point precision field, with range [1, infinity) |
|
static |
Converts a string to a string with lower characters only.
value | String value to convert, only containing ASCII characters |
|
inline |
|
staticprivate |
Converts a value of an arbitrary primitive type into a string (supported types are: ordinal types, floating point types, bool, string, char arrays)
value | The value that is to be converted |
TChar | Data type of the characters of the C++ String |
T | Type of value |
|
static |
Converts a string to a string with upper characters only.
value | String value to convert, only containing ASCII characters |
|
static |
Converts a value to a wstring.
value | The value to convert, may be nullptr |
|
static |
Converts a value to a wstring.
value | The value to convert |
|
static |
Converts a value to a wstring using a fixed notation.
value | The value to convert, with range (-infinity, infinity) |
precision | Optional floating-point precision field, with range [1, infinity) |
|
static |
Converts a value to a wstring using a fixed notation.
value | The value to convert, with range (-infinity, infinity) |
precision | Optional floating-point precision field, with range [1, infinity) |
|
static |
Converts a value to a wstring.
value | The value to convert |
|
static |
Converts a value to a wstring.
value | The value to convert |
|
static |
Converts a value to a wstring.
value | The value to convert |
|
static |
Converts a value to a wstring.
value | The value to convert |
|
static |
Converts a value to a wstring.
value | The value to convert |
|
static |
Converts a value to a wstring.
value | The value to convert |
|
static |
Converts a value to a wstring.
value | The value to convert |
|
static |
Converts a value to a wstring.
value | The value to convert |
|
static |
Converts a value to a wstring.
value | The value to convert |
|
static |
Converts a value to a wstring with a minimal number of characters.
Zero (prefix) are used to fill the missing part.
value | The value to be converted |
minimalChars | Number of minimal characters to be created |
|
static |
Converts a value to a wstring.
value | The value to convert |
|
static |
Converts a value to a wstring.
value | The value to convert, may be nullptr |
|
static |
Converts a value to a wstring.
value | The value to convert |
|
static |
Converts a value to a wstring.
value | The value to convert, may be nullptr |
|
static |
Converts a value to a wstring.
value | The value to convert |
|
static |
Converts a value to a wstring using a scientific notation.
value | The value to convert, with range (-infinity, infinity) |
precision | Optional floating-point precision field, with range [1, infinity) |
|
static |
Converts a value to a wstring using a scientific notation.
value | The value to convert, with range (-infinity, infinity) |
precision | Optional floating-point precision field, with range [1, infinity) |
|
static |
Trims the front and the back of a string.
value | String to be trimmed |
character | Trimming character |
|
static |
Trims the front and the back of a string.
value | String to be trimmed |
character | Trimming character |
|
static |
Trims the back of a string.
value | String to be trimmed at the back |
character | Trimming character |
|
static |
Trims the back of a string.
value | String to be trimmed at the back |
character | Trimming character |
|
static |
Trims the front of a string.
value | String to be trimmed at the front |
character | Trimming character |
|
static |
Trims the front of a string.
value | String to be trimmed at the front |
character | Trimming character |
|
static |
Returns the specified text with all whitespace characters removed from the left and right side.
Characters considered whitespace are:
text | The text string to be trimmed |
|
static |
Returns the specified text with all whitespace characters removed from the left and right side.
Characters considered whitespace are:
text | The text string to be trimmed |
|
staticprivate |
Returns the specified text with all whitespace characters removed from the left and right side.
Characters considered whitespace are:
text | The text string to be trimmed |
TChar | Character data type of specified string, either use char or wchar_t |