|
The Micro C++ Library
|
The Strings class provides lots of string conversion and formatting functions. More...
#include <micxx.hxx>
Static Public Member Functions | |
| static void | append (std::string &dest, const std::wstring &src) |
Append src at the end of dest. | |
| static void | append (std::string &dest, const char *src, std::size_t count) |
Append at most count characters from src at the end of dest. | |
| static void | append (std::string &dest, const wchar_t *src, std::size_t count) |
Append at most count wide characters from src at the end of dest. | |
| static void | append (std::wstring &dest, const std::string &src) |
Append src at the end of dest. | |
| static void | append (std::wstring &dest, const char *src, std::size_t count) |
Append count wide characters from src to the end of dest. | |
| static void | append (std::string &dest, long value, unsigned char base=10) |
| Same as Strings::append(dest, (long long) value, base). | |
| static void | append (std::wstring &dest, long value, unsigned char base=10) |
| static void | append (std::string &dest, long long value, unsigned char base=10) |
Append the string representation of value at the end of dest. | |
| static void | append (std::wstring &dest, long long value, unsigned char base=10) |
| static void | append (std::string &dest, unsigned long value, unsigned char base=10) |
| Same as Strings::append(dest, (unsigned long long) value, base). | |
| static void | append (std::wstring &dest, unsigned long value, unsigned char base=10) |
| static void | append (std::string &dest, unsigned long long value, unsigned char base=10) |
Append the string representation of value at the end of dest. | |
| static void | append (std::wstring &dest, unsigned long long value, unsigned char base=10) |
| static std::wstring | convert (const std::string &str) |
| static std::string | convert (const std::wstring &wstr) |
| static void | copy (char *dest, std::size_t destSize, const char *src) |
| Same as copy(dest, destSize, src, Strings::length(src, destSize)) | |
| static void | copy (char *dest, std::size_t destSize, const char *src, std::size_t count) |
Copies min(destSize,count) characters from source to dest. If count < destSize, destSize-count 0x00 characters are appended as well. | |
| static std::string | dump (const void *buf, std::size_t bufSize, unsigned long long startAddress=0, unsigned char addressSize=8) |
Return a hex dump of the first bufSize bytes of buf. | |
| static void | dump (std::ostream &out, const void *buf, std::size_t bufSize, unsigned long long startAddress=0, unsigned char addressSize=8) |
Print a hex dump of the first bufSize bytes of buf to the output stream out. | |
| static void | dump (std::ostream &out, const Buffer &buffer, unsigned long long startAddress=0, unsigned char addressSize=8) |
| Same as dump(out, buffer.getAddress(), buffer.getSize(), startAddress, addressSize). | |
| static int | icompare (const char *left, const char *right, std::size_t count) |
| static int | icompare (const wchar_t *left, const wchar_t *right, std::size_t count) |
| static std::size_t | length (const char *str, std::size_t max) |
| Returns either strlen(str), if strlen(str) <= max, or max. | |
| static std::size_t | length (const wchar_t *wstr, std::size_t max) |
| Returns either wcslen(wstr), if wcslen(wstr) <= max, or max. | |
| static void | move (char *dest, std::size_t destSize, const char *src, std::size_t count) |
Moves min(destSize,count) characters / bytes from source to dest. | |
| static std::size_t | split (std::list< std::string > &list, const std::string &str, char separator, bool returnEmptyStrings=true) |
| split the string str at all occurences of character separator into single strings. | |
| static std::size_t | split (std::list< std::wstring > &list, const std::wstring &wstr, wchar_t separator) |
| split the string wstr at all occurences of character separator into single strings. | |
| static int | sprintf (std::string &dest, const char *fmt,...) |
| static int | sprintf (char dest[], std::size_t size, const char *fmt,...) |
Copies up to count characters into dest including the terminating 0 character. | |
| static int | sprintf (wchar_t dest[], std::size_t count, const wchar_t *fmt,...) |
Copies up to count wide characters into dest including the terminating 0 character. | |
| static char | toInt8 (const std::string &str, unsigned char base=10) |
Try to parse (convert) the string str into a char number. | |
| static char | toInt8 (const std::wstring &wstr, unsigned char base=10) |
Try to parse (convert) the string wstr into a char number. | |
| static short | toInt16 (const std::string &str, unsigned char base=10) |
Try to parse (convert) the string str into a short number. | |
| static short | toInt16 (const std::wstring &wstr, unsigned char base=10) |
Try to parse (convert) the string wstr into a short number. | |
| static long | toInt32 (const std::string &str, unsigned char base=10) |
Try to parse (convert) the string str into a long number. | |
| static long | toInt32 (const std::wstring &wstr, unsigned char base=10) |
Try to parse (convert) the string wstr into a long number. | |
| static long long | toInt64 (const std::string &str, unsigned char base=10) |
Try to parse (convert) the string str into a long long number. | |
| static long long | toInt64 (const std::wstring &wstr, unsigned char base=10) |
Try to parse (convert) the string wstr into a long long number. | |
| static std::string & | toLower (std::string &str, const std::locale *loc=0) |
convert str into its lower string representation. | |
| static std::wstring & | toLower (std::wstring &wstr, const std::locale *loc=0) |
convert wstr into its lower string representation. | |
| static std::string | toString (long value, unsigned char base=10) |
| static std::string | toString (long long value, unsigned char base=10) |
| static std::string | toString (unsigned long value, unsigned char base=10) |
| static std::string | toString (unsigned long long value, unsigned char base=10) |
| static unsigned char | toUInt8 (const std::string &str, unsigned char base=10) |
Try to parse (convert) the string str into an unsigned char number. | |
| static unsigned char | toUInt8 (const std::wstring &wstr, unsigned char base=10) |
Try to parse (convert) the string wstr into an unsigned char number. | |
| static unsigned short | toUInt16 (const std::string &str, unsigned char base=10) |
Try to parse (convert) the string str into an unsigned short number. | |
| static unsigned short | toUInt16 (const std::wstring &wstr, unsigned char base=10) |
Try to parse (convert) the string wstr into an unsigned short number. | |
| static unsigned long | toUInt32 (const std::string &str, unsigned char base=10) |
Try to parse (convert) the string str into an unsigned long number. | |
| static unsigned long | toUInt32 (const std::wstring &wstr, unsigned char base=10) |
Try to parse (convert) the string wstr into an unsigned long number. | |
| static unsigned long long | toUInt64 (const std::string &str, unsigned char base=10) |
Try to parse (convert) the string str into an unsigned long long number. | |
| static unsigned long long | toUInt64 (const std::wstring &wstr, unsigned char base=10) |
Try to parse (convert) the string wstr into an unsigned long long number. | |
| static std::string & | toUpper (std::string &str, const std::locale *loc=0) |
convert str into its upper string representation. | |
| static std::wstring & | toUpper (std::wstring &wstr, const std::locale *loc=0) |
convert wstr into its upper string representation. | |
| static std::string & | trim (std::string &str) |
Removes any whitespace characters (' ', '\t', '\r', '\n', '\v') from both sides of the string str. | |
| static std::wstring & | trim (std::wstring &wstr) |
Removes any whitespace characters (' ', '\t', '\r', '\n', '\v') from both sides of the string wstr. | |
| static std::size_t | urldecode (void *buf, std::size_t bufSize, const std::string &str) |
Decodes the string str using the URL encoding of RFC 1738. | |
| static std::string | urlencode (const void *buf, std::size_t bufSize) |
| static void | urlencode (std::string &dest, const void *buf, std::size_t bufSize) |
Encodes the content of buf using the URL encoding of RFC 1738. | |
| static int | vsprintf (char dest[], std::size_t count, const char *fmt, va_list argptr) |
| static int | vsprintf (std::string &str, const char *fmt, va_list argptr) |
| static int | vsprintf (wchar_t dest[], std::size_t count, const wchar_t *fmt, va_list argptr) |
The Strings class provides lots of string conversion and formatting functions.
| static void micxx::Strings::append | ( | std::string & | dest, |
| const std::wstring & | src | ||
| ) | [static] |
Append src at the end of dest.
| static void micxx::Strings::append | ( | std::string & | dest, |
| const char * | src, | ||
| std::size_t | count | ||
| ) | [static] |
Append at most count characters from src at the end of dest.
| static void micxx::Strings::append | ( | std::wstring & | dest, |
| const std::string & | src | ||
| ) | [static] |
Append src at the end of dest.
| static void micxx::Strings::append | ( | std::string & | dest, |
| long long | value, | ||
| unsigned char | base = 10 |
||
| ) | [static] |
Append the string representation of value at the end of dest.
| static void micxx::Strings::append | ( | std::wstring & | dest, |
| long long | value, | ||
| unsigned char | base = 10 |
||
| ) | [static] |
| static void micxx::Strings::append | ( | std::wstring & | dest, |
| const char * | src, | ||
| std::size_t | count | ||
| ) | [static] |
Append count wide characters from src to the end of dest.
| static void micxx::Strings::append | ( | std::string & | dest, |
| unsigned long | value, | ||
| unsigned char | base = 10 |
||
| ) | [static] |
Same as Strings::append(dest, (unsigned long long) value, base).
| static void micxx::Strings::append | ( | std::wstring & | dest, |
| unsigned long | value, | ||
| unsigned char | base = 10 |
||
| ) | [static] |
| static void micxx::Strings::append | ( | std::string & | dest, |
| const wchar_t * | src, | ||
| std::size_t | count | ||
| ) | [static] |
Append at most count wide characters from src at the end of dest.
| static void micxx::Strings::append | ( | std::string & | dest, |
| long | value, | ||
| unsigned char | base = 10 |
||
| ) | [static] |
Same as Strings::append(dest, (long long) value, base).
| static void micxx::Strings::append | ( | std::string & | dest, |
| unsigned long long | value, | ||
| unsigned char | base = 10 |
||
| ) | [static] |
Append the string representation of value at the end of dest.
| static void micxx::Strings::append | ( | std::wstring & | dest, |
| unsigned long long | value, | ||
| unsigned char | base = 10 |
||
| ) | [static] |
| static void micxx::Strings::append | ( | std::wstring & | dest, |
| long | value, | ||
| unsigned char | base = 10 |
||
| ) | [static] |
| static std::wstring micxx::Strings::convert | ( | const std::string & | str | ) | [static] |
| static std::string micxx::Strings::convert | ( | const std::wstring & | wstr | ) | [static] |
| static void micxx::Strings::copy | ( | char * | dest, |
| std::size_t | destSize, | ||
| const char * | src | ||
| ) | [static] |
Same as copy(dest, destSize, src, Strings::length(src, destSize))
| static void micxx::Strings::copy | ( | char * | dest, |
| std::size_t | destSize, | ||
| const char * | src, | ||
| std::size_t | count | ||
| ) | [static] |
Copies min(destSize,count) characters from source to dest. If count < destSize, destSize-count 0x00 characters are appended as well.
| static std::string micxx::Strings::dump | ( | const void * | buf, |
| std::size_t | bufSize, | ||
| unsigned long long | startAddress = 0, |
||
| unsigned char | addressSize = 8 |
||
| ) | [static] |
Return a hex dump of the first bufSize bytes of buf.
| static void micxx::Strings::dump | ( | std::ostream & | out, |
| const void * | buf, | ||
| std::size_t | bufSize, | ||
| unsigned long long | startAddress = 0, |
||
| unsigned char | addressSize = 8 |
||
| ) | [static] |
Print a hex dump of the first bufSize bytes of buf to the output stream out.
| out | the output stream |
| buf | the base address of the buffer to be dumped |
| bufSize | the size of buffer buf in bytes |
| startAddress | use startAddress as a starting offset for the address column |
| addressSize | use 2*sizeof(unsigned long) (default, 32-Bit addresses resulting in 8 hexadecimal digits) or 2*sizeof(unsigned long long) (64-Bit addresses resulting in 16 hexadecimal digits). |
| static void micxx::Strings::dump | ( | std::ostream & | out, |
| const Buffer & | buffer, | ||
| unsigned long long | startAddress = 0, |
||
| unsigned char | addressSize = 8 |
||
| ) | [static] |
Same as dump(out, buffer.getAddress(), buffer.getSize(), startAddress, addressSize).
| static int micxx::Strings::icompare | ( | const char * | left, |
| const char * | right, | ||
| std::size_t | count | ||
| ) | [static] |
Compares lexicographically, at most, the first count characters of left and right. The comparison is performed without regard to case.
| static int micxx::Strings::icompare | ( | const wchar_t * | left, |
| const wchar_t * | right, | ||
| std::size_t | count | ||
| ) | [static] |
Compares lexicographically, at most, the first count characters of left and right. The comparison is performed without regard to case.
| static std::size_t micxx::Strings::length | ( | const char * | str, |
| std::size_t | max | ||
| ) | [static] |
Returns either strlen(str), if strlen(str) <= max, or max.
| static std::size_t micxx::Strings::length | ( | const wchar_t * | wstr, |
| std::size_t | max | ||
| ) | [static] |
Returns either wcslen(wstr), if wcslen(wstr) <= max, or max.
| static void micxx::Strings::move | ( | char * | dest, |
| std::size_t | destSize, | ||
| const char * | src, | ||
| std::size_t | count | ||
| ) | [static] |
Moves min(destSize,count) characters / bytes from source to dest.
| dest | The destination address. |
| destSize | The max. size of the destination area (starting at dest). |
| src | The source address. |
| count | The max. number of characters / bytes to be moved. |
| static std::size_t micxx::Strings::split | ( | std::list< std::string > & | list, |
| const std::string & | str, | ||
| char | separator, | ||
| bool | returnEmptyStrings = true |
||
| ) | [static] |
split the string str at all occurences of character separator into single strings.
| static std::size_t micxx::Strings::split | ( | std::list< std::wstring > & | list, |
| const std::wstring & | wstr, | ||
| wchar_t | separator | ||
| ) | [static] |
split the string wstr at all occurences of character separator into single strings.
| static int micxx::Strings::sprintf | ( | std::string & | dest, |
| const char * | fmt, | ||
| ... | |||
| ) | [static] |
| static int micxx::Strings::sprintf | ( | char | dest[], |
| std::size_t | size, | ||
| const char * | fmt, | ||
| ... | |||
| ) | [static] |
Copies up to count characters into dest including the terminating 0 character.
That means, if the formatted string has more than count characters, only the first count - 1 characters and a terminating 0 character is copied into dest.
0. | static int micxx::Strings::sprintf | ( | wchar_t | dest[], |
| std::size_t | count, | ||
| const wchar_t * | fmt, | ||
| ... | |||
| ) | [static] |
Copies up to count wide characters into dest including the terminating 0 character.
| static short micxx::Strings::toInt16 | ( | const std::string & | str, |
| unsigned char | base = 10 |
||
| ) | [static] |
Try to parse (convert) the string str into a short number.
| static short micxx::Strings::toInt16 | ( | const std::wstring & | wstr, |
| unsigned char | base = 10 |
||
| ) | [static] |
Try to parse (convert) the string wstr into a short number.
| static long micxx::Strings::toInt32 | ( | const std::string & | str, |
| unsigned char | base = 10 |
||
| ) | [static] |
Try to parse (convert) the string str into a long number.
| static long micxx::Strings::toInt32 | ( | const std::wstring & | wstr, |
| unsigned char | base = 10 |
||
| ) | [static] |
Try to parse (convert) the string wstr into a long number.
| static long long micxx::Strings::toInt64 | ( | const std::string & | str, |
| unsigned char | base = 10 |
||
| ) | [static] |
Try to parse (convert) the string str into a long long number.
| static long long micxx::Strings::toInt64 | ( | const std::wstring & | wstr, |
| unsigned char | base = 10 |
||
| ) | [static] |
Try to parse (convert) the string wstr into a long long number.
| static char micxx::Strings::toInt8 | ( | const std::wstring & | wstr, |
| unsigned char | base = 10 |
||
| ) | [static] |
Try to parse (convert) the string wstr into a char number.
| static char micxx::Strings::toInt8 | ( | const std::string & | str, |
| unsigned char | base = 10 |
||
| ) | [static] |
Try to parse (convert) the string str into a char number.
| static std::wstring& micxx::Strings::toLower | ( | std::wstring & | wstr, |
| const std::locale * | loc = 0 |
||
| ) | [static] |
convert wstr into its lower string representation.
wstr | static std::string& micxx::Strings::toLower | ( | std::string & | str, |
| const std::locale * | loc = 0 |
||
| ) | [static] |
convert str into its lower string representation.
str | static std::string micxx::Strings::toString | ( | long | value, |
| unsigned char | base = 10 |
||
| ) | [static] |
| static std::string micxx::Strings::toString | ( | long long | value, |
| unsigned char | base = 10 |
||
| ) | [static] |
| static std::string micxx::Strings::toString | ( | unsigned long | value, |
| unsigned char | base = 10 |
||
| ) | [static] |
| static std::string micxx::Strings::toString | ( | unsigned long long | value, |
| unsigned char | base = 10 |
||
| ) | [static] |
| static unsigned short micxx::Strings::toUInt16 | ( | const std::wstring & | wstr, |
| unsigned char | base = 10 |
||
| ) | [static] |
Try to parse (convert) the string wstr into an unsigned short number.
| static unsigned short micxx::Strings::toUInt16 | ( | const std::string & | str, |
| unsigned char | base = 10 |
||
| ) | [static] |
Try to parse (convert) the string str into an unsigned short number.
| static unsigned long micxx::Strings::toUInt32 | ( | const std::wstring & | wstr, |
| unsigned char | base = 10 |
||
| ) | [static] |
Try to parse (convert) the string wstr into an unsigned long number.
| static unsigned long micxx::Strings::toUInt32 | ( | const std::string & | str, |
| unsigned char | base = 10 |
||
| ) | [static] |
Try to parse (convert) the string str into an unsigned long number.
| static unsigned long long micxx::Strings::toUInt64 | ( | const std::wstring & | wstr, |
| unsigned char | base = 10 |
||
| ) | [static] |
Try to parse (convert) the string wstr into an unsigned long long number.
| static unsigned long long micxx::Strings::toUInt64 | ( | const std::string & | str, |
| unsigned char | base = 10 |
||
| ) | [static] |
Try to parse (convert) the string str into an unsigned long long number.
| str | a numerical string. If str starts with "0x" base is set to 16 regardless what is passed here. |
| base | Should either be 8, 10 or 16. |
| static unsigned char micxx::Strings::toUInt8 | ( | const std::wstring & | wstr, |
| unsigned char | base = 10 |
||
| ) | [static] |
Try to parse (convert) the string wstr into an unsigned char number.
| static unsigned char micxx::Strings::toUInt8 | ( | const std::string & | str, |
| unsigned char | base = 10 |
||
| ) | [static] |
Try to parse (convert) the string str into an unsigned char number.
| static std::string& micxx::Strings::toUpper | ( | std::string & | str, |
| const std::locale * | loc = 0 |
||
| ) | [static] |
convert str into its upper string representation.
str | static std::wstring& micxx::Strings::toUpper | ( | std::wstring & | wstr, |
| const std::locale * | loc = 0 |
||
| ) | [static] |
convert wstr into its upper string representation.
wstr | static std::wstring& micxx::Strings::trim | ( | std::wstring & | wstr | ) | [static] |
Removes any whitespace characters (' ', '\t', '\r', '\n', '\v') from both sides of the string wstr.
| static std::string& micxx::Strings::trim | ( | std::string & | str | ) | [static] |
Removes any whitespace characters (' ', '\t', '\r', '\n', '\v') from both sides of the string str.
| static std::size_t micxx::Strings::urldecode | ( | void * | buf, |
| std::size_t | bufSize, | ||
| const std::string & | str | ||
| ) | [static] |
Decodes the string str using the URL encoding of RFC 1738.
str must not contain any of the characters '=', '&' or '"' as those characters are copied unchanged into buf, which means that, if any of the "XX" encoded characters are decoded into one of these characters, they could not be differentiated anymore from the other characters. | buf | the destination buffer, or 0, if the required length to take the decoded string str should be calculated. |
| bufSize | the maximum number of resulting decoded bytes that are written to buf. |
| str | the string to be decoded. |
buf is 0, the number of bytes resulting from the decoding of str is returned. | static std::string micxx::Strings::urlencode | ( | const void * | buf, |
| std::size_t | bufSize | ||
| ) | [static] |
| static void micxx::Strings::urlencode | ( | std::string & | dest, |
| const void * | buf, | ||
| std::size_t | bufSize | ||
| ) | [static] |
Encodes the content of buf using the URL encoding of RFC 1738.
Each ' ' is encoded as '+'. Each '=', '&', '+', '%', '?' and each non-printable character is encoded as "%XX", where XX is the ASCII Hex code of the character.
| static int micxx::Strings::vsprintf | ( | std::string & | str, |
| const char * | fmt, | ||
| va_list | argptr | ||
| ) | [static] |
| static int micxx::Strings::vsprintf | ( | char | dest[], |
| std::size_t | count, | ||
| const char * | fmt, | ||
| va_list | argptr | ||
| ) | [static] |
| static int micxx::Strings::vsprintf | ( | wchar_t | dest[], |
| std::size_t | count, | ||
| const wchar_t * | fmt, | ||
| va_list | argptr | ||
| ) | [static] |