Rocket::Core::StringUtilities Class Reference
#include <StringUtilities.h>
|
Static Public Member Functions |
| static void | ExpandString (StringList &string_list, const String &string, const char delimiter= ',') |
| static void | JoinString (String &string, const StringList &string_list, const char delimiter= ',') |
| static String | MD5Hash (const char *data, int length=-1) |
| static Hash | FNVHash (const char *data, int length=-1) |
| static bool | URLEncode (const char *input, size_t input_length, String &output) |
| static bool | URLDecode (const String &input, char *output, size_t output_length) |
| static bool | Base64Encode (const char *input, size_t input_length, String &output) |
| static bool | Base64Decode (const String &input, char *output, size_t output_length) |
| static bool | UTF8toUCS2 (const String &input, std::vector< word > &output) |
| static bool | UCS2toUTF8 (const std::vector< word > &input, String &output) |
| static bool | UCS2toUTF8 (const word *input, size_t input_size, String &output) |
| template<typename CharacterType> |
| static bool | IsWhitespace (CharacterType x) |
| static String | StripWhitespace (const String &string) |
|
static int | GetOpt (int nargc, char *nargv[], char *optstring, ArgumentState &arg_state) |
| | getopt program argument processing.
|
Data Structures |
| struct | ArgumentState |
| struct | StringComparei |
| | Operator for STL containers using strings. More...
|
Detailed Description
Helper functions for string manipulation.
- Author:
- Lloyd Weehuizen
Member Function Documentation
| void Rocket::Core::StringUtilities::ExpandString |
( |
StringList & |
string_list, |
|
|
const String & |
string, |
|
|
const char |
delimiter = ',' | |
|
) |
| | [static] |
Expands character-delimited list of values in a single string to a whitespace-trimmed list of values.
- Parameters:
-
| [out] | string_list | Resulting list of values. |
| [in] | string | String to expand. |
| [in] | delimiter | Delimiter found between entries in the string list. |
| void Rocket::Core::StringUtilities::JoinString |
( |
String & |
string, |
|
|
const StringList & |
string_list, |
|
|
const char |
delimiter = ',' | |
|
) |
| | [static] |
Joins a list of string values into a single string separated by a character delimiter.
- Parameters:
-
| [out] | string | Resulting concatenated string. |
| [in] | string_list | Input list of string values. |
| [in] | delimiter | Delimiter to insert between the individual values. |
| String Rocket::Core::StringUtilities::MD5Hash |
( |
const char * |
data, |
|
|
int |
length = -1 | |
|
) |
| | [static] |
Hashes a string of data to an 32-character MD5 value.
- Parameters:
-
| [in] | data | Data to hash. |
| [in] | length | Length of the string to hash. If this is -1, the data will be interpreted as a C string. |
- Returns:
- MD5 hash of the data.
| Hash Rocket::Core::StringUtilities::FNVHash |
( |
const char * |
data, |
|
|
int |
length = -1 | |
|
) |
| | [static] |
Hashes a string of data to an integer value using the FNV algorithm.
- Parameters:
-
| [in] | data | Data to hash. |
| [in] | length | Length of the string to hash. If this is -1, the data will be interpreted as a C string. |
- Returns:
- Integer hash of the data.
| bool Rocket::Core::StringUtilities::URLEncode |
( |
const char * |
input, |
|
|
size_t |
input_length, |
|
|
String & |
output | |
|
) |
| | [static] |
Encodes a string with URL-encoding.
- Parameters:
-
| [in] | input | Input ASCII string to encode. |
| [in] | input_length | Length of the input string. |
| [out] | output | Output URL-encoded string. |
- Returns:
- True if the encoding was successful, false otherwise.
| bool Rocket::Core::StringUtilities::URLDecode |
( |
const String & |
input, |
|
|
char * |
output, |
|
|
size_t |
output_length | |
|
) |
| | [static] |
Decodes a URL-encoded string.
- Parameters:
-
| [in] | input | Input URL-encoded string. |
| [out] | output | Output buffer for the decoded characters. |
| [in] | Length | of the output buffer. |
- Returns:
- False if the decoding failed or the output buffer was too short, true otherwise.
| bool Rocket::Core::StringUtilities::Base64Encode |
( |
const char * |
input, |
|
|
size_t |
input_length, |
|
|
String & |
output | |
|
) |
| | [static] |
Encodes a string with base64-encoding.
- Parameters:
-
| [in] | input | Input ASCII string to encode. |
| [in] | input_length | Length of the input string. |
| [out] | output | Output base-64 encoded string. |
- Returns:
- True if the encoding was successful, false otherwise.
| bool Rocket::Core::StringUtilities::Base64Decode |
( |
const String & |
input, |
|
|
char * |
output, |
|
|
size_t |
output_length | |
|
) |
| | [static] |
Decodes a base64-encoded string.
- Parameters:
-
| [in] | input | Input base-64 encoded string. |
| [out] | output | Output buffer for the decoded characters. |
| [in] | Length | of the output buffer. |
- Returns:
- False if the decoding failed or the output buffer was too short, true otherwise.
| bool Rocket::Core::StringUtilities::UTF8toUCS2 |
( |
const String & |
input, |
|
|
std::vector< word > & |
output | |
|
) |
| | [static] |
Converts a character array in UTF-8 encoding to a vector of words. The UCS-2 words will be encoded as either big- or little-endian, depending on the host processor.
- Parameters:
-
| [in] | input | Input string in UTF-8 encoding. |
| [out] | output | Output vector of UCS-2 characters. |
- Returns:
- True if the conversion went successfully, false if any characters had to be skipped (this will occur if they can't fit into UCS-2).
| bool Rocket::Core::StringUtilities::UCS2toUTF8 |
( |
const std::vector< word > & |
input, |
|
|
String & |
output | |
|
) |
| | [static] |
Converts a vector of words in UCS-2 encoding into a character array in UTF-8 encoding. This function assumes the endianness of the input words to be the same as the host processor.
- Parameters:
-
| [in] | input | Input vector in UCS-2 encoding. |
| [out] | output | Output string in UTF-8 encoding. |
- Returns:
- True if the conversion went successfully, false if not.
| bool Rocket::Core::StringUtilities::UCS2toUTF8 |
( |
const word * |
input, |
|
|
size_t |
input_size, |
|
|
String & |
output | |
|
) |
| | [static] |
Converts an array of words in UCS-2 encoding into a character array in UTF-8 encoding. This function assumes the endianness of the input words to be the same as the host processor.
- Parameters:
-
| [in] | input | Input array of words in UCS-2 encoding. |
| [in] | input_size | Length of the input array. |
| [out] | output | Output string in UTF-8 encoding. |
- Returns:
- True if the conversion went successfully, false if not.
template<typename CharacterType>
| static bool Rocket::Core::StringUtilities::IsWhitespace |
( |
CharacterType |
x |
) |
[inline, static] |
Checks if a given value is a whitespace character.
- Parameters:
-
| [in] | x | The character to evaluate. |
- Returns:
- True if the character is whitespace, false otherwise.
| String Rocket::Core::StringUtilities::StripWhitespace |
( |
const String & |
string |
) |
[static] |
Strip whitespace characters from the beginning and end of a string.
- Parameters:
-
| [in] | string | The string to trim. |
- Returns:
- The stripped string.
The documentation for this class was generated from the following files: