2 * Copyright 2008-2013, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
6 #include "TerminalCharClassifier.h"
13 // #pragma mark - TerminalCharClassifier
16 TerminalCharClassifier::~TerminalCharClassifier()
21 // #pragma mark - DefaultCharClassifier
24 DefaultCharClassifier::DefaultCharClassifier(const char* additionalWordChars
)
26 const char* p
= additionalWordChars
;
27 while (p
!= NULL
&& *p
!= '\0') {
28 int count
= UTF8Char::ByteCount(*p
);
29 if (count
<= 0 || count
> 4)
31 fAdditionalWordChars
.push_back(UTF8Char(p
, count
));
38 DefaultCharClassifier::Classify(const UTF8Char
& character
)
40 if (character
.IsSpace())
41 return CHAR_TYPE_SPACE
;
43 if (character
.IsAlNum())
44 return CHAR_TYPE_WORD_CHAR
;
46 if (std::find(fAdditionalWordChars
.begin(), fAdditionalWordChars
.end(),
47 character
) != fAdditionalWordChars
.end()) {
48 return CHAR_TYPE_WORD_CHAR
;
51 return CHAR_TYPE_WORD_DELIMITER
;