Skip to content

Commit

Permalink
pct encoded view
Browse files Browse the repository at this point in the history
  • Loading branch information
alandefreitas committed Jul 15, 2022
1 parent ef2db3c commit f3e9885
Show file tree
Hide file tree
Showing 14 changed files with 1,728 additions and 6 deletions.
14 changes: 12 additions & 2 deletions doc/qbk/0.main.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@
[def __MoveConstructible__ [@https://en.cppreference.com/w/cpp/named_req/MoveConstructible ['MoveConstructible]]]
[def __SemiRegular__ [@https://en.cppreference.com/w/cpp/concepts/semiregular ['SemiRegular]]]
[def __Swappable__ [@https://en.cppreference.com/w/cpp/named_req/Swappable ['Swappable]]]
[def __CharSet__ [link url.grammar_rules.charset ['CharSet]]]
[def __CharSet__ [link url.concepts.charset ['CharSet]]]
[def __MutableString__ [link url.concepts.mutablestring ['MutableString]]]

[def __std_swap__ [@https://en.cppreference.com/w/cpp/algorithm/swap `std::swap`]]
[def __std_string__ [@https://en.cppreference.com/w/cpp/string/basic_string `std::string`]]

[def __authority_view__ [link url.ref.boost__urls__authority_view `authority_view`]]
[def __segments_view__ [link url.ref.boost__urls__segments_view `segments_view`]]
[def __segments_encoded_view__ [link url.ref.boost__urls__segments_encoded_view `segments_encoded_view`]]
Expand All @@ -63,6 +66,7 @@
[def __static_pool__ [link url.ref.boost__urls__static_pool `static_pool`]]
[def __static_url__ [link url.ref.boost__urls__static_url `static_url`]]
[def __const_string__ [link url.ref.boost__urls__const_string `const_string`]]
[def __pct_encoded_view__ [link url.ref.boost__urls__pct_encoded_view `pct_encoded_view`]]
[def __string_view__ [link url.ref.boost__urls__string_view `string_view`]]
[def __url__ [link url.ref.boost__urls__url `url`]]
[def __url_view__ [link url.ref.boost__urls__url_view `url_view`]]
Expand Down Expand Up @@ -97,7 +101,6 @@
[section Grammar Rules]
[include 5.0.grammars.qbk]
[include 5.1.customization.qbk]
[include 5.2.CharSet.qbk]
[endsect]


Expand All @@ -108,4 +111,11 @@
[block'''</part>''']
[endsect]

[section:concepts Concepts]
[include 6.1.CharSet.qbk]
[include 6.2.MutableString.qbk]
[endsect]



[xinclude index.xml]
File renamed without changes.
86 changes: 86 additions & 0 deletions doc/qbk/6.2.MutableString.qbk
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
[/
Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)

Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Official repository: https://github.com/CPPAlliance/url
]

[section MutableString]

A ['MutableString] is a container that has the `assign` and
`append` member functions that accept iterators to `char`.

The class __pct_encoded_view__ provides a operations
to assign and append percent-decoded values to a
['MutableString].

When storing decoded values in a container, these functions
allow the caller to recycle the input string without
reallocating memory.

[heading Related Identifiers]

* __pct_encoded_view__
* [link url.ref.boost__urls__pct_encoded_rule `pct_encoded_rule`]

[heading Requirements]

In this table:

* `T` is a type meeting the requirements of ['MutableString]
* `s` is a mutable container of type `T`
* `first`, `last` are __InputIterator__s whose `value_type` is `char`
and which refer to the valid character sequence `[ first, last )`

[table Valid expressions
[[Expression] [Type] [Semantics, Pre/Post-conditions]]
[
[
```
T::value_type
```
]
[`char`]
[
Requires: `std::is_same_v< T::value_type, char >`
]
][
[
```
s.assign(first,last)
```
]
[]
[
This member function assigns the characters from the
range in `[first, last)` to `s`.
]
][
[
```
s.append(first,last)
```
]
[]
[
This member function appends the characters from the
range in `[first, last)` to `s`.
]
]]

[heading Exemplar]

[snippet_mutable_string_exemplar]

[heading Models]

* __std_string__

[heading Models]

* __pct_encoded_view__
* [def __pct_encoded_view__ [link url.ref.boost__urls__pct_encoded_view `pct_encoded_view`]]

[endsect]
5 changes: 4 additions & 1 deletion doc/qbk/quickref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<member><link linkend="url.ref.boost__urls__authority_view">authority_view</link></member>
<member><link linkend="url.ref.boost__urls__const_string">const_string</link></member>
<member><link linkend="url.ref.boost__urls__const_string__factory">const_string::factory</link></member>
<member><link linkend="url.ref.boost__urls__pct_encoded_view">pct_encoded_view</link></member>
<member><link linkend="url.ref.boost__urls__ipv4_address">ipv4_address</link></member>
<member><link linkend="url.ref.boost__urls__ipv6_address">ipv6_address</link></member>
<member><link linkend="url.ref.boost__urls__params">params</link></member>
Expand Down Expand Up @@ -106,7 +107,8 @@
</simplelist>
<bridgehead renderas="sect3">Concepts</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="url.grammar_rules.charset"><emphasis>CharSet</emphasis></link></member>
<member><link linkend="url.concepts.charset"><emphasis>CharSet</emphasis></link></member>
<member><link linkend="url.concepts.mutablestring"><emphasis>MutableString</emphasis></link></member>
</simplelist>
</entry>
</row></tbody>
Expand Down Expand Up @@ -224,6 +226,7 @@
</simplelist>
<bridgehead renderas="sect3">Type Traits</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="url.ref.boost__urls__grammar__is_mutable_string">is_mutable_string</link></member>
<member><link linkend="url.ref.boost__urls__grammar__is_charset">is_charset</link></member>
<member><link linkend="url.ref.boost__urls__grammar__is_range">is_range</link></member>
</simplelist>
Expand Down
3 changes: 2 additions & 1 deletion doc/xsl/custom-overrides.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

<xsl:variable name="emphasized-template-parameter-types" select="
'Allocator',
'CharSet'
'CharSet',
'MutableString'
"/>

</xsl:stylesheet>
78 changes: 78 additions & 0 deletions include/boost/url/grammar/is_mutable_string.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
//
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/CPPAlliance/url
//

#ifndef BOOST_URL_IS_MUTABLE_STRING_HPP
#define BOOST_URL_IS_MUTABLE_STRING_HPP

#include <type_traits>

namespace boost {
namespace urls {
namespace grammar {

/** Alias for `std::true_type` if `T` satisfies __MutableString__
for the iterator type `I`
*/
#ifdef BOOST_URL_DOCS
template<class T, class I>
using is_mutable_string = __see_below__;
#else
namespace detail
{
template<class T, class = void>
struct has_value_type : std::false_type {};

template<class T>
struct has_value_type<T, boost::void_t<
typename T::value_type>>
: std::true_type
{};

template<class T, class I, class = void>
struct has_assign_and_append : std::false_type {};

template<class T, class I>
struct has_assign_and_append<T, I, boost::void_t<
// T::append(I, I)
decltype(
std::declval<T&>()
.append(
std::declval<I>(),
std::declval<I>())
),
// T::assign(I, I)
decltype(
std::declval<T&>()
.assign(
std::declval<I>(),
std::declval<I>())
)>>
: std::true_type
{};
}

template <class T, class I, class = void>
struct is_mutable_string : std::false_type {};

template <class T, class I>
struct is_mutable_string<
T, I,
typename std::enable_if<
detail::has_value_type<T>::value &&
detail::has_assign_and_append<T, I>::value
>::type>
: std::is_same<typename T::value_type, char>
{};
#endif

} // grammar
} // urls
} // boost

#endif

0 comments on commit f3e9885

Please sign in to comment.