]> git.lyx.org Git - lyx.git/blob - src/support/textutils.h
40521ec461b928659229b02c1394b80d5a4048a8
[lyx.git] / src / support / textutils.h
1 // -*- C++ -*-
2 /**
3  * \file textutils.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Matthias Ettrich
8  * \author Lars Gullik Bjønnes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 // FIXME: I can think of a better name for this file ...
14
15 #ifndef TEXTUTILS_H
16 #define TEXTUTILS_H
17
18 #include "support/types.h"
19
20
21 namespace lyx {
22
23 /// return true if the char is a line separator
24 inline
25 bool isLineSeparatorChar(lyx::char_type c)
26 {
27         return c == ' ';
28 }
29
30
31 /// return true if a char is alphabetical (including accented chars)
32 inline
33 bool isLetterChar(lyx::char_type c)
34 {
35         return (c >= 'A' && c <= 'Z')
36                 || (c >= 'a' && c <= 'z')
37                 || (c >= 192 && c < 256); // in iso-8859-x these are accented chars
38 }
39
40
41 /// return true if the char is printable (masked to 7-bit ASCII)
42 inline
43 bool isPrintable(lyx::char_type c)
44 {
45         return (c & 127) >= ' ';
46 }
47
48
49 /// return true if the char is printable and not a space (masked to 7-bit ASCII)
50 inline
51 bool isPrintableNonspace(lyx::char_type c)
52 {
53         return isPrintable(c) && c != ' ';
54 }
55
56 /// return true if a unicode char is a digit.
57 inline
58 bool isDigit(lyx::char_type ch)
59 {
60         return ch >= '0' && ch <= '9';
61 }
62
63
64
65 } // namespace lyx
66
67 #endif // TEXTUTILS_H