aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/CharClassify.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/CharClassify.cxx')
-rw-r--r--src/CharClassify.cxx16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/CharClassify.cxx b/src/CharClassify.cxx
index c16af4547..7e3db737e 100644
--- a/src/CharClassify.cxx
+++ b/src/CharClassify.cxx
@@ -46,3 +46,19 @@ void CharClassify::SetCharClasses(const unsigned char *chars, cc newCharClass) {
}
}
}
+
+int CharClassify::GetCharsOfClass(cc characterClass, unsigned char *buffer) {
+ // Get characters belonging to the given char class; return the number
+ // of characters (if the buffer is NULL, don't write to it).
+ int count = 0;
+ for (int ch = maxChar - 1; ch >= 0; --ch) {
+ if (charClass[ch] == characterClass) {
+ ++count;
+ if (buffer) {
+ *buffer = static_cast<unsigned char>(ch);
+ buffer++;
+ }
+ }
+ }
+ return count;
+}