[#boost-urls-url_view_base-query]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/url_view_base.adoc[url&lowbar;view&lowbar;base]::query
:relfileprefix: ../../../
:mrdocs:

Return the query

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;xref:boost/urls/string_token.adoc[string&lowbar;token]::xref:boost/urls/string_token/StringToken.adoc[StringToken] StringToken = xref:boost/urls/string_token.adoc[string&lowbar;token]::xref:boost/urls/string_token/return_string.adoc[return&lowbar;string]&gt;
StringToken::result&lowbar;type
query(StringToken&& token = &lcub;&rcub;);
----

== Description

If this contains a query, it is returned as a string (which may be empty)&period; Otherwise, an empty string is returned&period; Any percent&hyphen;escapes in the string are decoded first&period; When plus signs appear in the query portion of the url, they are converted to spaces automatically upon decoding&period; This behavior can be changed by setting decode options&period;

== Example
[,cpp]
----
assert( url_view( "/sql?id=42&name=jane%2Ddoe&page+size=20" ).query() == "id=42&name=jane-doe&page size=20" );
----
== Complexity
Linear in `this&hyphen;&gt;query()&period;size()`&period;

== Exception Safety
Calls to allocate may throw&period;

== BNF
[,cpp]
----
query           = *( pchar / "/" / "?" )

query-param     = key [ "=" value ]
query-params    = [ query-param ] *( "&" query-param )
----
== Specification
* https://datatracker.ietf.org/doc/html/rfc3986#section-3.4[]
* https://en.wikipedia.org/wiki/Query_string[]

== Return Value

The query as a string&period;

== Parameters

[cols=2]
|===
| Name
| Description
| *token*
| A token to use for the returned string&period;
|===

== See Also

xref:boost/urls/url_view_base/encoded_params.adoc[`encoded&lowbar;params`], xref:boost/urls/url_view_base/encoded_query.adoc[`encoded&lowbar;query`], xref:boost/urls/url_view_base/has_query.adoc[`has&lowbar;query`], xref:boost/urls/url_view_base/params-065.adoc[`params`]&period;


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