A class to represent any data coming after the ?
in the request URL into key-value pairs.
More...
A class to represent any data coming after the ?
in the request URL into key-value pairs.
◆ query_string() [1/3]
crow::query_string::query_string |
( |
| ) |
|
|
inline |
◆ query_string() [2/3]
◆ query_string() [3/3]
crow::query_string::query_string |
( |
std::string |
url | ) |
|
|
inline |
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ clear()
void crow::query_string::clear |
( |
| ) |
|
|
inline |
◆ get()
char* crow::query_string::get |
( |
const std::string & |
name | ) |
const |
|
inline |
Get a value from a name, used for ?name=value
.
Note: this method returns the value of the first occurrence of the key only, to return all occurrences, see get_list().
◆ pop()
char* crow::query_string::pop |
( |
const std::string & |
name | ) |
|
|
inline |
Works similar to get() except it removes the item from the query string.
◆ get_list()
std::vector<char*> crow::query_string::get_list |
( |
const std::string & |
name, |
|
|
bool |
use_brackets = true |
|
) |
| const |
|
inline |
Returns a list of values, passed as ?name[]=value1&name[]=value2&...name[]=valuen
with n being the size of the list.
Note: Square brackets in the above example are controlled by use_brackets
boolean (true by default). If set to false, the example becomes ?name=value1,name=value2...name=valuen
◆ pop_list()
std::vector<char*> crow::query_string::pop_list |
( |
const std::string & |
name, |
|
|
bool |
use_brackets = true |
|
) |
| |
|
inline |
◆ get_dict()
std::unordered_map<std::string, std::string> crow::query_string::get_dict |
( |
const std::string & |
name | ) |
const |
|
inline |
Works similar to get_list() except the brackets are mandatory must not be empty.
For example calling get_dict(yourname)
on ?yourname[sub1]=42&yourname[sub2]=84
would give a map containing {sub1 : 42, sub2 : 84}
.
if your query string has both empty brackets and ones with a key inside, use pop_list() to get all the values without a key before running this method.
◆ pop_dict()
std::unordered_map<std::string, std::string> crow::query_string::pop_dict |
( |
const std::string & |
name | ) |
|
|
inline |
Works the same as get_dict() but removes the values from the query string.
◆ keys()
std::vector<std::string> crow::query_string::keys |
( |
| ) |
const |
|
inline |
◆ operator<<
std::ostream& operator<< |
( |
std::ostream & |
os, |
|
|
const query_string & |
qs |
|
) |
| |
|
friend |
◆ MAX_KEY_VALUE_PAIRS_COUNT
const int crow::query_string::MAX_KEY_VALUE_PAIRS_COUNT = 256 |
|
static |
◆ url_
std::string crow::query_string::url_ |
|
private |
◆ key_value_pairs_
std::vector<char*> crow::query_string::key_value_pairs_ |
|
private |
The documentation for this class was generated from the following file: