2
0
mirror of https://github.com/boostorg/url.git synced 2026-02-17 02:02:11 +00:00
Files
url/doc/qbk/CharSet.qbk
Vinnie Falco c7e180a840 Doc work
2021-10-08 21:08:21 -07:00

131 lines
3.7 KiB
Plaintext

[/
Copyright (c) 2021 Vinnie Falco (vinnie.falco@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:CharSet CharSet]
A ['CharSet] is a unary predicate which accepts as its single
argument a value of type `char`. The return value of the predicate
is a `bool` whose value is true if the character is a member of the
notional character set, or false otherwise. A character set can be
used to specify which characters are unreserved and thus, do not
need to be escaped when used in percent-encoding algorithms.
Character sets may also be used by parsers; some character sets
have optimized implementations for finding matching elements.
[heading Associated Types]
* [link url.ref.boost__urls__bnf__is_charset `is_charset`]
[heading Requirements]
In this table:
* `T` is a type meeting the requirements of ['CharSet]
* `t` is a `const` value of type `T`
* `c` is a value of type `char`
* `first`, `last` are values of type `char const*`
[table Valid expressions
[[Expression] [Type] [Semantics, Pre/Post-conditions]]
[
[`T t;`]
[]
[
T is __DefaultConstructible__.
]
][
[`t.operator()( c );`]
[`bool`]
[
This function returns `true` if `c` is a member of
the character set, otherwise it returns `false`.
]
][
[
```
t.find_if(
first, last )
```
]
[`char const*`]
[
This optional member function examines the valid
range of characters in `[first, last)` and returns
a pointer to the first occurrence of a character
which is in the set, or returns `last` if no such
character.
The implementation of
[link url.ref.boost__urls__bnf__find_if `find_if`]
will call this function if provided by the character
set, allowing optimized or otherwise performant
implementations to be developed. If this member
function is not provided, a default implementation
is used which calls `operator()`.
]
][
[
```
t.find_if_not(
first, last )
```
]
[`char const*`]
[
This optional member function examines the valid
range of characters in `[first, last)` and returns
a pointer to the first occurrence of a character
which is not in the set, or returns `last` if no
such character.
The implementation of
[link url.ref.boost__urls__bnf__find_if_not `find_if_not`]
will call this function if provided by the character
set, allowing optimized or otherwise performant
implementations to be developed. If this member
function is not provided, a default implementation
is used which calls `operator()`.
]
]]
[heading Exemplar]
```
struct CharSet
{
bool operator()( char c ) const noexcept;
char const* find_if( char const* first, char const* last ) const noexcept;
char const* find_if_not( char const* first, char const* last ) const noexcept;
};
```
[heading Example]
```
struct digit_chars
{
constexpr bool operator()(char c) const noexcept
{
return c >= '0' && c <= '9';
}
};
```
[heading Models]
* [link url.ref.boost__urls__bnf__all_chars `bnf::all_chars`]
* [link url.ref.boost__urls__bnf__alnum_chars `bnf::alnum_chars`]
* [link url.ref.boost__urls__bnf__alpha_chars `bnf::alpha_chars`]
* [link url.ref.boost__urls__bnf__digit_chars `bnf::digit_chars`]
* [link url.ref.boost__urls__bnf__hexdig_chars `bnf::hexdig_chars`]
* [link url.ref.boost__urls__bnf__lut_chars `bnf::lut_chars`]
* [link url.ref.boost__urls__bnf__pred_chars `bnf::pred_chars`]
[endsect]