C++ Utilities
4.17.0
Useful C++ classes and routines such as argument parser, IO and conversion utilities
|
Contains several functions providing conversions between different data types. More...
Namespaces | |
BE | |
Encapsulates binary conversion functions using the big endian byte order. | |
LE | |
Encapsulates binary conversion functions using the little endian byte order. | |
Classes | |
class | ConversionException |
The ConversionException class is thrown by the various conversion functions of this library when a conversion error occurs. More... | |
struct | StringDataDeleter |
The StringDataDeleter struct deletes the data of a StringData instance. More... | |
class | Widen |
Converts a std::string to a wide string using the specified locale. More... | |
Typedefs | |
using | StringData = std::pair< std::unique_ptr< char[], StringDataDeleter >, std::size_t > |
Type used to return string encoding conversion result. More... | |
Enumerations | |
enum | EmptyPartsTreat { EmptyPartsTreat::Keep, EmptyPartsTreat::Omit, EmptyPartsTreat::Merge } |
Specifies the role of empty parts when splitting strings. More... | |
Functions | |
CPP_UTILITIES_EXPORT constexpr uint16 | toFixed8 (float32 float32value) |
Returns the 8.8 fixed point representation converted from the specified 32-bit floating point number. More... | |
CPP_UTILITIES_EXPORT constexpr float32 | toFloat32 (uint16 fixed8value) |
Returns a 32-bit floating point number converted from the specified 8.8 fixed point representation. More... | |
CPP_UTILITIES_EXPORT constexpr uint32 | toFixed16 (float32 float32value) |
Returns the 16.16 fixed point representation converted from the specified 32-bit floating point number. More... | |
CPP_UTILITIES_EXPORT constexpr float32 | toFloat32 (uint32 fixed16value) |
Returns a 32-bit floating point number converted from the specified 16.16 fixed point representation. More... | |
CPP_UTILITIES_EXPORT constexpr uint32 | toSynchsafeInt (uint32 normalInt) |
Returns a 32-bit synchsafe integer converted from a normal 32-bit integer. More... | |
CPP_UTILITIES_EXPORT constexpr uint32 | toNormalInt (uint32 synchsafeInt) |
Returns a normal 32-bit integer converted from a 32-bit synchsafe integer. More... | |
CPP_UTILITIES_EXPORT constexpr uint16 | swapOrder (uint16 value) |
Swaps the byte order of the specified 16-bit unsigned integer. More... | |
CPP_UTILITIES_EXPORT constexpr uint32 | swapOrder (uint32 value) |
Swaps the byte order of the specified 32-bit unsigned integer. More... | |
CPP_UTILITIES_EXPORT constexpr uint64 | swapOrder (uint64 value) |
Swaps the byte order of the specified 64-bit unsigned integer. More... | |
CPP_UTILITIES_EXPORT StringData | convertString (const char *fromCharset, const char *toCharset, const char *inputBuffer, std::size_t inputBufferSize, float outputBufferSizeFactor) |
Converts the specified string from one character set to another. More... | |
CPP_UTILITIES_EXPORT StringData | convertUtf8ToUtf16LE (const char *inputBuffer, std::size_t inputBufferSize) |
Converts the specified UTF-8 string to UTF-16 (little-endian). More... | |
CPP_UTILITIES_EXPORT StringData | convertUtf16LEToUtf8 (const char *inputBuffer, std::size_t inputBufferSize) |
Converts the specified UTF-16 (little-endian) string to UTF-8. More... | |
CPP_UTILITIES_EXPORT StringData | convertUtf8ToUtf16BE (const char *inputBuffer, std::size_t inputBufferSize) |
Converts the specified UTF-8 string to UTF-16 (big-endian). More... | |
CPP_UTILITIES_EXPORT StringData | convertUtf16BEToUtf8 (const char *inputBuffer, std::size_t inputBufferSize) |
Converts the specified UTF-16 (big-endian) string to UTF-8. More... | |
CPP_UTILITIES_EXPORT StringData | convertLatin1ToUtf8 (const char *inputBuffer, std::size_t inputBufferSize) |
Converts the specified Latin-1 string to UTF-8. More... | |
CPP_UTILITIES_EXPORT StringData | convertUtf8ToLatin1 (const char *inputBuffer, std::size_t inputBufferSize) |
Converts the specified UTF-8 string to Latin-1. More... | |
CPP_UTILITIES_EXPORT void | truncateString (string &str, char terminationChar) |
Truncates all characters after the first occurrence of the specified terminationChar and the termination character as well. More... | |
template<class Container = std::initializer_list<std::string>> | |
Container::value_type | joinStrings (const Container &strings, const typename Container::value_type &delimiter=typename Container::value_type(), bool omitEmpty=false, const typename Container::value_type &leftClosure=typename Container::value_type(), const typename Container::value_type &rightClosure=typename Container::value_type()) |
Joins the given strings using the specified delimiter. More... | |
template<class Container = std::initializer_list<std::string>> | |
std::vector< std::string > | toMultiline (const Container &arrayOfLines) |
Converts the specified arrayOfLines to a multiline string. More... | |
template<class Container = std::list<std::string>> | |
Container | splitString (const typename Container::value_type &string, const typename Container::value_type &delimiter, EmptyPartsTreat emptyPartsRole=EmptyPartsTreat::Keep, int maxParts=-1) |
Splits the given string at the specified delimiter. More... | |
template<class Container = std::list<std::string>> | |
Container | splitStringSimple (const typename Container::value_type &string, const typename Container::value_type &delimiter, int maxParts=-1) |
Splits the given string (which might also be a string view) at the specified delimiter. More... | |
template<class Container = std::vector<std::string>> | |
std::vector< std::string > | toArrayOfLines (const std::string &multilineString) |
Converts the specified multilineString to an array of lines. More... | |
template<typename StringType > | |
bool | startsWith (const StringType &str, const StringType &phrase) |
Returns whether str starts with phrase. More... | |
template<typename StringType > | |
bool | startsWith (const StringType &str, const typename StringType::value_type *phrase) |
Returns whether str starts with phrase. More... | |
template<typename StringType > | |
bool | containsSubstrings (const StringType &str, std::initializer_list< StringType > substrings) |
Returns whether str contains the specified substrings. More... | |
template<typename StringType > | |
bool | containsSubstrings (const StringType &str, std::initializer_list< const typename StringType::value_type * > substrings) |
Returns whether str contains the specified substrings. More... | |
template<typename StringType > | |
void | findAndReplace (StringType &str, const StringType &find, const StringType &replace) |
Replaces all occurences of find with relpace in the specified str. More... | |
template<typename CharType > | |
constexpr CharType | digitToChar (CharType digit) |
Returns the character representation of the specified digit. More... | |
template<typename IntegralType , class StringType = std::string, Traits::EnableIf< std::is_integral< IntegralType >, std::is_unsigned< IntegralType >> * = nullptr> | |
StringType | numberToString (IntegralType number, typename StringType::value_type base=10) |
Converts the given number to its equivalent string representation using the specified base. More... | |
template<typename FloatingType , class StringType = std::string, Traits::EnableIf< std::is_floating_point< FloatingType >> * = nullptr> | |
StringType | numberToString (FloatingType number, typename StringType::value_type base=10) |
Converts the given number to its equivalent string representation using the specified base. More... | |
template<typename CharType > | |
CharType | charToDigit (CharType character, CharType base) |
Returns number/digit of the specified character representation using the specified base. More... | |
template<typename IntegralType , typename StringType , Traits::EnableIf< std::is_integral< IntegralType >, std::is_unsigned< IntegralType >> * = nullptr> | |
IntegralType | stringToNumber (const StringType &string, typename StringType::value_type base=10) |
Converts the given string to an unsigned number assuming string uses the specified base. More... | |
template<typename FloatingType , class StringType , Traits::EnableIf< std::is_floating_point< FloatingType >> * = nullptr> | |
FloatingType | stringToNumber (const StringType &string, typename StringType::value_type base=10) |
Converts the given string to a number assuming string uses the specified base. More... | |
template<typename IntegralType , class CharType , Traits::EnableIf< std::is_integral< IntegralType >, std::is_unsigned< IntegralType >> * = nullptr> | |
IntegralType | stringToNumber (const CharType *string, unsigned char base=10) |
Converts the given null-terminated string to an unsigned numeric value using the specified base. More... | |
template<typename FloatingType , class CharType , Traits::EnableIf< std::is_floating_point< FloatingType >> * = nullptr> | |
FloatingType | stringToNumber (const CharType *string, unsigned char base=10) |
Converts the given null-terminated string to a number assuming string uses the specified base. More... | |
template<typename IntegralType , class CharType , Traits::EnableIf< std::is_integral< IntegralType >, std::is_unsigned< IntegralType >> * = nullptr> | |
IntegralType | bufferToNumber (const CharType *string, std::size_t size, unsigned char base=10) |
Converts the given string of size characters to an unsigned numeric value using the specified base. More... | |
template<typename T > | |
std::string | interpretIntegerAsString (T integer, int startOffset=0) |
Interprets the given integer at the specified position as std::string using the specified byte order. More... | |
CPP_UTILITIES_EXPORT std::string | dataSizeToString (uint64 sizeInByte, bool includeByte) |
Converts the specified data size in byte to its equivalent std::string representation. More... | |
CPP_UTILITIES_EXPORT std::string | bitrateToString (double bitrateInKbitsPerSecond, bool useIecBinaryPrefixes) |
Converts the specified bitrate in kbit/s to its equivalent std::string representation. More... | |
CPP_UTILITIES_EXPORT std::string | encodeBase64 (const byte *data, uint32 dataSize) |
Encodes the specified data to Base64. More... | |
CPP_UTILITIES_EXPORT std::pair< std::unique_ptr< byte[]>, uint32 > | decodeBase64 (const char *encodedStr, const uint32 strSize) |
Decodes the specified Base64 encoded string. More... | |
template<class StringType = std::string, class... Args> | |
StringType | tupleToString (const std::tuple< Args... > &tuple) |
Concatenates all strings hold by the specified tuple. More... | |
template<class StringType = std::string, class... Args> | |
constexpr StringType | argsToString (Args &&... args) |
template<class Tuple > | |
constexpr auto | operator% (const Tuple &lhs, const std::string &rhs) -> decltype(std::tuple_cat(lhs, std::make_tuple(&rhs))) |
Allows construction of string-tuples via %-operator, eg. More... | |
template<class Tuple > | |
constexpr auto | operator% (const Tuple &lhs, const char *rhs) -> decltype(std::tuple_cat(lhs, std::make_tuple(rhs))) |
Allows construction of string-tuples via %-operator, eg. More... | |
template<class Tuple , typename IntegralType , Traits::EnableIf< std::is_integral< IntegralType >> * = nullptr> | |
constexpr auto | operator% (const Tuple &lhs, IntegralType rhs) -> decltype(std::tuple_cat(lhs, std::make_tuple(rhs))) |
Allows construction of string-tuples via %-operator, eg. More... | |
constexpr auto | operator% (const std::string &lhs, const std::string &rhs) -> decltype(std::make_tuple(&lhs, &rhs)) |
Allows construction of string-tuples via %-operator, eg. More... | |
constexpr auto | operator% (const char *lhs, const std::string &rhs) -> decltype(std::make_tuple(lhs, &rhs)) |
Allows construction of string-tuples via %-operator, eg. More... | |
constexpr auto | operator% (const std::string &lhs, const char *rhs) -> decltype(std::make_tuple(&lhs, rhs)) |
Allows construction of string-tuples via %-operator, eg. More... | |
constexpr auto | operator% (const std::string &lhs, char rhs) -> decltype(std::make_tuple(&lhs, rhs)) |
Allows construction of string-tuples via %-operator, eg. More... | |
constexpr auto | operator% (char lhs, const std::string &rhs) -> decltype(std::make_tuple(lhs, &rhs)) |
Allows construction of string-tuples via %-operator, eg. More... | |
template<class Tuple , Traits::EnableIf< Traits::IsSpecializationOf< Tuple, std::tuple >> * = nullptr> | |
std::string | operator+ (const Tuple &lhs, const std::string &rhs) |
Allows construction of final string from previously constructed string-tuple and trailing string via +-operator. More... | |
template<class Tuple , Traits::EnableIf< Traits::IsSpecializationOf< Tuple, std::tuple >> * = nullptr> | |
std::string | operator+ (const Tuple &lhs, const char *rhs) |
Allows construction of final string from previously constructed string-tuple and trailing string via +-operator. More... | |
template<class Tuple , typename IntegralType , Traits::EnableIf< Traits::IsSpecializationOf< Tuple, std::tuple >, std::is_integral< IntegralType >> * = nullptr> | |
std::string | operator+ (const Tuple &lhs, IntegralType rhs) |
Allows construction of final string from previously constructed string-tuple and trailing char via +-operator. More... | |
Contains several functions providing conversions between different data types.
binaryconversion.h declares functions which convert base data types to an array of bytes and vice versa. stringconversion.h declares different functions around string conversion such as converting a number to a string and vice versa.
using ConversionUtilities::StringData = typedef std::pair<std::unique_ptr<char[], StringDataDeleter>, std::size_t> |
Type used to return string encoding conversion result.
Definition at line 38 of file stringconversion.h.
|
strong |
Specifies the role of empty parts when splitting strings.
Enumerator | |
---|---|
Keep | empty parts are kept |
Omit | empty parts are omitted |
Merge | empty parts are omitted but cause the adjacent parts being joined using the delimiter |
Definition at line 119 of file stringconversion.h.
constexpr StringType ConversionUtilities::argsToString | ( | Args &&... | args | ) |
Definition at line 147 of file stringbuilder.h.
string ConversionUtilities::bitrateToString | ( | double | bitrateInKbitsPerSecond, |
bool | useIecBinaryPrefixes | ||
) |
Converts the specified bitrate in kbit/s to its equivalent std::string representation.
The unit with appropriate binary prefix will be appended.
bitrateInKbitsPerSecond | Specifies the bitrate in kbit/s. |
useIecBinaryPrefixes | Indicates whether IEC binary prefixes should be used (eg. KiB/s). |
Definition at line 284 of file stringconversion.cpp.
IntegralType ConversionUtilities::bufferToNumber | ( | const CharType * | string, |
std::size_t | size, | ||
unsigned char | base = 10 |
||
) |
Converts the given string of size characters to an unsigned numeric value using the specified base.
Converts the given string of size characters to a signed numeric value using the specified base.
IntegralType | The data type used to store the converted value. |
CharType | The character type. |
A | ConversionException will be thrown if the provided string is not a valid number. |
Definition at line 528 of file stringconversion.h.
CharType ConversionUtilities::charToDigit | ( | CharType | character, |
CharType | base | ||
) |
Returns number/digit of the specified character representation using the specified base.
A | ConversionException will be thrown if the provided character does not represent a valid digit for the specified base. |
Definition at line 368 of file stringconversion.h.
bool ConversionUtilities::containsSubstrings | ( | const StringType & | str, |
std::initializer_list< StringType > | substrings | ||
) |
Returns whether str contains the specified substrings.
Definition at line 244 of file stringconversion.h.
bool ConversionUtilities::containsSubstrings | ( | const StringType & | str, |
std::initializer_list< const typename StringType::value_type * > | substrings | ||
) |
Returns whether str contains the specified substrings.
Definition at line 261 of file stringconversion.h.
StringData ConversionUtilities::convertLatin1ToUtf8 | ( | const char * | inputBuffer, |
std::size_t | inputBufferSize | ||
) |
Converts the specified Latin-1 string to UTF-8.
Definition at line 185 of file stringconversion.cpp.
StringData ConversionUtilities::convertString | ( | const char * | fromCharset, |
const char * | toCharset, | ||
const char * | inputBuffer, | ||
std::size_t | inputBufferSize, | ||
float | outputBufferSizeFactor | ||
) |
Converts the specified string from one character set to another.
Definition at line 140 of file stringconversion.cpp.
StringData ConversionUtilities::convertUtf16BEToUtf8 | ( | const char * | inputBuffer, |
std::size_t | inputBufferSize | ||
) |
Converts the specified UTF-16 (big-endian) string to UTF-8.
Definition at line 176 of file stringconversion.cpp.
StringData ConversionUtilities::convertUtf16LEToUtf8 | ( | const char * | inputBuffer, |
std::size_t | inputBufferSize | ||
) |
Converts the specified UTF-16 (little-endian) string to UTF-8.
Definition at line 158 of file stringconversion.cpp.
StringData ConversionUtilities::convertUtf8ToLatin1 | ( | const char * | inputBuffer, |
std::size_t | inputBufferSize | ||
) |
Converts the specified UTF-8 string to Latin-1.
Definition at line 194 of file stringconversion.cpp.
StringData ConversionUtilities::convertUtf8ToUtf16BE | ( | const char * | inputBuffer, |
std::size_t | inputBufferSize | ||
) |
Converts the specified UTF-8 string to UTF-16 (big-endian).
Definition at line 167 of file stringconversion.cpp.
StringData ConversionUtilities::convertUtf8ToUtf16LE | ( | const char * | inputBuffer, |
std::size_t | inputBufferSize | ||
) |
Converts the specified UTF-8 string to UTF-16 (little-endian).
Definition at line 149 of file stringconversion.cpp.
string ConversionUtilities::dataSizeToString | ( | uint64 | sizeInByte, |
bool | includeByte | ||
) |
Converts the specified data size in byte to its equivalent std::string representation.
The unit with appropriate binary prefix will be appended.
Definition at line 252 of file stringconversion.cpp.
pair< unique_ptr< byte[]>, uint32 > ConversionUtilities::decodeBase64 | ( | const char * | encodedStr, |
const uint32 | strSize | ||
) |
Decodes the specified Base64 encoded string.
Throws | a ConversionException if the specified string is no valid Base64. |
Definition at line 361 of file stringconversion.cpp.
constexpr CharType ConversionUtilities::digitToChar | ( | CharType | digit | ) |
Returns the character representation of the specified digit.
Definition at line 289 of file stringconversion.h.
Encodes the specified data to Base64.
Definition at line 321 of file stringconversion.cpp.
void ConversionUtilities::findAndReplace | ( | StringType & | str, |
const StringType & | find, | ||
const StringType & | replace | ||
) |
Replaces all occurences of find with relpace in the specified str.
Definition at line 276 of file stringconversion.h.
std::string ConversionUtilities::interpretIntegerAsString | ( | T | integer, |
int | startOffset = 0 |
||
) |
Interprets the given integer at the specified position as std::string using the specified byte order.
Example: interpretation of ID3v2 frame IDs (stored as 32-bit integer) as string
T | The data type of the integer to be interpreted. |
Definition at line 617 of file stringconversion.h.
Container::value_type ConversionUtilities::joinStrings | ( | const Container & | strings, |
const typename Container::value_type & | delimiter = typename Container::value_type() , |
||
bool | omitEmpty = false , |
||
const typename Container::value_type & | leftClosure = typename Container::value_type() , |
||
const typename Container::value_type & | rightClosure = typename Container::value_type() |
||
) |
Joins the given strings using the specified delimiter.
The strings will be enclosed using the provided closures leftClosure and rightClosure.
strings | The string parts to be joined. |
delimiter | Specifies a delimiter to be used (empty string by default). |
omitEmpty | Indicates whether empty part should be omitted. |
leftClosure | Specifies a string to be inserted before each string (empty string by default). |
rightClosure | Specifies a string to be appendend after each string (empty string by default). |
Container | The STL-container used to provide the strings. |
Definition at line 72 of file stringconversion.h.
StringType ConversionUtilities::numberToString | ( | IntegralType | number, |
typename StringType::value_type | base = 10 |
||
) |
Converts the given number to its equivalent string representation using the specified base.
IntegralType | The data type of the given number. |
StringType | The string type (should be an instantiation of the basic_string class template). |
Definition at line 302 of file stringconversion.h.
StringType ConversionUtilities::numberToString | ( | FloatingType | number, |
typename StringType::value_type | base = 10 |
||
) |
Converts the given number to its equivalent string representation using the specified base.
FloatingType | The data type of the given number. |
StringType | The string type (should be an instantiation of the basic_string class template). |
Definition at line 356 of file stringconversion.h.
constexpr auto ConversionUtilities::operator% | ( | const Tuple & | lhs, |
const std::string & | rhs | ||
) | -> decltype(std::tuple_cat(lhs, std::make_tuple(&rhs))) |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 155 of file stringbuilder.h.
constexpr auto ConversionUtilities::operator% | ( | const Tuple & | lhs, |
const char * | rhs | ||
) | -> decltype(std::tuple_cat(lhs, std::make_tuple(rhs))) |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 163 of file stringbuilder.h.
constexpr auto ConversionUtilities::operator% | ( | const Tuple & | lhs, |
IntegralType | rhs | ||
) | -> decltype(std::tuple_cat(lhs, std::make_tuple(rhs))) |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 172 of file stringbuilder.h.
constexpr auto ConversionUtilities::operator% | ( | const std::string & | lhs, |
const std::string & | rhs | ||
) | -> decltype(std::make_tuple(&lhs, &rhs)) |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 180 of file stringbuilder.h.
constexpr auto ConversionUtilities::operator% | ( | const char * | lhs, |
const std::string & | rhs | ||
) | -> decltype(std::make_tuple(lhs, &rhs)) |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 188 of file stringbuilder.h.
constexpr auto ConversionUtilities::operator% | ( | const std::string & | lhs, |
const char * | rhs | ||
) | -> decltype(std::make_tuple(&lhs, rhs)) |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 196 of file stringbuilder.h.
constexpr auto ConversionUtilities::operator% | ( | const std::string & | lhs, |
char | rhs | ||
) | -> decltype(std::make_tuple(&lhs, rhs)) |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 204 of file stringbuilder.h.
constexpr auto ConversionUtilities::operator% | ( | char | lhs, |
const std::string & | rhs | ||
) | -> decltype(std::make_tuple(lhs, &rhs)) |
Allows construction of string-tuples via %-operator, eg.
string1 % "string2" % string3.
Definition at line 212 of file stringbuilder.h.
|
inline |
Allows construction of final string from previously constructed string-tuple and trailing string via +-operator.
This is meant to be used for fast string building without multiple heap allocation, eg.
Definition at line 227 of file stringbuilder.h.
|
inline |
Allows construction of final string from previously constructed string-tuple and trailing string via +-operator.
This is meant to be used for fast string building without multiple heap allocation, eg.
Definition at line 242 of file stringbuilder.h.
|
inline |
Allows construction of final string from previously constructed string-tuple and trailing char via +-operator.
This is meant to be used for fast string building without multiple heap allocation, eg.
Definition at line 258 of file stringbuilder.h.
Container ConversionUtilities::splitString | ( | const typename Container::value_type & | string, |
const typename Container::value_type & | delimiter, | ||
EmptyPartsTreat | emptyPartsRole = EmptyPartsTreat::Keep , |
||
int | maxParts = -1 |
||
) |
Splits the given string at the specified delimiter.
string | The string to be splitted. |
delimiter | Specifies the delimiter. |
emptyPartsRole | Specifies the treatment of empty parts. |
maxParts | Specifies the maximal number of parts. Values less or equal zero indicate an unlimited number of parts. |
Container | The STL-container used to return the parts. |
Definition at line 135 of file stringconversion.h.
Container ConversionUtilities::splitStringSimple | ( | const typename Container::value_type & | string, |
const typename Container::value_type & | delimiter, | ||
int | maxParts = -1 |
||
) |
Splits the given string (which might also be a string view) at the specified delimiter.
string | The string to be splitted. |
delimiter | Specifies the delimiter. |
maxParts | Specifies the maximal number of parts. Values less or equal zero indicate an unlimited number of parts. |
Container | The STL-container used to return the parts. |
Definition at line 182 of file stringconversion.h.
bool ConversionUtilities::startsWith | ( | const StringType & | str, |
const StringType & | phrase | ||
) |
Returns whether str starts with phrase.
Definition at line 210 of file stringconversion.h.
bool ConversionUtilities::startsWith | ( | const StringType & | str, |
const typename StringType::value_type * | phrase | ||
) |
Returns whether str starts with phrase.
Definition at line 228 of file stringconversion.h.
IntegralType ConversionUtilities::stringToNumber | ( | const StringType & | string, |
typename StringType::value_type | base = 10 |
||
) |
Converts the given string to an unsigned number assuming string uses the specified base.
Converts the given string to a signed number assuming string uses the specified base.
IntegralType | The data type used to store the converted value. |
StringType | The string type (should be an instantiation of the basic_string class template). |
A | ConversionException will be thrown if the provided string is not a valid number. |
IntegralType | The data type used to store the converted value. |
StringType | The string type (should be an instantiation of the basic_string class template). |
A | ConversionException will be thrown if the provided string is not a valid number. |
Definition at line 398 of file stringconversion.h.
FloatingType ConversionUtilities::stringToNumber | ( | const StringType & | string, |
typename StringType::value_type | base = 10 |
||
) |
Converts the given string to a number assuming string uses the specified base.
FloatingType | The data type used to store the converted value. |
StringType | The string type (should be an instantiation of the basic_string class template). |
A | ConversionException will be thrown if the provided string is not a valid number. |
Definition at line 455 of file stringconversion.h.
IntegralType ConversionUtilities::stringToNumber | ( | const CharType * | string, |
unsigned char | base = 10 |
||
) |
Converts the given null-terminated string to an unsigned numeric value using the specified base.
Converts the given null-terminated string to a signed numeric value using the specified base.
IntegralType | The data type used to store the converted value. |
CharType | The character type. |
A | ConversionException will be thrown if the provided string is not a valid number. |
IntegralType | The data type used to store the converted value. |
CharType | The character type. |
A | ConversionException will be thrown if the provided string is not a valid number. |
Definition at line 480 of file stringconversion.h.
FloatingType ConversionUtilities::stringToNumber | ( | const CharType * | string, |
unsigned char | base = 10 |
||
) |
Converts the given null-terminated string to a number assuming string uses the specified base.
FloatingType | The data type used to store the converted value. |
CharType | The character type. |
A | ConversionException will be thrown if the provided string is not a valid number. |
Definition at line 504 of file stringconversion.h.
CPP_UTILITIES_EXPORT constexpr uint16 ConversionUtilities::swapOrder | ( | uint16 | value | ) |
Swaps the byte order of the specified 16-bit unsigned integer.
Definition at line 154 of file binaryconversion.h.
CPP_UTILITIES_EXPORT constexpr uint32 ConversionUtilities::swapOrder | ( | uint32 | value | ) |
Swaps the byte order of the specified 32-bit unsigned integer.
Definition at line 162 of file binaryconversion.h.
CPP_UTILITIES_EXPORT constexpr uint64 ConversionUtilities::swapOrder | ( | uint64 | value | ) |
Swaps the byte order of the specified 64-bit unsigned integer.
Definition at line 170 of file binaryconversion.h.
|
inline |
Converts the specified multilineString to an array of lines.
Definition at line 202 of file stringconversion.h.
CPP_UTILITIES_EXPORT constexpr uint32 ConversionUtilities::toFixed16 | ( | float32 | float32value | ) |
Returns the 16.16 fixed point representation converted from the specified 32-bit floating point number.
Definition at line 117 of file binaryconversion.h.
CPP_UTILITIES_EXPORT constexpr uint16 ConversionUtilities::toFixed8 | ( | float32 | float32value | ) |
Returns the 8.8 fixed point representation converted from the specified 32-bit floating point number.
Definition at line 101 of file binaryconversion.h.
CPP_UTILITIES_EXPORT constexpr float32 ConversionUtilities::toFloat32 | ( | uint16 | fixed8value | ) |
Returns a 32-bit floating point number converted from the specified 8.8 fixed point representation.
Definition at line 109 of file binaryconversion.h.
CPP_UTILITIES_EXPORT constexpr float32 ConversionUtilities::toFloat32 | ( | uint32 | fixed16value | ) |
Returns a 32-bit floating point number converted from the specified 16.16 fixed point representation.
Definition at line 125 of file binaryconversion.h.
|
inline |
Converts the specified arrayOfLines to a multiline string.
Definition at line 111 of file stringconversion.h.
CPP_UTILITIES_EXPORT constexpr uint32 ConversionUtilities::toNormalInt | ( | uint32 | synchsafeInt | ) |
Returns a normal 32-bit integer converted from a 32-bit synchsafe integer.
Definition at line 145 of file binaryconversion.h.
CPP_UTILITIES_EXPORT constexpr uint32 ConversionUtilities::toSynchsafeInt | ( | uint32 | normalInt | ) |
Returns a 32-bit synchsafe integer converted from a normal 32-bit integer.
Definition at line 135 of file binaryconversion.h.
void ConversionUtilities::truncateString | ( | std::string & | str, |
char | terminationChar = '\0' |
||
) |
Truncates all characters after the first occurrence of the specified terminationChar and the termination character as well.
Definition at line 239 of file stringconversion.cpp.
StringType ConversionUtilities::tupleToString | ( | const std::tuple< Args... > & | tuple | ) |
Concatenates all strings hold by the specified tuple.
Definition at line 139 of file stringbuilder.h.