1 /* $Id: unicode.hg,v 1.2 2003/08/20 10:31:23 murrayc Exp $ */
3 /* Copyright (C) 2002 The gtkmm Development Team
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.
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.
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.
25 // m4 helper macros to generate the character-class inline functions.
27 m4_define(`_UNICHAR_FUNC',`dnl
28 inline $1 $2(gunichar uc)
29 { return g_unichar_$2(uc); }
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); }
38 m4_define(`_ASCII_FUNC',`dnl
40 { return g_ascii_$2(c); }
48 // Not used, but we want to get rid of possible <ctype.h> macros.
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)
78 /** @defgroup Unicode Unicode Manipulation
79 * Functions operating on Unicode characters and UTF-8 strings.
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)
102 _UNICHAR_FUNC(gunichar, toupper)
103 _UNICHAR_FUNC(gunichar, tolower)
104 _UNICHAR_FUNC(gunichar, totitle)
106 _UNICHAR_FUNC(int, digit_value)
107 _UNICHAR_FUNC(int, xdigit_value)
109 inline Glib::UnicodeType type(gunichar uc)
110 { return static_cast<Glib::UnicodeType>(static_cast<int>(g_unichar_type(uc))); }
112 inline Glib::UnicodeBreakType break_type(gunichar uc)
113 { return static_cast<Glib::UnicodeBreakType>(static_cast<int>(g_unichar_break_type(uc))); }
115 } // namespace Unicode
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)
133 _ASCII_FUNC(char, tolower)
134 _ASCII_FUNC(char, toupper)
136 _ASCII_FUNC(int, digit_value)
137 _ASCII_FUNC(int, xdigit_value)
142 /** @} group Unicode */