|
Upa URL C++ library
A WHATWG URL Standard implementation
|
URLSearchParams class. More...
#include <upa/url_search_params.h>
Public Types | |
| using | name_value_pair = std::pair<std::string, std::string> |
| using | name_value_list = std::list<name_value_pair> |
| using | const_iterator = name_value_list::const_iterator |
| using | const_reverse_iterator = name_value_list::const_reverse_iterator |
| using | iterator = const_iterator |
| using | reverse_iterator = const_reverse_iterator |
| using | size_type = name_value_list::size_type |
| using | value_type = name_value_pair |
Public Member Functions | |
| url_search_params ()=default | |
| Default constructor. | |
| url_search_params (const url_search_params &other) | |
| Copy constructor. | |
| url_search_params (url_search_params &&other) noexcept(std::is_nothrow_move_constructible_v< name_value_list >) | |
| Move constructor. | |
| template<class StrT, enable_if_str_arg_t< StrT > = 0> | |
| url_search_params (StrT &&query) | |
| Parsing constructor. | |
| template<class ConT, detail::enable_if_not_base_of_t< url_search_params, ConT > = 0, std::enable_if_t< detail::is_iterable_pairs_v< ConT >, int > = 0> | |
| url_search_params (ConT &&cont) | |
| ~url_search_params ()=default | |
| destructor | |
| url_search_params & | operator= (const url_search_params &other) |
| Copy assignment. | |
| url_search_params & | operator= (url_search_params &&other) noexcept |
| Move assignment. | |
| url_search_params & | safe_assign (url_search_params &&other) |
| Safe move assignment. | |
| void | clear () |
| Clears parameters. | |
| void | swap (url_search_params &other) noexcept |
| Swaps the contents of two url_search_params. | |
| template<class StrT, enable_if_str_arg_t< StrT > = 0> | |
| void | parse (StrT &&query) |
| template<class TN, class TV> | |
| void | append (TN &&name, TV &&value) |
| template<class TN> | |
| void | del (const TN &name) |
| template<class TN, class TV> | |
| void | del (const TN &name, const TV &value) |
| template<class TN> | |
| size_type | remove (const TN &name) |
| template<class TN, class TV> | |
| size_type | remove (const TN &name, const TV &value) |
| template<class UnaryPredicate> | |
| size_type | remove_if (UnaryPredicate p) |
| template<class TN> | |
| const std::string * | get (const TN &name) const |
| template<class TN> | |
| std::list< std::string > | get_all (const TN &name) const |
| template<class TN> | |
| bool | has (const TN &name) const |
| template<class TN, class TV> | |
| bool | has (const TN &name, const TV &value) const |
| template<class TN, class TV> | |
| void | set (TN &&name, TV &&value) |
| void | sort () |
| void | serialize (std::string &query) const |
| std::string | to_string () const |
| const_iterator | begin () const noexcept |
| const_iterator | cbegin () const noexcept |
| const_iterator | end () const noexcept |
| const_iterator | cend () const noexcept |
| const_reverse_iterator | rbegin () const noexcept |
| const_reverse_iterator | crbegin () const noexcept |
| const_reverse_iterator | rend () const noexcept |
| const_reverse_iterator | crend () const noexcept |
| bool | empty () const noexcept |
| size_type | size () const noexcept |
Static Public Member Functions | |
| template<class StrT, enable_if_str_arg_t< StrT > = 0> | |
| static name_value_list | do_parse (bool rem_qmark, StrT &&query) |
| template<class StrT, enable_if_str_arg_t< StrT > = 0> | |
| static void | urlencode (std::string &encoded, StrT &&value) |
Friends | |
| class | url |
| class | detail::url_search_params_ptr |
| std::ostream & | operator<< (std::ostream &os, const url_search_params &usp) |
| Performs stream output on URL search parameters. | |
URLSearchParams class.
Follows specification in https://url.spec.whatwg.org/#interface-urlsearchparams
Definition at line 71 of file url_search_params.h.
| using upa::url_search_params::const_iterator = name_value_list::const_iterator |
Definition at line 77 of file url_search_params.h.
| using upa::url_search_params::const_reverse_iterator = name_value_list::const_reverse_iterator |
Definition at line 78 of file url_search_params.h.
Definition at line 79 of file url_search_params.h.
| using upa::url_search_params::name_value_list = std::list<name_value_pair> |
Definition at line 76 of file url_search_params.h.
| using upa::url_search_params::name_value_pair = std::pair<std::string, std::string> |
Definition at line 75 of file url_search_params.h.
Definition at line 80 of file url_search_params.h.
| using upa::url_search_params::size_type = name_value_list::size_type |
Definition at line 81 of file url_search_params.h.
Definition at line 82 of file url_search_params.h.
|
default |
Default constructor.
Constructs empty url_search_params object.
|
inline |
Copy constructor.
| [in] | other | url_search_params object to copy from |
Definition at line 442 of file url_search_params.h.
|
inlinenoexcept |
Move constructor.
Constructs the url_search_params object with the contents of other using move semantics.
| [in,out] | other | url_search_params object to move from |
Definition at line 449 of file url_search_params.h.
|
inlineexplicit |
Parsing constructor.
Initializes name-value pairs list by parsing query string.
| [in] | query | string to parse |
Definition at line 111 of file url_search_params.h.
|
inlineexplicit |
Initializes name-value pairs list by copying pairs fron container.
| [in] | cont | name-value pairs container |
Definition at line 123 of file url_search_params.h.
|
default |
destructor
|
inline |
Appends given name-value pair to list
More info: https://url.spec.whatwg.org/#dom-urlsearchparams-append
| [in] | name | |
| [in] | value |
Definition at line 522 of file url_search_params.h.
|
inlinenodiscardnoexcept |
Definition at line 311 of file url_search_params.h.
|
inlinenodiscardnoexcept |
Definition at line 314 of file url_search_params.h.
|
inlinenodiscardnoexcept |
Definition at line 320 of file url_search_params.h.
|
inline |
Clears parameters.
Definition at line 479 of file url_search_params.h.
|
inlinenodiscardnoexcept |
Definition at line 326 of file url_search_params.h.
|
inlinenodiscardnoexcept |
Definition at line 332 of file url_search_params.h.
|
inline |
Remove all name-value pairs whose name is name from list.
More info: https://url.spec.whatwg.org/#dom-urlsearchparams-delete
| [in] | name |
Definition at line 532 of file url_search_params.h.
|
inline |
Remove all name-value pairs whose name is name and value is value from list.
More info: https://url.spec.whatwg.org/#dom-urlsearchparams-delete
| [in] | name | |
| [in] | value |
Definition at line 542 of file url_search_params.h.
|
inlinestaticnodiscard |
Initializes and returns name-value pairs list by parsing query string.
| [in] | rem_qmark | if it is true and the query starts with U+003F (?), then skips first code point in query |
| [in] | query | string to parse |
Definition at line 669 of file url_search_params.h.
|
inlinenodiscardnoexcept |
Checks whether the name-value list is empty
Definition at line 339 of file url_search_params.h.
|
inlinenodiscardnoexcept |
Definition at line 317 of file url_search_params.h.
|
inlinenodiscard |
Returns value of the first name-value pair whose name is name, or nullptr, if there isn't such pair.
More info: https://url.spec.whatwg.org/#dom-urlsearchparams-get
| [in] | name |
Definition at line 585 of file url_search_params.h.
|
inlinenodiscard |
Return the values of all name-value pairs whose name is name.
More info: https://url.spec.whatwg.org/#dom-urlsearchparams-getall
| [in] | name |
Definition at line 595 of file url_search_params.h.
|
inlinenodiscard |
Tests if list contains a name-value pair whose name is name.
More info: https://url.spec.whatwg.org/#dom-urlsearchparams-has
| [in] | name |
Definition at line 606 of file url_search_params.h.
|
inlinenodiscard |
Tests if list contains a name-value pair whose name is name and value is value.
More info: https://url.spec.whatwg.org/#dom-urlsearchparams-has
| [in] | name | |
| [in] | value |
Definition at line 616 of file url_search_params.h.
|
inline |
Copy assignment.
Replaces the contents with those of other using copy semantics.
Updates linked URL object if any. So this operator can be used to assign a value to the reference returned by url::search_params().
| [in] | other | url_search_params to copy from |
Definition at line 457 of file url_search_params.h.
|
inlinenoexcept |
Move assignment.
Replaces the contents with those of other using move semantics.
NOTE: It is undefined behavior to use this operator to assign a value to the reference returned by url::search_params(). Use safe_assign instead.
| [in,out] | other | url_search_params to move to this object |
Definition at line 465 of file url_search_params.h.
|
inline |
Initializes name-value pairs list by parsing query string.
| [in] | query | string to parse |
Definition at line 515 of file url_search_params.h.
|
inlinenodiscardnoexcept |
Definition at line 323 of file url_search_params.h.
|
inline |
Remove all name-value pairs whose name is name from list.
It updates connected URL only if something is removed.
| [in] | name |
Definition at line 553 of file url_search_params.h.
|
inline |
Remove all name-value pairs whose name is name and value is value from list.
It updates connected URL only if something is removed.
| [in] | name | |
| [in] | value |
Definition at line 562 of file url_search_params.h.
|
inline |
Remove all name-value pairs for which predicate p returns true.
It updates connected URL only if something is removed.
| [in] | p | unary predicate which returns value of bool type and has const value_type& parameter |
Definition at line 572 of file url_search_params.h.
|
inlinenodiscardnoexcept |
Definition at line 329 of file url_search_params.h.
|
inline |
Safe move assignment.
Replaces the contents with those of other using move semantics.
Updates linked URL object if any. So this function can be used to assign a value to the reference returned by url::search_params().
| [in,out] | other | URL to move to this object |
Definition at line 471 of file url_search_params.h.
|
inline |
Serializes name-value pairs to string and appends it to query.
| [in,out] | query |
Definition at line 739 of file url_search_params.h.
|
inline |
Sets search parameter value
More info: https://url.spec.whatwg.org/#dom-urlsearchparams-set
| [in] | name | |
| [in] | value |
Definition at line 628 of file url_search_params.h.
|
inlinenodiscardnoexcept |
Definition at line 342 of file url_search_params.h.
|
inline |
Sort all name-value pairs, by their names.
Sorting is done by comparison of code units. The relative order between name-value pairs with equal names is preserved.
More info: https://url.spec.whatwg.org/#dom-urlsearchparams-sort
Definition at line 650 of file url_search_params.h.
|
inlinenoexcept |
Swaps the contents of two url_search_params.
NOTE: It is undefined behavior to use this function to swap the contents of references returned by url::search_params().
| [in,out] | other | url_search_params to exchange the contents with |
Definition at line 485 of file url_search_params.h.
|
inlinenodiscard |
Serializes name-value pairs to string.
More info: https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior
Definition at line 753 of file url_search_params.h.
|
inlinestatic |
Percent encodes the value using application/x-www-form-urlencoded percent-encode set, and replacing 0x20 (SP) with U+002B (+). Appends result to the encoded string.
| [in,out] | encoded | string to append percent encoded value |
| [in] | value | string value to percent encode |
Definition at line 734 of file url_search_params.h.
|
friend |
Definition at line 375 of file url_search_params.h.
|
friend |
Performs stream output on URL search parameters.
Outputs URL search parameters serialized to application/x-www-form-urlencoded
| [in] | os | the output stream to write to |
| [in] | usp | the url_search_params object to serialize and output |
Definition at line 771 of file url_search_params.h.
|
friend |
Definition at line 374 of file url_search_params.h.