1 #include <samchon/library/URLVariables.hpp> 2 #include <initializer_list> 11 URLVariables::URLVariables()
18 vector<WeakString> &items = flashVars.
split(
"&");
19 for (
size_t i = 0; i < items.size(); i++)
22 size_t index = item.
find(
"=");
24 if(index == string::npos)
27 string &key = item.
substr(0, index).str();
40 res.reserve(wstr.size() * 3);
42 for (
size_t i = 0; i < wstr.size(); i++)
44 unsigned char ch = wstr[i];
48 (
'a' <= ch && ch <=
'z') || (
'A' <= ch && ch <=
'Z')
49 || (
'0' <= ch && ch <=
'9')
50 || ch ==
'-' || ch ==
'_' || ch ==
'.' || ch ==
'~' 51 || ch ==
'@' || ch ==
':' || ch ==
'/' || ch ==
'\\' 69 res.reserve(wstr.size());
71 for (
size_t i = 0; i < wstr.size(); i++)
73 const char ch = wstr[i];
80 if (ch ==
'%' && wstr.size() > i + 2)
82 char ch1 = fromHex(wstr[i + 1]);
83 char ch2 = fromHex(wstr[i + 2]);
84 char decoded = (ch1 << 4) | ch2;
86 res.append({ decoded });
95 auto URLVariables::toHex(
unsigned char ch) ->
char 97 static const char lookup[] =
"0123456789ABCDEF";
101 auto URLVariables::fromHex(
unsigned char ch) ->
char 103 if (ch <= '9' && ch >=
'0')
105 else if (ch <= 'f' && ch >=
'a')
107 else if (ch <= 'F' && ch >=
'A')
121 for(const_iterator it = begin(); it != end(); it++)
126 str.append(it->first);
128 str.append(
encode(it->second));
auto substr(size_t startIndex, size_t endIndex=SIZE_MAX) const -> WeakString
Generates a substring.
auto split(const WeakString &delim) const -> std::vector< WeakString >
Generates substrings.
auto find(const WeakString &delim, size_t startIndex=NULL) const -> size_t
Finds first occurence in string.
static auto decode(const WeakString &) -> std::string
Decode a URI string.
static auto encode(const WeakString &) -> std::string
Encode a string into a valid URI.
auto toString() const -> std::string
Get the string representing URLVariables.
Top level namespace of products built from samchon.
A string class only references characeters, reference only.
URLVariables()
Default Constructor.