@@ -27,15 +27,15 @@ namespace fly::detail {
27
27
* @author Timothy Flynn ([email protected] )
28
28
* @version January 3, 2021
29
29
*/
30
- template <typename StringType , typename ... ParameterTypes>
30
+ template <typename CharType , typename ... ParameterTypes>
31
31
class BasicFormatString
32
32
{
33
- using traits = BasicStringTraits<StringType >;
34
- using char_type = typename traits::char_type ;
35
- using lexer = fly::BasicLexer<char_type >;
33
+ using string_type = std::basic_string<CharType >;
34
+ using traits = BasicStringTraits<string_type> ;
35
+ using lexer = fly::BasicLexer<CharType >;
36
36
using view_type = typename traits::view_type;
37
37
38
- using FormatSpecifier = BasicFormatSpecifier<char_type >;
38
+ using FormatSpecifier = BasicFormatSpecifier<CharType >;
39
39
40
40
enum class ParameterType : std::uint8_t
41
41
{
@@ -59,7 +59,7 @@ class BasicFormatString
59
59
* Constructor. Parse and validate a C-string literal as a format string.
60
60
*/
61
61
template <std::size_t N>
62
- FLY_CONSTEVAL BasicFormatString (const char_type (&format)[N]) noexcept ;
62
+ FLY_CONSTEVAL BasicFormatString (const CharType (&format)[N]) noexcept ;
63
63
64
64
BasicFormatString (BasicFormatString &&) = default;
65
65
BasicFormatString &operator =(BasicFormatString &&) = default;
@@ -91,7 +91,7 @@ class BasicFormatString
91
91
std::optional<FormatSpecifier> next_specifier ();
92
92
93
93
private:
94
- friend BasicFormatSpecifier<char_type >;
94
+ friend BasicFormatSpecifier<CharType >;
95
95
96
96
BasicFormatString (const BasicFormatString &) = delete ;
97
97
BasicFormatString &operator =(const BasicFormatString &) = delete ;
@@ -142,9 +142,9 @@ class BasicFormatString
142
142
*/
143
143
void on_error (const char *error);
144
144
145
- static constexpr const auto s_left_brace = FLY_CHR(char_type , ' {' );
146
- static constexpr const auto s_right_brace = FLY_CHR(char_type , ' }' );
147
- static constexpr const auto s_colon = FLY_CHR(char_type , ' :' );
145
+ static constexpr const auto s_left_brace = FLY_CHR(CharType , ' {' );
146
+ static constexpr const auto s_right_brace = FLY_CHR(CharType , ' }' );
147
+ static constexpr const auto s_colon = FLY_CHR(CharType , ' :' );
148
148
149
149
lexer m_lexer;
150
150
@@ -160,13 +160,13 @@ class BasicFormatString
160
160
};
161
161
162
162
// ==================================================================================================
163
- template <typename StringType , typename ... ParameterTypes>
163
+ template <typename CharType , typename ... ParameterTypes>
164
164
template <std::size_t N>
165
- FLY_CONSTEVAL BasicFormatString<StringType , ParameterTypes...>::BasicFormatString(
166
- const char_type (&format)[N]) noexcept :
165
+ FLY_CONSTEVAL BasicFormatString<CharType , ParameterTypes...>::BasicFormatString(
166
+ const CharType (&format)[N]) noexcept :
167
167
m_lexer(format)
168
168
{
169
- std::optional<char_type > ch;
169
+ std::optional<CharType > ch;
170
170
171
171
if constexpr (!(BasicFormatTraits::is_formattable_v<ParameterTypes> && ...))
172
172
{
@@ -203,29 +203,29 @@ FLY_CONSTEVAL BasicFormatString<StringType, ParameterTypes...>::BasicFormatStrin
203
203
}
204
204
205
205
// ==================================================================================================
206
- template <typename StringType , typename ... ParameterTypes>
207
- constexpr auto BasicFormatString<StringType , ParameterTypes...>::view() const -> view_type
206
+ template <typename CharType , typename ... ParameterTypes>
207
+ constexpr auto BasicFormatString<CharType , ParameterTypes...>::view() const -> view_type
208
208
{
209
209
return m_lexer.view ();
210
210
}
211
211
212
212
// ==================================================================================================
213
- template <typename StringType , typename ... ParameterTypes>
214
- constexpr bool BasicFormatString<StringType , ParameterTypes...>::has_error() const
213
+ template <typename CharType , typename ... ParameterTypes>
214
+ constexpr bool BasicFormatString<CharType , ParameterTypes...>::has_error() const
215
215
{
216
216
return !m_error.empty ();
217
217
}
218
218
219
219
// ==================================================================================================
220
- template <typename StringType , typename ... ParameterTypes>
221
- std::string BasicFormatString<StringType , ParameterTypes...>::error() const
220
+ template <typename CharType , typename ... ParameterTypes>
221
+ std::string BasicFormatString<CharType , ParameterTypes...>::error() const
222
222
{
223
223
return std::string (m_error);
224
224
}
225
225
226
226
// ==================================================================================================
227
- template <typename StringType , typename ... ParameterTypes>
228
- auto BasicFormatString<StringType , ParameterTypes...>::next_specifier()
227
+ template <typename CharType , typename ... ParameterTypes>
228
+ auto BasicFormatString<CharType , ParameterTypes...>::next_specifier()
229
229
-> std::optional<FormatSpecifier>
230
230
{
231
231
if (m_specifier_index >= m_specifier_count)
@@ -237,9 +237,9 @@ auto BasicFormatString<StringType, ParameterTypes...>::next_specifier()
237
237
}
238
238
239
239
// ==================================================================================================
240
- template <typename StringType , typename ... ParameterTypes>
240
+ template <typename CharType , typename ... ParameterTypes>
241
241
constexpr auto
242
- BasicFormatString<StringType , ParameterTypes...>::parse_specifier(SpecifierType specifier_type)
242
+ BasicFormatString<CharType , ParameterTypes...>::parse_specifier(SpecifierType specifier_type)
243
243
-> std::optional<FormatSpecifier>
244
244
{
245
245
// The opening { will have already been consumed, so the starting position is one less.
@@ -299,8 +299,8 @@ BasicFormatString<StringType, ParameterTypes...>::parse_specifier(SpecifierType
299
299
}
300
300
301
301
// ==================================================================================================
302
- template <typename StringType , typename ... ParameterTypes>
303
- constexpr std::size_t BasicFormatString<StringType , ParameterTypes...>::parse_position()
302
+ template <typename CharType , typename ... ParameterTypes>
303
+ constexpr std::size_t BasicFormatString<CharType , ParameterTypes...>::parse_position()
304
304
{
305
305
if (auto position = m_lexer.consume_number (); position)
306
306
{
@@ -315,9 +315,9 @@ constexpr std::size_t BasicFormatString<StringType, ParameterTypes...>::parse_po
315
315
}
316
316
317
317
// ==================================================================================================
318
- template <typename StringType , typename ... ParameterTypes>
318
+ template <typename CharType , typename ... ParameterTypes>
319
319
template <size_t N>
320
- constexpr auto BasicFormatString<StringType , ParameterTypes...>::parameter_type(size_t index)
320
+ constexpr auto BasicFormatString<CharType , ParameterTypes...>::parameter_type(size_t index)
321
321
-> std::optional<ParameterType>
322
322
{
323
323
if constexpr (N < sizeof ...(ParameterTypes))
@@ -366,8 +366,8 @@ constexpr auto BasicFormatString<StringType, ParameterTypes...>::parameter_type(
366
366
}
367
367
368
368
// ==================================================================================================
369
- template <typename StringType , typename ... ParameterTypes>
370
- void BasicFormatString<StringType , ParameterTypes...>::on_error(const char *error)
369
+ template <typename CharType , typename ... ParameterTypes>
370
+ void BasicFormatString<CharType , ParameterTypes...>::on_error(const char *error)
371
371
{
372
372
if (!has_error ())
373
373
{
0 commit comments