GCC Code Coverage Report


Directory: libs/url/
File: boost/url/grammar/token_rule.hpp
Date: 2024-08-19 20:08:56
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 namespace implementation_defined {
57 template<class CharSet>
58 struct token_rule_t
59 {
60 using value_type = core::string_view;
61
62 static_assert(
63 is_charset<CharSet>::value,
64 "CharSet requirements not met");
65
66 auto
67 parse(
68 char const*& it,
69 char const* end
70 ) const noexcept ->
71 system::result<value_type>;
72
73 constexpr
74 179 token_rule_t(
75 CharSet const& cs) noexcept
76 179 : cs_(cs)
77 {
78 179 }
79
80 private:
81 CharSet const cs_;
82 };
83 }
84
85 /** Match a non-empty string of characters from a set
86
87 If there is no more input, the error code
88 @ref error::need_more is returned.
89
90 @par Value Type
91 @code
92 using value_type = core::string_view;
93 @endcode
94
95 @par Example
96 Rules are used with the function @ref parse.
97 @code
98 system::result< core::string_view > rv = parse( "abcdef", token_rule( alpha_chars ) );
99 @endcode
100
101 @par BNF
102 @code
103 token = 1*( ch )
104 @endcode
105
106 @param cs The character set to use
107
108 @see
109 @ref alpha_chars,
110 @ref parse.
111 */
112 template<class CharSet>
113 constexpr
114 auto
115 103 token_rule(
116 CharSet const& cs) noexcept ->
117 implementation_defined::token_rule_t<CharSet>
118 {
119 103 return {cs};
120 }
121 #endif
122
123 } // grammar
124 } // urls
125 } // boost
126
127 #include <boost/url/grammar/impl/token_rule.hpp>
128
129 #endif
130