1  
//
1  
//
2  
// Copyright (c) 2021 Vinnie Falco (vinnie dot falco at gmail dot com)
2  
// Copyright (c) 2021 Vinnie Falco (vinnie dot falco at gmail dot com)
3  
//
3  
//
4  
// Distributed under the Boost Software License, Version 1.0. (See accompanying
4  
// Distributed under the Boost Software License, Version 1.0. (See accompanying
5  
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5  
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6  
//
6  
//
7  
// Official repository: https://github.com/boostorg/url
7  
// Official repository: https://github.com/boostorg/url
8  
//
8  
//
9  

9  

10  
#ifndef BOOST_URL_GRAMMAR_VCHARS_HPP
10  
#ifndef BOOST_URL_GRAMMAR_VCHARS_HPP
11  
#define BOOST_URL_GRAMMAR_VCHARS_HPP
11  
#define BOOST_URL_GRAMMAR_VCHARS_HPP
12  

12  

13  
#include <boost/url/detail/config.hpp>
13  
#include <boost/url/detail/config.hpp>
14  
#include <boost/url/grammar/detail/charset.hpp>
14  
#include <boost/url/grammar/detail/charset.hpp>
15  

15  

16  
namespace boost {
16  
namespace boost {
17  
namespace urls {
17  
namespace urls {
18  
namespace grammar {
18  
namespace grammar {
19  
namespace implementation_defined {
19  
namespace implementation_defined {
20  
struct vchars_t
20  
struct vchars_t
21  
{
21  
{
22  
    constexpr
22  
    constexpr
23  
    bool
23  
    bool
24  
    operator()(char c) const noexcept
24  
    operator()(char c) const noexcept
25  
    {
25  
    {
26  
        return c >= 0x21 && c <= 0x7e;
26  
        return c >= 0x21 && c <= 0x7e;
27  
    }
27  
    }
28  

28  

29  
#ifdef BOOST_URL_USE_SSE2
29  
#ifdef BOOST_URL_USE_SSE2
30  
    char const*
30  
    char const*
31  
    find_if(
31  
    find_if(
32  
        char const* first,
32  
        char const* first,
33  
        char const* last) const noexcept
33  
        char const* last) const noexcept
34  
    {
34  
    {
35  
        return detail::find_if_pred(
35  
        return detail::find_if_pred(
36  
            *this, first, last);
36  
            *this, first, last);
37  
    }
37  
    }
38  

38  

39  
    char const*
39  
    char const*
40  
    find_if_not(
40  
    find_if_not(
41  
        char const* first,
41  
        char const* first,
42  
        char const* last) const noexcept
42  
        char const* last) const noexcept
43  
    {
43  
    {
44  
        return detail::find_if_not_pred(
44  
        return detail::find_if_not_pred(
45  
            *this, first, last);
45  
            *this, first, last);
46  
    }
46  
    }
47  
#endif
47  
#endif
48  
};
48  
};
49  
} // implementation_defined
49  
} // implementation_defined
50  

50  

51  
/** The set of visible characters
51  
/** The set of visible characters
52  

52  

53  
    @par Example
53  
    @par Example
54  
    Character sets are used with rules and the
54  
    Character sets are used with rules and the
55  
    functions @ref find_if and @ref find_if_not.
55  
    functions @ref find_if and @ref find_if_not.
56  
    @code
56  
    @code
57  
    system::result< core::string_view > rv = parse( "JohnDoe", token_rule( vchars ) );
57  
    system::result< core::string_view > rv = parse( "JohnDoe", token_rule( vchars ) );
58  
    @endcode
58  
    @endcode
59  

59  

60  
    @par BNF
60  
    @par BNF
61  
    @code
61  
    @code
62  
    VCHAR       = 0x21-0x7E
62  
    VCHAR       = 0x21-0x7E
63  
                ; visible (printing) characters
63  
                ; visible (printing) characters
64  
    @endcode
64  
    @endcode
65  

65  

66  
    @par Specification
66  
    @par Specification
67  
    @li <a href="https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1"
67  
    @li <a href="https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1"
68  
        >B.1. Core Rules (rfc5234)</a>
68  
        >B.1. Core Rules (rfc5234)</a>
69  

69  

70  
    @see
70  
    @see
71  
        @ref find_if,
71  
        @ref find_if,
72  
        @ref find_if_not,
72  
        @ref find_if_not,
73  
        @ref parse,
73  
        @ref parse,
74  
        @ref token_rule.
74  
        @ref token_rule.
75  
*/
75  
*/
76  
constexpr implementation_defined::vchars_t vchars{};
76  
constexpr implementation_defined::vchars_t vchars{};
77  

77  

78  
} // grammar
78  
} // grammar
79  
} // urls
79  
} // urls
80  
} // boost
80  
} // boost
81  

81  

82  
#endif
82  
#endif