Skip to content

Commit 3fd2973

Browse files
committed
#30 - Implement method CppStringT::isspace()
Completed.
1 parent 266fe34 commit 3fd2973

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

cpp-strings/cppstrings.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222

2323
//=============================================================
24+
#include <algorithm>
2425
#include <string>
2526
#include <vector>
2627
//#include <initializer_list>
@@ -113,12 +114,30 @@ class CppStringT : public std::basic_string<CharT>
113114
return _ASCII_PUNCT_DATA.contains(ch);
114115
}
115116

117+
//--- is_space ----------------------------------------
118+
/** \brief Returns true if there are only whitespace characters in the string and there is at least one character, or false otherwise.
119+
*
120+
* Notice for version 2.0 of this library: a character is whitespace if
121+
* in the Unicode character database, either its general category is Zs
122+
* (“Separator, space”), or its bidirectional class is one of WS, B, or S.
123+
*/
124+
inline const bool is_space(const MyBaseClass& str) noexcept
125+
{
126+
if (str.size() == 0)
127+
return false;
128+
for (auto& c : str)
129+
if (std::find(str.cbegin(), str.cend(), c) == str.cend())
130+
return false;
131+
return true;
132+
}
133+
116134

117135
protected:
118136

119137

120138
private:
121139
//=== DATA ============================================
122140
static inline constexpr std::vector<value_type> _ASCII_PUNCT_DATA{ '!', ',', '.', ':', ';', '?' };
141+
static inline constexpr std::vector<value_type> _ASCII_SEP{ ' ', '\t', '\n', 'r', '\f' };
123142

124143
};

0 commit comments

Comments
 (0)