11 #ifndef TLX_STRING_PARSE_URI_FORM_DATA_HEADER 12 #define TLX_STRING_PARSE_URI_FORM_DATA_HEADER 29 const char* str,
const char* end =
nullptr) {
32 out.reserve(strlen(str));
34 out.reserve(end - str);
37 while (*str && str != end) {
38 if (*str ==
'%' && (a = str[1]) != 0 && (b = str[2]) != 0) {
39 if (a >=
'0' && a <=
'9')
41 else if (a >=
'a' && a <=
'f')
43 else if (a >=
'A' && a <=
'F')
51 if (b >=
'0' && b <=
'9')
53 else if (b >=
'a' && b <=
'f')
55 else if (b >=
'A' && b <=
'F')
63 out +=
static_cast<char>(16 * a + b);
66 else if (*str ==
'+') {
84 std::vector<std::string>* key,
85 std::vector<std::string>* value) {
87 key->clear(), value->clear();
88 const char* c = query_string;
91 const char* begin = c;
92 while (*c !=
'=' && *c != 0) {
102 key->emplace_back(std::move(k));
103 value->emplace_back(std::string());
108 while (*c !=
'&' && *c != 0) {
114 key->emplace_back(std::move(k));
115 value->emplace_back(std::move(v));
130 std::vector<std::string>* key,
131 std::vector<std::string>* value) {
139 #endif // !TLX_STRING_PARSE_URI_FORM_DATA_HEADER
static void parse_uri_form_data(const char *query_string, std::vector< std::string > *key, std::vector< std::string > *value)
Parse a urlencoded form data like "query=string+with+spaces&submit=yes%21&" into a list of keys and v...
static std::string parse_uri_form_data_decode(const char *str, const char *end=nullptr)
Helper function to decode %20 and + in urlencoded form data like "query=string+with+spaces&submit=yes...