[#boost-urls-params_encoded_ref-set-07] = xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/params_encoded_ref.adoc[params_encoded_ref]::set :relfileprefix: ../../../ :mrdocs: Set a value == Synopsis Declared in `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/params_encoded_ref.hpp#L951[boost/url/params_encoded_ref.hpp]>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:boost/urls/params_encoded_base/iterator.adoc[iterator] set( xref:boost/urls/pct_string_view.adoc[pct_string_view] key, xref:boost/urls/pct_string_view.adoc[pct_string_view] value, xref:boost/urls/ignore_case_param.adoc[ignore_case_param] ic = {}); ---- == Description This function performs one of two actions depending on the value of `this‐>contains( key, ic )`. * If key is contained in the view then one of the matching params has its value changed to the specified value. The remaining params with a matching key are erased. Otherwise, * If `key` is not contained in the view, then the function apppends the param `{ key, value }` . All iterators are invalidated. [NOTE] The strings passed in must not come from the element being replaced, or else the behavior is undefined. === Example [,cpp] ---- url u( "?id=42&id=69" ); u.encoded_params().set( "id", "none" ); assert( u.encoded_params().count( "id" ) == 1 ); ---- === Postconditions [,cpp] ---- this->count( key, ic ) == 1 && this->find( key, ic )->value == value ---- === Complexity Linear in `this‐>url().encoded_query().size()`. === Exception Safety Strong guarantee. Calls to allocate may throw. Exceptions thrown on invalid input. Set a value This function performs one of two actions depending on the value of `this‐>contains( key, ic )`. * If key is contained in the view then one of the matching params has its value changed to the specified value. The remaining params with a matching key are erased. Otherwise, * If `key` is not contained in the view, then the function apppends the param `{ key, value }` . All iterators are invalidated. [NOTE] The strings passed in must not come from the element being replaced, or else the behavior is undefined. === Example [,cpp] ---- url u( "?id=42&id=69" ); u.encoded_params().set( "id", "none" ); assert( u.encoded_params().count( "id" ) == 1 ); ---- === Postconditions [,cpp] ---- this->count( key, ic ) == 1 && this->find( key, ic )->value == value ---- === Complexity Linear in `this‐>url().encoded_query().size()`. === Exception Safety Strong guarantee. Calls to allocate may throw. Exceptions thrown on invalid input. == Exceptions |=== | Name | Thrown on | `system_error` | `key` or `value` contain an invalid percent‐encoding. | `system_error` | `key` or `value` contain an invalid percent‐encoding. |=== == Return Value An iterator to the appended or modified element. == Parameters |=== | Name | Description | *key* | The key to match. By default, a case‐sensitive comparison is used. | *value* | The value to assign. The empty string still counts as a value. That is, `has_value` for the element is true. | *ic* | An optional parameter. If the value xref:boost/urls/ignore_case.adoc[ignore_case] is passed here, the comparison is case‐insensitive. | *key* | The key to match. By default, a case‐sensitive comparison is used. | *value* | The value to assign. The empty string still counts as a value. That is, `has_value` for the element is true. | *ic* | An optional parameter. If the value xref:boost/urls/ignore_case.adoc[ignore_case] is passed here, the comparison is case‐insensitive. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#