Fix crash on startup if an LV2 plugin has a bad .ttl file.
[ardour.git] / libs / glibmm2 / glib / src / unicode.hg
1 /* $Id: unicode.hg,v 1.2 2003/08/20 10:31:23 murrayc Exp $ */
2
3 /* Copyright (C) 2002 The gtkmm Development Team
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the Free
17  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19
20 _DEFS(glibmm,glib)
21
22 #m4begin
23 _PUSH()
24
25 // m4 helper macros to generate the character-class inline functions.
26
27 m4_define(`_UNICHAR_FUNC',`dnl
28 inline $1 $2(gunichar uc)
29   { return g_unichar_$2(uc); }
30 `'dnl`'')
31
32 //MSVC++ needs the != 0 to avoid an int -> bool cast warning.
33 m4_define(`_UNICHAR_FUNC_BOOL',`dnl
34 inline $1 $2(gunichar uc)
35   { return (g_unichar_$2(uc) != 0); }
36 `'dnl`'')
37
38 m4_define(`_ASCII_FUNC',`dnl
39 inline $1 $2(char c)
40   { return g_ascii_$2(c); }
41 `'dnl`'')
42
43 _POP()
44 #m4end
45
46 #include <glib.h>
47
48 // Not used, but we want to get rid of possible <ctype.h> macros.
49 #include <cctype>
50
51 #undef isalnum
52 #undef isalpha
53 #undef iscntrl
54 #undef isdigit
55 #undef isgraph
56 #undef islower
57 #undef isprint
58 #undef ispunct
59 #undef isspace
60 #undef isupper
61 #undef isxdigit
62 #undef istitle
63 #undef isdefined
64 #undef iswide
65 #undef toupper
66 #undef tolower
67 #undef totitle
68
69
70 namespace Glib
71 {
72
73 _WRAP_ENUM(UnicodeType, GUnicodeType, NO_GTYPE)
74 _WRAP_ENUM(UnicodeBreakType, GUnicodeBreakType, NO_GTYPE)
75 _WRAP_ENUM(AsciiType, GAsciiType, NO_GTYPE)
76 _WRAP_ENUM(NormalizeMode, GNormalizeMode, NO_GTYPE)
77
78 /** @defgroup Unicode Unicode Manipulation
79  * Functions operating on Unicode characters and UTF-8 strings.
80  * @{
81  */
82
83 namespace Unicode
84 {
85
86 _UNICHAR_FUNC_BOOL(bool, validate)
87 _UNICHAR_FUNC_BOOL(bool, isalnum)
88 _UNICHAR_FUNC_BOOL(bool, isalpha)
89 _UNICHAR_FUNC_BOOL(bool, iscntrl)
90 _UNICHAR_FUNC_BOOL(bool, isdigit)
91 _UNICHAR_FUNC_BOOL(bool, isgraph)
92 _UNICHAR_FUNC_BOOL(bool, islower)
93 _UNICHAR_FUNC_BOOL(bool, isprint)
94 _UNICHAR_FUNC_BOOL(bool, ispunct)
95 _UNICHAR_FUNC_BOOL(bool, isspace)
96 _UNICHAR_FUNC_BOOL(bool, isupper)
97 _UNICHAR_FUNC_BOOL(bool, isxdigit)
98 _UNICHAR_FUNC_BOOL(bool, istitle)
99 _UNICHAR_FUNC_BOOL(bool, isdefined)
100 _UNICHAR_FUNC_BOOL(bool, iswide)
101
102 _UNICHAR_FUNC(gunichar, toupper)
103 _UNICHAR_FUNC(gunichar, tolower)
104 _UNICHAR_FUNC(gunichar, totitle)
105
106 _UNICHAR_FUNC(int, digit_value)
107 _UNICHAR_FUNC(int, xdigit_value)
108
109 inline Glib::UnicodeType type(gunichar uc)
110   { return static_cast<Glib::UnicodeType>(static_cast<int>(g_unichar_type(uc))); }
111
112 inline Glib::UnicodeBreakType break_type(gunichar uc)
113   { return static_cast<Glib::UnicodeBreakType>(static_cast<int>(g_unichar_break_type(uc))); }
114
115 } // namespace Unicode
116
117
118 namespace Ascii
119 {
120
121 _ASCII_FUNC(bool, isalnum)
122 _ASCII_FUNC(bool, isalpha)
123 _ASCII_FUNC(bool, iscntrl)
124 _ASCII_FUNC(bool, isdigit)
125 _ASCII_FUNC(bool, isgraph)
126 _ASCII_FUNC(bool, islower)
127 _ASCII_FUNC(bool, isprint)
128 _ASCII_FUNC(bool, ispunct)
129 _ASCII_FUNC(bool, isspace)
130 _ASCII_FUNC(bool, isupper)
131 _ASCII_FUNC(bool, isxdigit)
132
133 _ASCII_FUNC(char, tolower)
134 _ASCII_FUNC(char, toupper)
135
136 _ASCII_FUNC(int, digit_value)
137 _ASCII_FUNC(int, xdigit_value)
138
139 } // namespace Ascii
140
141
142 /** @} group Unicode */
143
144 } // namespace Glib
145