7
7
#include < cstdint>
8
8
#include < optional>
9
9
10
- namespace fly ::detail {
10
+ namespace fly {
11
11
12
12
/* *
13
13
* Helper class to perform lexical analysis of a C-string literal. All methods are constant
@@ -19,15 +19,14 @@ namespace fly::detail {
19
19
template <typename StringType>
20
20
class BasicStringLexer
21
21
{
22
- using traits = BasicStringTraits<StringType>;
23
- using classifier = BasicStringClassifier<StringType>;
22
+ using traits = detail:: BasicStringTraits<StringType>;
23
+ using classifier = detail:: BasicStringClassifier<StringType>;
24
24
using char_type = typename traits::char_type;
25
25
using view_type = typename traits::view_type;
26
26
27
27
public:
28
28
/* *
29
- * Constructor. Stores a view into a C-string literal. This class is not interested in the null
30
- * terminator, thus if provided, it is excluded from the view.
29
+ * Constructor. Stores a view into a C-string literal.
31
30
*
32
31
* @tparam N The size of the C-string literal.
33
32
*
@@ -36,6 +35,13 @@ class BasicStringLexer
36
35
template <std::size_t N>
37
36
constexpr explicit BasicStringLexer (const char_type (&literals)[N]) noexcept ;
38
37
38
+ /* *
39
+ * Constructor. Stores an existing view into a string.
40
+ *
41
+ * @param view The existing view into the string.
42
+ */
43
+ constexpr explicit BasicStringLexer (view_type view) noexcept ;
44
+
39
45
/* *
40
46
* @return A string view into the C-string literal.
41
47
*/
@@ -116,6 +122,14 @@ constexpr BasicStringLexer<StringType>::BasicStringLexer(const char_type (&liter
116
122
{
117
123
}
118
124
125
+ // ==================================================================================================
126
+ template <typename StringType>
127
+ constexpr BasicStringLexer<StringType>::BasicStringLexer(view_type view) noexcept :
128
+ m_size(view.size()),
129
+ m_view(std::move(view))
130
+ {
131
+ }
132
+
119
133
// ==================================================================================================
120
134
template <typename StringType>
121
135
constexpr auto BasicStringLexer<StringType>::view() const -> view_type
@@ -199,4 +213,4 @@ constexpr std::optional<std::size_t> BasicStringLexer<StringType>::consume_numbe
199
213
return parsed_number ? std::optional<std::size_t >(number) : std::nullopt;
200
214
}
201
215
202
- } // namespace fly::detail
216
+ } // namespace fly
0 commit comments