xref: /MusicPlayer2/scintilla/src/CharClassify.h (revision 443d2d2511be730d1b1dd3181942b7fa6539aa1a)
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 <[email protected]>
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 
11 namespace Scintilla {
12 
13 class CharClassify {
14 public:
15 	CharClassify();
16 
17 	enum cc { ccSpace, ccNewLine, ccWord, ccPunctuation };
18 	void SetDefaultCharClasses(bool includeWordClass);
19 	void SetCharClasses(const unsigned char *chars, cc newCharClass);
20 	int GetCharsOfClass(cc characterClass, unsigned char *buffer) const noexcept;
21 	cc GetClass(unsigned char ch) const noexcept { return static_cast<cc>(charClass[ch]);}
22 	bool IsWord(unsigned char ch) const noexcept { return static_cast<cc>(charClass[ch]) == ccWord;}
23 
24 private:
25 	enum { maxChar=256 };
26 	unsigned char charClass[maxChar];    // not type cc to save space
27 };
28 
29 }
30 
31 #endif
32