Boost.URL Logo

PrevUpHomeNext
pct_encoded_view::append_to

Append the range with percent-decoded applied to an existing string.

Synopsis
template<
    class MutableString>
MutableString&
append_to(
    MutableString& s) const;
Description

This function applies percent-decoding to each character in the referenced buffer and appends it to s which must satisfy the requirements of MutableString. In particular this expression must be valid:

s.append( this->begin(), this->end() );

Depending on the implementation of MutableString this allows the caller to recycle capacity that resides in an already-existing container when applying percent-decoding, as shown in this example:

Example
void f( pct_encoded_view s )
{
    thread_local static std::string tmp;

    // Existing capacity of `tmp` will be reused first.
    // If this function is called repeatedly, then the
    // following three lines will almost never perform a
    // memory allocation:

    tmp = "The decoded value is '";
    s.append_to( tmp );
    tmp += "'\n";

    std::cout << tmp;
}
Mandates
is_mutable_string_v< MutableString >
Complexity

Linear in this->size(), plus s.append( this->begin(), this->end() ).

Return Value

A string representing the entire contents of the decoded range.


PrevUpHomeNext