Ocean
Ocean::String Class Reference

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...
 

Detailed Description

This class provides string convert functionalities.

Member Function Documentation

◆ exchangeCharacters() [1/2]

static std::string Ocean::String::exchangeCharacters ( const std::string &  value,
const char  character0,
const char  character1 
)
static

Exchanges two characters within a string.

Parameters
valueThe string in which the character will be exchanged
character0One of both characters to exchange
character1The second character to exchange
Returns
The resulting string with exchanged characters
See also
replaceCharacters(), removeCharacters().

◆ exchangeCharacters() [2/2]

static std::wstring Ocean::String::exchangeCharacters ( const std::wstring &  value,
const wchar_t  character0,
const wchar_t  character1 
)
static

Exchanges two characters within a string.

Parameters
valueThe string in which the character will be exchanged
character0One of both characters to exchange
character1The second character to exchange
Returns
The resulting string with exchanged characters
See also
replaceCharacters(), removeCharacters().

◆ insertCharacter()

template<typename TChar >
std::basic_string< TChar > Ocean::String::insertCharacter ( const std::basic_string< TChar > &  value,
const TChar &  character,
size_t  interval,
bool  startAtFront 
)
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.

Parameters
valueThe string to which the character will be inserted
characterThe character to be inserted
intervalThe number of string characters that will stay together (between each block the specified character will be inserted), with range [0, infinity)
startAtFrontTrue, to start at the front of the string; False, to start at the back of the string
Returns
The modified string
Template Parameters
TCharThe data type of the character of the string

◆ isBoolean()

static bool Ocean::String::isBoolean ( const std::string &  stringValue,
const bool  matchCase = true,
const bool  acceptInteger = false,
bool *  value = nullptr 
)
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.

Parameters
stringValueString to be checked
matchCaseTrue, if the sting must match the lower case, otherwise any case is accepted
acceptIntegerTrue, if '1' and '0' will be accepted as 'true' and 'false'
valueOptional the value is returned
Returns
True, if so

◆ isHexValue64()

static bool Ocean::String::isHexValue64 ( const char *  hexString,
size_t  length,
const bool  needPrefix = false,
unsigned long long *  value = nullptr 
)
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.

Parameters
hexStringThe hexadecimal value given as string, must be valid
lengthThe number of characters the given string contains, with range [1, 18]
needPrefixTrue, to accept hexadecimal values only if they start with "0x"; False, to accept also hexadecimal values with the prefix
valueOptional resulting decimal value of the given hexadecimal value; nullptr, if the value is not of interest
Returns
True, if so

◆ isInteger32()

static bool Ocean::String::isInteger32 ( const std::string &  stringValue,
int32_t *  value = nullptr 
)
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.

Parameters
stringValueString to be checked
valueOptional the value is returned
Returns
True, if so

◆ isNumber()

static bool Ocean::String::isNumber ( const std::string &  stringValue,
const bool  acceptInteger = false,
double *  value = nullptr 
)
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.

Parameters
stringValueString to be checked
acceptIntegerTrue, if also strict integers will be accepted
valueOptional the value is returned
Returns
True, if so

◆ isUnsignedInteger64()

static bool Ocean::String::isUnsignedInteger64 ( const std::string &  stringValue,
uint64_t *  value = nullptr 
)
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.

Parameters
stringValueString to be checked
valueOptional the value is returned
Returns
True, if so

◆ removeCharacters() [1/2]

static std::string Ocean::String::removeCharacters ( const std::string &  value,
const char  character 
)
static

Removes characters with a specified value from a string.

Parameters
valueThe string from which the characters will be removed
characterThe character which will be removed
Returns
The resulting string without the specified character
See also
replaceCharacters(), exchangeCharacters().

◆ removeCharacters() [2/2]

static std::wstring Ocean::String::removeCharacters ( const std::wstring &  value,
const wchar_t  character 
)
static

Removes characters with a specified value from a string.

Parameters
valueThe string from which the characters will be removed
characterThe character which will be removed
Returns
The resulting string without the specified character
See also
replaceCharacters(), exchangeCharacters().

◆ replace()

static std::string Ocean::String::replace ( std::string &&  value,
const std::string &  oldString,
const std::string &  newString,
const bool  onlyFirstOccurrence 
)
static

Replaces a sub-string inside a string with a different string.

Parameters
valueThe string in which the replacement will take place, can be empty
oldStringThe sub-string to be replaced, empty to replace nothing
newStringThe sub-string which will be placed at the location of the old string, can be empty
onlyFirstOccurrenceTrue, to stop after the first replacement; False, to continue with the remaining string
Returns
The resulting string with replaced sub-string(s)

◆ replaceCharacters() [1/2]

static std::string Ocean::String::replaceCharacters ( const std::string &  value,
const char  oldCharacter,
const char  newCharacter 
)
static

Replaces characters with a specified value by a new character.

Parameters
valueThe string in which the character will be replaced
oldCharacterThe character which will be replaced
newCharacterThe character which will be set at the position of the old characters
Returns
The resulting string which replaced characters
See also
exchangeCharacters(), removeCharacters().

◆ replaceCharacters() [2/2]

static std::wstring Ocean::String::replaceCharacters ( const std::wstring &  value,
const wchar_t  oldCharacter,
const wchar_t  newCharacter 
)
static

Replaces characters with a specified value by a new character.

Parameters
valueThe string in which the character will be replaced
oldCharacterThe character which will be replaced
newCharacterThe character which will be set at the position of the old characters
Returns
The resulting string which replaced characters
See also
exchangeCharacters(), removeCharacters().

◆ toAString() [1/18]

static std::string Ocean::String::toAString ( const char *  value)
static

Converts a value to a string with 8bit character.

Parameters
valueThe value to convert, may be nullptr
Returns
Converted string

◆ toAString() [2/18]

static std::string Ocean::String::toAString ( const char  value)
static

Converts a value to a string with 8bit character.

Parameters
valueThe value to convert
Returns
Converted string

◆ toAString() [3/18]

static std::string Ocean::String::toAString ( const double  value,
const unsigned int  precision = 5u 
)
static

Converts a value to a string with 8bit character using a fixed notation.

Parameters
valueThe value to convert, with range (-infinity, infinity)
precisionOptional floating-point precision field, with range [1, infinity)
Returns
Converted string

◆ toAString() [4/18]

static std::string Ocean::String::toAString ( const float  value,
const unsigned int  precision = 5u 
)
static

Converts a value to a string with 8bit character using a fixed notation.

Parameters
valueThe value to convert, with range (-infinity, infinity)
precisionOptional floating-point precision field, with range [1, infinity)
Returns
Converted string

◆ toAString() [5/18]

static std::string Ocean::String::toAString ( const int  value)
static

Converts a value to a string with 8bit character.

Parameters
valueThe value to convert
Returns
Converted string

◆ toAString() [6/18]

static std::string Ocean::String::toAString ( const long long  value)
static

Converts a value to a string with 8bit character.

Parameters
valueThe value to convert
Returns
Converted string

◆ toAString() [7/18]

static std::string Ocean::String::toAString ( const long unsigned int  value)
static

Converts a value to a string with 8bit character.

Parameters
valueThe value to convert
Returns
Converted string

◆ toAString() [8/18]

static std::string Ocean::String::toAString ( const long  value)
static

Converts a value to a string with 8bit character.

Parameters
valueThe value to convert
Returns
Converted string

◆ toAString() [9/18]

static std::string Ocean::String::toAString ( const short  value)
static

Converts a value to a string with 8bit character.

Parameters
valueThe value to convert
Returns
Converted string

◆ toAString() [10/18]

static std::string Ocean::String::toAString ( const std::string &  value)
static

Converts a value to a string with 8bit character.

Parameters
valueThe value to convert
Returns
Converted string

◆ toAString() [11/18]

static std::string Ocean::String::toAString ( const std::wstring &  value)
static

Converts a value to a string with 8bit character.

Parameters
valueThe value to convert
Returns
Converted string

◆ toAString() [12/18]

static std::string Ocean::String::toAString ( const unsigned char  value)
static

Converts a value to a string with 8bit character.

Parameters
valueThe value to convert
Returns
Converted string

◆ toAString() [13/18]

static std::string Ocean::String::toAString ( const unsigned int  value)
static

Converts a value to a string with 8bit character.

Parameters
valueThe value to convert
Returns
Converted string

◆ toAString() [14/18]

static std::string Ocean::String::toAString ( const unsigned int  value,
const unsigned int  minimalChars 
)
static

Converts a value to a string with a minimal number of characters.

Zero (prefix) are used to fill the missing part.

Parameters
valueThe value to be converted
minimalCharsNumber of minimal characters to be created
Returns
Converted string

◆ toAString() [15/18]

static std::string Ocean::String::toAString ( const unsigned long long  value)
static

Converts a value to a string with 8bit character.

Parameters
valueThe value to convert
Returns
Converted string

◆ toAString() [16/18]

static std::string Ocean::String::toAString ( const unsigned short  value)
static

Converts a value to a string with 8bit character.

Parameters
valueThe value to convert
Returns
Converted string

◆ toAString() [17/18]

static std::string Ocean::String::toAString ( const wchar_t *  value)
static

Converts a value to a string with 8bit character.

Parameters
valueThe value to convert, may be nullptr
Returns
Converted string

◆ toAString() [18/18]

static std::string Ocean::String::toAString ( const wchar_t  value)
static

Converts a value to a string with 8bit character.

Parameters
valueThe value to convert
Returns
Converted string

◆ toAStringHex() [1/12]

static std::string Ocean::String::toAStringHex ( const char  value,
const bool  upperCases = true 
)
static

Converts a value to a string with 8bit character as hexadecimal notation.

Parameters
valueThe value to convert
upperCasesTrue, to use upper case characters; False, to use lower case characters
Returns
Converted string

◆ toAStringHex() [2/12]

static std::string Ocean::String::toAStringHex ( const double  value,
const bool  upperCases = true 
)
static

Converts a value to a string with 8bit character as hexadecimal notation.

Parameters
valueThe value to convert
upperCasesTrue, to use upper case characters; False, to use lower case characters
Returns
Converted string

◆ toAStringHex() [3/12]

static std::string Ocean::String::toAStringHex ( const float  value,
const bool  upperCases = true 
)
static

Converts a value to a string with 8bit character as hexadecimal notation.

Parameters
valueThe value to convert
upperCasesTrue, to use upper case characters; False, to use lower case characters
Returns
Converted string

◆ toAStringHex() [4/12]

static std::string Ocean::String::toAStringHex ( const int  value,
const bool  upperCases = true 
)
static

Converts a value to a string with 8bit character as hexadecimal notation.

Parameters
valueThe value to convert
upperCasesTrue, to use upper case characters; False, to use lower case characters
Returns
Converted string

◆ toAStringHex() [5/12]

static std::string Ocean::String::toAStringHex ( const long long  value,
const bool  upperCases = true 
)
static

Converts a value to a string with 8bit character as hexadecimal notation.

Parameters
valueThe value to convert
upperCasesTrue, to use upper case characters; False, to use lower case characters
Returns
Converted string

◆ toAStringHex() [6/12]

static std::string Ocean::String::toAStringHex ( const long unsigned int  value,
const bool  upperCases = true 
)
static

Converts a value to a string with 8bit character as hexadecimal notation.

Parameters
valueThe value to convert
upperCasesTrue, to use upper case characters; False, to use lower case characters
Returns
Converted string

◆ toAStringHex() [7/12]

static std::string Ocean::String::toAStringHex ( const short  value,
const bool  upperCases = true 
)
static

Converts a value to a string with 8bit character as hexadecimal notation.

Parameters
valueThe value to convert
upperCasesTrue, to use upper case characters; False, to use lower case characters
Returns
Converted string

◆ toAStringHex() [8/12]

static std::string Ocean::String::toAStringHex ( const uint8_t *  data,
const size_t  size,
const bool  upperCases = true 
)
static

Converts memory to a string with hexadecimal notation.

Parameters
dataThe memory to convert, can be nullptr if size == 0
sizeThe size of the memory in bytes, with range [0, infinity)
upperCasesTrue, to use upper case characters; False, to use lower case characters
Returns
Converted string

◆ toAStringHex() [9/12]

static std::string Ocean::String::toAStringHex ( const unsigned char  value,
const bool  upperCases = true 
)
static

Converts a value to a string with 8bit character as hexadecimal notation.

Parameters
valueThe value to convert
upperCasesTrue, to use upper case characters; False, to use lower case characters
Returns
Converted string

◆ toAStringHex() [10/12]

static std::string Ocean::String::toAStringHex ( const unsigned int  value,
const bool  upperCases = true 
)
static

Converts a value to a string with 8bit character as hexadecimal notation.

Parameters
valueThe value to convert
upperCasesTrue, to use upper case characters; False, to use lower case characters
Returns
Converted string

◆ toAStringHex() [11/12]

static std::string Ocean::String::toAStringHex ( const unsigned long long  value,
const bool  upperCases = true 
)
static

Converts a value to a string with 8bit character as hexadecimal notation.

Parameters
valueThe value to convert
upperCasesTrue, to use upper case characters; False, to use lower case characters
Returns
Converted string

◆ toAStringHex() [12/12]

static std::string Ocean::String::toAStringHex ( const unsigned short  value,
const bool  upperCases = true 
)
static

Converts a value to a string with 8bit character as hexadecimal notation.

Parameters
valueThe value to convert
upperCasesTrue, to use upper case characters; False, to use lower case characters
Returns
Converted string

◆ toAStringHexReverse()

static std::string Ocean::String::toAStringHexReverse ( const uint8_t *  data,
const size_t  size,
const bool  upperCases = true 
)
static

Converts memory to a string with hexadecimal notation in a reverse order.

Parameters
dataThe memory to convert, can be nullptr if size == 0
sizeThe size of the memory in bytes, with range [0, infinity)
upperCasesTrue, to use upper case characters; False, to use lower case characters
Returns
Converted string

◆ toAStringScientific() [1/2]

static std::string Ocean::String::toAStringScientific ( const double  value,
const unsigned int  precision = 5u 
)
static

Converts a value to a string with 8bit character using a scientific notation.

Parameters
valueThe value to convert, with range (-infinity, infinity)
precisionOptional floating-point precision field, with range [1, infinity)
Returns
Converted string

◆ toAStringScientific() [2/2]

static std::string Ocean::String::toAStringScientific ( const float  value,
const unsigned int  precision = 5u 
)
static

Converts a value to a string with 8bit character using a scientific notation.

Parameters
valueThe value to convert, with range (-infinity, infinity)
precisionOptional floating-point precision field, with range [1, infinity)
Returns
Converted string

◆ toLower()

static std::string Ocean::String::toLower ( const std::string &  value)
static

Converts a string to a string with lower characters only.

Parameters
valueString value to convert, only containing ASCII characters
Returns
Converted string.

◆ toString() [1/2]

template<>
std::wstring Ocean::String::toString ( const bool &  value)
inline

◆ toString() [2/2]

template<typename TChar , typename T >
std::basic_string< TChar > Ocean::String::toString ( const T &  value)
staticprivate

Converts a value of an arbitrary primitive type into a string (supported types are: ordinal types, floating point types, bool, string, char arrays)

Parameters
valueThe value that is to be converted
Returns
Text representation of value
Template Parameters
TCharData type of the characters of the C++ String
TType of value

◆ toUpper()

static std::string Ocean::String::toUpper ( const std::string &  value)
static

Converts a string to a string with upper characters only.

Parameters
valueString value to convert, only containing ASCII characters
Returns
Converted string.

◆ toWString() [1/19]

static std::wstring Ocean::String::toWString ( const char *  value)
static

Converts a value to a wstring.

Parameters
valueThe value to convert, may be nullptr
Returns
Converted string

◆ toWString() [2/19]

static std::wstring Ocean::String::toWString ( const char  value)
static

Converts a value to a wstring.

Parameters
valueThe value to convert
Returns
Converted string

◆ toWString() [3/19]

static std::wstring Ocean::String::toWString ( const double  value,
const unsigned int  precision = 5u 
)
static

Converts a value to a wstring using a fixed notation.

Parameters
valueThe value to convert, with range (-infinity, infinity)
precisionOptional floating-point precision field, with range [1, infinity)
Returns
Converted string

◆ toWString() [4/19]

static std::wstring Ocean::String::toWString ( const float  value,
const unsigned int  precision = 5u 
)
static

Converts a value to a wstring using a fixed notation.

Parameters
valueThe value to convert, with range (-infinity, infinity)
precisionOptional floating-point precision field, with range [1, infinity)
Returns
Converted string

◆ toWString() [5/19]

static std::wstring Ocean::String::toWString ( const int  value)
static

Converts a value to a wstring.

Parameters
valueThe value to convert
Returns
Converted string

◆ toWString() [6/19]

static std::wstring Ocean::String::toWString ( const long long  value)
static

Converts a value to a wstring.

Parameters
valueThe value to convert
Returns
Converted string

◆ toWString() [7/19]

static std::wstring Ocean::String::toWString ( const long unsigned int  value)
static

Converts a value to a wstring.

Parameters
valueThe value to convert
Returns
Converted string

◆ toWString() [8/19]

static std::wstring Ocean::String::toWString ( const long  value)
static

Converts a value to a wstring.

Parameters
valueThe value to convert
Returns
Converted string

◆ toWString() [9/19]

static std::wstring Ocean::String::toWString ( const short  value)
static

Converts a value to a wstring.

Parameters
valueThe value to convert
Returns
Converted string

◆ toWString() [10/19]

static std::wstring Ocean::String::toWString ( const std::string &  value)
static

Converts a value to a wstring.

Parameters
valueThe value to convert
Returns
Converted string

◆ toWString() [11/19]

static std::wstring Ocean::String::toWString ( const std::wstring &  value)
static

Converts a value to a wstring.

Parameters
valueThe value to convert
Returns
Converted string

◆ toWString() [12/19]

static std::wstring Ocean::String::toWString ( const unsigned char  value)
static

Converts a value to a wstring.

Parameters
valueThe value to convert
Returns
Converted string

◆ toWString() [13/19]

static std::wstring Ocean::String::toWString ( const unsigned int  value)
static

Converts a value to a wstring.

Parameters
valueThe value to convert
Returns
Converted string

◆ toWString() [14/19]

static std::wstring Ocean::String::toWString ( const unsigned int  value,
const unsigned int  minimalChars 
)
static

Converts a value to a wstring with a minimal number of characters.

Zero (prefix) are used to fill the missing part.

Parameters
valueThe value to be converted
minimalCharsNumber of minimal characters to be created
Returns
Converted string

◆ toWString() [15/19]

static std::wstring Ocean::String::toWString ( const unsigned long long  value)
static

Converts a value to a wstring.

Parameters
valueThe value to convert
Returns
Converted string

◆ toWString() [16/19]

static std::wstring Ocean::String::toWString ( const unsigned short *  value)
static

Converts a value to a wstring.

Parameters
valueThe value to convert, may be nullptr
Returns
Converted string

◆ toWString() [17/19]

static std::wstring Ocean::String::toWString ( const unsigned short  value)
static

Converts a value to a wstring.

Parameters
valueThe value to convert
Returns
Converted string

◆ toWString() [18/19]

static std::wstring Ocean::String::toWString ( const wchar_t *  value)
static

Converts a value to a wstring.

Parameters
valueThe value to convert, may be nullptr
Returns
Converted string

◆ toWString() [19/19]

static std::wstring Ocean::String::toWString ( const wchar_t  value)
static

Converts a value to a wstring.

Parameters
valueThe value to convert
Returns
Converted string

◆ toWStringScientific() [1/2]

static std::wstring Ocean::String::toWStringScientific ( const double  value,
const unsigned int  precision = 5u 
)
static

Converts a value to a wstring using a scientific notation.

Parameters
valueThe value to convert, with range (-infinity, infinity)
precisionOptional floating-point precision field, with range [1, infinity)
Returns
Converted string

◆ toWStringScientific() [2/2]

static std::wstring Ocean::String::toWStringScientific ( const float  value,
const unsigned int  precision = 5u 
)
static

Converts a value to a wstring using a scientific notation.

Parameters
valueThe value to convert, with range (-infinity, infinity)
precisionOptional floating-point precision field, with range [1, infinity)
Returns
Converted string

◆ trim() [1/2]

static std::string Ocean::String::trim ( const std::string &  value,
const char  character = ' ' 
)
static

Trims the front and the back of a string.

Parameters
valueString to be trimmed
characterTrimming character
Returns
Trimmed string

◆ trim() [2/2]

static std::wstring Ocean::String::trim ( const std::wstring &  value,
const wchar_t  character = L' ' 
)
static

Trims the front and the back of a string.

Parameters
valueString to be trimmed
characterTrimming character
Returns
Trimmed string

◆ trimBack() [1/2]

static std::string Ocean::String::trimBack ( const std::string &  value,
const char  character = ' ' 
)
static

Trims the back of a string.

Parameters
valueString to be trimmed at the back
characterTrimming character
Returns
Trimmed string

◆ trimBack() [2/2]

static std::wstring Ocean::String::trimBack ( const std::wstring &  value,
const wchar_t  character = L' ' 
)
static

Trims the back of a string.

Parameters
valueString to be trimmed at the back
characterTrimming character
Returns
Trimmed string

◆ trimFront() [1/2]

static std::string Ocean::String::trimFront ( const std::string &  value,
const char  character = ' ' 
)
static

Trims the front of a string.

Parameters
valueString to be trimmed at the front
characterTrimming character
Returns
Trimmed string

◆ trimFront() [2/2]

static std::wstring Ocean::String::trimFront ( const std::wstring &  value,
const wchar_t  character = L' ' 
)
static

Trims the front of a string.

Parameters
valueString to be trimmed at the front
characterTrimming character
Returns
Trimmed string

◆ trimWhitespace() [1/2]

static std::string Ocean::String::trimWhitespace ( const std::string &  text)
static

Returns the specified text with all whitespace characters removed from the left and right side.

Characters considered whitespace are:

  • ' ' (0x20) space (SPC)
  • '\t' (0x09) horizontal tab (TAB)
  • '\n' (0x0a) newline (LF)
  • '\v' (0x0b) vertical tab (VT)
  • '\f' (0x0c) feed (FF)
  • '\r' (0x0d) carriage return (CR)
  • '\0' (0x00) the null terminator (NUL), for every null-terminator character at position '< std::string::size()' Further, the string trimmed string will not contain a null-terminator character in the middle of the string at position '< std::string::size()',
    the only null terminator character will be at the end of the string at position 'std::string::size()'.
    Parameters
    textThe text string to be trimmed
    Returns
    Trimmed text string
    See also
    trimWhitespaceString

◆ trimWhitespace() [2/2]

static std::wstring Ocean::String::trimWhitespace ( const std::wstring &  text)
static

Returns the specified text with all whitespace characters removed from the left and right side.

Characters considered whitespace are:

  • ' ' (0x20) space (SPC)
  • '\t' (0x09) horizontal tab (TAB)
  • '\n' (0x0a) newline (LF)
  • '\v' (0x0b) vertical tab (VT)
  • '\f' (0x0c) feed (FF)
  • '\r' (0x0d) carriage return (CR)
  • '\0' (0x00) the null terminator (NUL), for every null-terminator character at position '< std::string::size()' Further, the string trimmed string will not contain a null-terminator character in the middle of the string at position '< std::string::size()',
    the only null terminator character will be at the end of the string at position 'std::string::size()'.
    Parameters
    textThe text string to be trimmed
    Returns
    Trimmed text string
    See also
    trimWhitespaceString

◆ trimWhitespaceString()

template<typename TChar >
static std::basic_string<TChar> Ocean::String::trimWhitespaceString ( const std::basic_string< TChar > &  text)
staticprivate

Returns the specified text with all whitespace characters removed from the left and right side.

Characters considered whitespace are:

  • ' ' (0x20) space (SPC)
  • '\t' (0x09) horizontal tab (TAB)
  • '\n' (0x0a) newline (LF)
  • '\v' (0x0b) vertical tab (VT)
  • '\f' (0x0c) feed (FF)
  • '\r' (0x0d) carriage return (CR)
  • '\0' (0x00) the null terminator (NUL), for every null-terminator character at position '< std::string::size()' Further, the string trimmed string will not contain a null-terminator character in the middle of the string at position '< std::string::size()',
    the only null terminator character will be at the end of the string at position 'std::string::size()'.
    Parameters
    textThe text string to be trimmed
    Template Parameters
    TCharCharacter data type of specified string, either use char or wchar_t
    Returns
    Trimmed text string

The documentation for this class was generated from the following file: