GCC Code Coverage Report


Directory: libs/url/
File: boost/url/grammar/token_rule.hpp
Date: 2024-03-13 19:32:03
Exec Total Coverage
Lines: 5 5 100.0%
Functions: 14 14 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 //
2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
3 //
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)
6 //
7 // Official repository: https://github.com/boostorg/http_proto
8 //
9
10 #ifndef BOOST_URL_GRAMMAR_TOKEN_RULE_HPP
11 #define BOOST_URL_GRAMMAR_TOKEN_RULE_HPP
12
13 #include <boost/url/detail/config.hpp>
14 #include <boost/url/grammar/charset.hpp>
15 #include <boost/url/error_types.hpp>
16 #include <boost/core/detail/string_view.hpp>
17
18 namespace boost {
19 namespace urls {
20 namespace grammar {
21
22 /** Match a non-empty string of characters from a set
23
24 If there is no more input, the error code
25 @ref error::need_more is returned.
26
27 @par Value Type
28 @code
29 using value_type = core::string_view;
30 @endcode
31
32 @par Example
33 Rules are used with the function @ref parse.
34 @code
35 system::result< core::string_view > rv = parse( "abcdef", token_rule( alpha_chars ) );
36 @endcode
37
38 @par BNF
39 @code
40 token = 1*( ch )
41 @endcode
42
43 @param cs The character set to use
44
45 @see
46 @ref alpha_chars,
47 @ref parse.
48 */
49 #ifdef BOOST_URL_DOCS
50 template<class CharSet>
51 constexpr
52 __implementation_defined__
53 token_rule(
54 CharSet cs) noexcept;
55 #else
56 template<class CharSet>
57 struct token_rule_t
58 {
59 using value_type = core::string_view;
60
61 static_assert(
62 is_charset<CharSet>::value,
63 "CharSet requirements not met");
64
65 auto
66 parse(
67 char const*& it,
68 char const* end
69 ) const noexcept ->
70 system::result<value_type>;
71
72 private:
73 template<class CharSet_>
74 friend
75 constexpr
76 auto
77 token_rule(
78 CharSet_ const&) noexcept ->
79 token_rule_t<CharSet_>;
80
81 constexpr
82 179 token_rule_t(
83 CharSet const& cs) noexcept
84 179 : cs_(cs)
85 {
86 179 }
87
88 CharSet const cs_;
89 };
90
91 template<class CharSet>
92 constexpr
93 auto
94 103 token_rule(
95 CharSet const& cs) noexcept ->
96 token_rule_t<CharSet>
97 {
98 103 return {cs};
99 }
100 #endif
101
102 } // grammar
103 } // urls
104 } // boost
105
106 #include <boost/url/grammar/impl/token_rule.hpp>
107
108 #endif
109