:relfileprefix: ../../../
[#boost-urls-params_view-2constructor-04]

= xref:boost.adoc[pass:[boost]]::xref:boost/urls.adoc[pass:[urls]]::xref:boost/urls/params_view.adoc[pass:[params_view]]::params_view


Constructor


== Synopsis

Declared in header `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/params_view.hpp#L253[boost/url/params_view.hpp,window=blank_]>`

[source,cpp,subs="verbatim,macros,-callouts"]
----
params_view(
    core::string_view s,
    xref:boost/urls/encoding_opts.adoc[encoding_opts] opt);
----

== Description


This function constructs params from
a valid query parameter string, which
can contain percent escapes.

This instance will use the specified
xref:boost/urls/encoding_opts.adoc[encoding_opts]
when the values
are decoded.

Unlike the parameters in URLs, the string
passed here should not start with "?".
Upon construction, the view will
reference the character buffer pointed
to by `s`. The caller is responsible
for ensuring that the lifetime of the
buffer extends until it is no longer
referenced.

=== Example
[,cpp]
----
encoding_opts opt;
opt.space_as_plus = true;
params_view qp( "name=John+Doe", opt );
----

=== Effects
[,cpp]
----
return params_view(parse_query( s ).value(), opt);
----

=== Postconditions
[,cpp]
----
this->buffer().data() == s.data()
----

=== Complexity

Linear in `s`.

=== Exception Safety

Exceptions thrown on invalid input.

=== BNF
[,cpp]
----
query-params    = [ query-param ] *( "&" query-param )

query-param     = key [ "=" value ]
----

=== Specification

* link:https://datatracker.ietf.org/doc/html/rfc3986#section-3.4[3.4.  Query]



== Exceptions

|===
| Name | Thrown on

| `system_error`
| 
`s` contains an invalid query parameter
string.

|===



== Parameters

|===
| Name | Description 

| *s*
| 
The string to parse.

| *opt*
| 
The options for decoding. If
this parameter is omitted, `space_as_plus`
is used.

|===




