StringUtilities.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ROCKETCORESTRINGUTILITIES_H
00029 #define ROCKETCORESTRINGUTILITIES_H
00030
00031 #include <Rocket/Core/Header.h>
00032 #include <Rocket/Core/Types.h>
00033 #include <Rocket/Core/String.h>
00034 #include <stdarg.h>
00035
00036 namespace Rocket {
00037 namespace Core {
00038
00044 class ROCKETCORE_API StringUtilities
00045 {
00046 public:
00052 static void ExpandString(StringList& string_list, const String& string, const char delimiter = ',');
00057 static void JoinString(String& string, const StringList& string_list, const char delimiter = ',');
00058
00063 static String MD5Hash(const char* data, int length = -1);
00068 static Hash FNVHash(const char* data, int length = -1);
00069
00075 static bool URLEncode(const char* input, size_t input_length, String& output);
00081 static bool URLDecode(const String& input, char* output, size_t output_length);
00082
00088 static bool Base64Encode(const char* input, size_t input_length, String& output);
00094 static bool Base64Decode(const String& input, char* output, size_t output_length);
00095
00101 static bool UTF8toUCS2(const String& input, std::vector< word >& output);
00107 static bool UCS2toUTF8(const std::vector< word >& input, String& output);
00114 static bool UCS2toUTF8(const word* input, size_t input_size, String& output);
00115
00119 template < typename CharacterType >
00120 static bool IsWhitespace(CharacterType x)
00121 {
00122 return (x == '\r' || x == '\n' || x == ' ' || x == '\t');
00123 }
00124
00128 static String StripWhitespace(const String& string);
00129
00130 struct ROCKETCORE_API ArgumentState
00131 {
00132 ArgumentState();
00133
00134 int index;
00135 char option;
00136 const char* argument;
00137 bool display_errors;
00138 };
00139
00141 static int GetOpt(int nargc, char* nargv[], char* optstring, ArgumentState& arg_state);
00142
00144 struct ROCKETCORE_API StringComparei
00145 {
00146 bool operator()(const String& lhs, const String& rhs) const;
00147 };
00148 };
00149
00150 }
00151 }
00152
00153 #endif