2 #include <samchon/HashMap.hpp> 4 #include <initializer_list> 5 #include <samchon/WeakString.hpp> 29 :
public HashMap<std::string, std::string>
55 std::vector<WeakString> &items = flashVars.
split(
"&");
56 for (
size_t i = 0; i < items.size(); i++)
59 size_t index = item.
find(
"=");
61 if (index == std::string::npos)
64 std::string &key = item.
substr(0, index).str();
82 res.reserve(wstr.size() * 3);
84 for (
size_t i = 0; i < wstr.size(); i++)
86 unsigned char ch = wstr[i];
90 (
'a' <= ch && ch <=
'z') || (
'A' <= ch && ch <=
'Z')
91 || (
'0' <= ch && ch <=
'9')
92 || ch ==
'-' || ch ==
'_' || ch ==
'.' || ch ==
'~' 93 || ch ==
'@' || ch ==
':' || ch ==
'/' || ch ==
'\\' 119 res.reserve(wstr.size());
121 for (
size_t i = 0; i < wstr.size(); i++)
123 const char ch = wstr[i];
125 if (ch ==
'%' && wstr.size() > i + 2)
127 char ch1 = fromHex(wstr[i + 1]);
128 char ch2 = fromHex(wstr[i + 2]);
129 char decoded = (ch1 << 4) | ch2;
131 res.append({ decoded });
144 static auto toHex(
unsigned char ch) ->
char 146 static const std::string lookup =
"0123456789ABCDEF";
151 static auto fromHex(
unsigned char ch) ->
char 153 if (ch <= '9' && ch >=
'0')
155 else if (ch <= 'f' && ch >=
'a')
157 else if (ch <= 'F' && ch >=
'A')
179 std::string str =
"";
180 for (const_iterator it = begin(); it != end(); it++)
185 str.append(it->first);
187 str.append(
encode(it->second));
auto toString() const -> std::string
Get the string representing URLVariables.
static auto encode(const WeakString &wstr) -> std::string
Encode a string into a valid URI.
auto find(const WeakString &delim, size_t startIndex=NULL) const -> size_t
Finds first occurence in string.
static auto decode(const WeakString &wstr) -> std::string
Decode a URI string.
URLVariables()
Default Constructor.
URLVariables(const WeakString &flashVars)
Constructor by a string representing encoded properties.
auto substr(size_t startIndex, size_t size=SIZE_MAX) const -> WeakString
Generates a substring.
auto split(const WeakString &delim) const -> std::vector< WeakString >
Generates substrings.
Customized std::unordered_map.
A string class only references characeters, reference only.
URLVariables class is for representing variables of HTTP.