1// Scintilla source code edit control
2/** @file CharClassify.h
3 ** Character classifications used by Document and RESearch.
4 **/
5// Copyright 2006-2009 by Neil Hodgson <neilh@scintilla.org>
6// The License.txt file describes the conditions under which this software may be distributed.
7
8#ifndef CHARCLASSIFY_H
9#define CHARCLASSIFY_H
10
11namespace Scintilla::Internal {
12
13enum class CharacterClass : unsigned char { space, newLine, word, punctuation };
14
15class CharClassify {
16public:
17 CharClassify();
18
19 void SetDefaultCharClasses(bool includeWordClass);
20 void SetCharClasses(const unsigned char *chars, CharacterClass newCharClass);
21 int GetCharsOfClass(CharacterClass characterClass, unsigned char *buffer) const noexcept;
22 CharacterClass GetClass(unsigned char ch) const noexcept { return charClass[ch];}
23 bool IsWord(unsigned char ch) const noexcept { return charClass[ch] == CharacterClass::word;}
24
25private:
26 static constexpr int maxChar=256;
27 CharacterClass charClass[maxChar];
28};
29
30}
31
32#endif
33