[#boost-urls-params_view-2constructor-04]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/params_view.adoc[params&lowbar;view]::params&lowbar;view
:relfileprefix: ../../../
:mrdocs:

Constructor

== Synopsis

Declared in `&lt;https://www.github.com/boostorg/url/blob/develop/include/boost/url/params_view.hpp#Lundefined[boost&sol;url&sol;params&lowbar;view&period;hpp]&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
params&lowbar;view(
    core::string&lowbar;view s,
    xref:boost/urls/encoding_opts.adoc[encoding&lowbar;opts] opt);
----

== Description

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

This instance will use the specified xref:boost/urls/encoding_opts.adoc[`encoding&lowbar;opts`] when the values are decoded&period;

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

== 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`&period;

== Exception Safety

Exceptions thrown on invalid input&period;

== BNF

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

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

* https://datatracker.ietf.org/doc/html/rfc3986#section-3.4[3&period;4&period;  Query]

== Exceptions

[cols="1,4"]
|===
| Name
| Thrown on
| `system&lowbar;error`
| `s` contains an invalid query parameter string&period;
|===

== Parameters

[cols="1,4"]
|===
|Name|Description

| *s*
| The string to parse&period;
| *opt*
| The options for decoding&period; If this parameter is omitted, `space&lowbar;as&lowbar;plus` is used&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
