1
1
#pragma once
2
2
3
3
#include " fly/traits/traits.hpp"
4
+ #include " fly/types/string/detail/string_classifier.hpp"
4
5
#include " fly/types/string/detail/string_converter.hpp"
5
6
#include " fly/types/string/detail/string_formatter.hpp"
6
7
#include " fly/types/string/detail/string_streamer.hpp"
@@ -51,6 +52,7 @@ using String32Traits = detail::BasicStringTraits<std::u32string>;
51
52
template <typename StringType>
52
53
class BasicString
53
54
{
55
+ using classifier = detail::BasicStringClassifier<StringType>;
54
56
using formatter = detail::BasicStringFormatter<StringType>;
55
57
using streamer = detail::BasicStringStreamer<StringType>;
56
58
using traits = detail::BasicStringTraits<StringType>;
@@ -61,6 +63,7 @@ class BasicString
61
63
using size_type = typename traits::size_type;
62
64
using char_type = typename traits::char_type;
63
65
using view_type = typename traits::view_type;
66
+ using int_type = typename traits::int_type;
64
67
using codepoint_type = typename traits::codepoint_type;
65
68
using ostream_type = typename traits::ostream_type;
66
69
using streamed_type = typename traits::streamed_type;
@@ -78,6 +81,33 @@ class BasicString
78
81
template <typename T, enable_if<detail::is_like_supported_string<T>> = 0 >
79
82
static size_type size (const T &value);
80
83
84
+ /* *
85
+ * Checks if the given character is an alphabetic character as classified by the default C
86
+ * locale.
87
+ *
88
+ * The STL's std::isalpha and std::iswalpha require that the provided character fits into an
89
+ * unsigned char and unsigned wchar_t, respectively. Other values result in undefined behavior.
90
+ * This method has no such restriction.
91
+ *
92
+ * @param ch The character to classify.
93
+ *
94
+ * @return True if the character is an alphabetic character.
95
+ */
96
+ static bool is_alpha (char_type ch);
97
+
98
+ /* *
99
+ * Checks if the given character is a decimal digit character.
100
+ *
101
+ * The STL's std::isdigit and std::iswdigit require that the provided character fits into an
102
+ * unsigned char and unsigned wchar_t, respectively. Other values result in undefined behavior.
103
+ * This method has no such restriction.
104
+ *
105
+ * @param ch The character to classify.
106
+ *
107
+ * @return True if the character is a decimal digit character.
108
+ */
109
+ static bool is_digit (char_type ch);
110
+
81
111
/* *
82
112
* Split a string into a vector of strings.
83
113
*
@@ -421,6 +451,20 @@ auto BasicString<StringType>::size(const T &value) -> size_type
421
451
}
422
452
}
423
453
454
+ // ==================================================================================================
455
+ template <typename StringType>
456
+ inline bool BasicString<StringType>::is_alpha(char_type ch)
457
+ {
458
+ return classifier::is_alpha (ch);
459
+ }
460
+
461
+ // ==================================================================================================
462
+ template <typename StringType>
463
+ inline bool BasicString<StringType>::is_digit(char_type ch)
464
+ {
465
+ return classifier::is_digit (ch);
466
+ }
467
+
424
468
// ==================================================================================================
425
469
template <typename StringType>
426
470
std::vector<StringType> BasicString<StringType>::split(const StringType &input, char_type delimiter)
0 commit comments