Subversion
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
subversion
include
svn_ctype.h
Go to the documentation of this file.
1
/**
2
* @copyright
3
* ====================================================================
4
* Copyright (c) 2000-2004, 2008 CollabNet. All rights reserved.
5
*
6
* This software is licensed as described in the file COPYING, which
7
* you should have received as part of this distribution. The terms
8
* are also available at http://subversion.tigris.org/license-1.html.
9
* If newer versions of this license are posted there, you may use a
10
* newer version instead, at your option.
11
*
12
* This software consists of voluntary contributions made by many
13
* individuals. For exact contribution history, see the revision
14
* history and logs, available at http://subversion.tigris.org/.
15
* ====================================================================
16
* @endcopyright
17
*
18
* @file svn_ctype.h
19
* @brief Character classification routines
20
* @since New in 1.2.
21
*/
22
23
24
#ifndef SVN_CTYPE_H
25
#define SVN_CTYPE_H
26
27
#include <apr.h>
28
29
30
#ifdef __cplusplus
31
extern
"C"
{
32
#endif
/* __cplusplus */
33
34
35
/** Table of flags for character classification. */
36
extern
const
apr_uint32_t *
const
svn_ctype_table
;
37
38
39
/** Check if @a c is in the character class described by @a flags.
40
* The @a flags is a bitwise-or combination of @c SVN_CTYPE_*
41
* constants. Uses #svn_ctype_table.
42
*/
43
#define svn_ctype_test(c, flags) \
44
(0 != (svn_ctype_table[(unsigned char)(c)] & (flags)))
45
46
47
/**
48
* @defgroup ctype_basic Basic character classification - 7-bit ASCII only
49
* @{
50
*/
51
52
/* Basic character classes */
53
#define SVN_CTYPE_CNTRL 0x0001
/**< Control character */
54
#define SVN_CTYPE_SPACE 0x0002
/**< Whitespace */
55
#define SVN_CTYPE_DIGIT 0x0004
/**< Decimal digit */
56
#define SVN_CTYPE_UPPER 0x0008
/**< Uppercase letter */
57
#define SVN_CTYPE_LOWER 0x0010
/**< Lowercase letter */
58
#define SVN_CTYPE_PUNCT 0x0020
/**< Punctuation mark */
59
#define SVN_CTYPE_XALPHA 0x0040
/**< Hexadecimal digits A to F */
60
#define SVN_CTYPE_ASCII 0x0080
/**< ASCII subset*/
61
62
/* Derived character classes */
63
/** ASCII letter */
64
#define SVN_CTYPE_ALPHA (SVN_CTYPE_LOWER | SVN_CTYPE_UPPER)
65
/** ASCII letter or decimal digit */
66
#define SVN_CTYPE_ALNUM (SVN_CTYPE_ALPHA | SVN_CTYPE_DIGIT)
67
/** ASCII hexadecimal digit */
68
#define SVN_CTYPE_XDIGIT (SVN_CTYPE_DIGIT | SVN_CTYPE_XALPHA)
69
/** Printable ASCII except space */
70
#define SVN_CTYPE_GRAPH (SVN_CTYPE_PUNCT | SVN_CTYPE_ALNUM)
71
/** All printable ASCII */
72
#define SVN_CTYPE_PRINT (SVN_CTYPE_GRAPH | SVN_CTYPE_SPACE)
73
74
75
/** Check if @a c is an ASCII control character. */
76
#define svn_ctype_iscntrl(c) svn_ctype_test((c), SVN_CTYPE_CNTRL)
77
78
/** Check if @a c is an ASCII whitespace character. */
79
#define svn_ctype_isspace(c) svn_ctype_test((c), SVN_CTYPE_SPACE)
80
81
/** Check if @a c is an ASCII digit. */
82
#define svn_ctype_isdigit(c) svn_ctype_test((c), SVN_CTYPE_DIGIT)
83
84
/** Check if @a c is an ASCII uppercase letter. */
85
#define svn_ctype_isupper(c) svn_ctype_test((c), SVN_CTYPE_UPPER)
86
87
/** Check if @a c is an ASCII lowercase letter. */
88
#define svn_ctype_islower(c) svn_ctype_test((c), SVN_CTYPE_LOWER)
89
90
/** Check if @a c is an ASCII punctuation mark. */
91
#define svn_ctype_ispunct(c) svn_ctype_test((c), SVN_CTYPE_PUNCT)
92
93
/** Check if @a c is an ASCII character. */
94
#define svn_ctype_isascii(c) svn_ctype_test((c), SVN_CTYPE_ASCII)
95
96
/** Check if @a c is an ASCII letter. */
97
#define svn_ctype_isalpha(c) svn_ctype_test((c), SVN_CTYPE_ALPHA)
98
99
/** Check if @a c is an ASCII letter or decimal digit. */
100
#define svn_ctype_isalnum(c) svn_ctype_test((c), SVN_CTYPE_ALNUM)
101
102
/** Check if @a c is an ASCII hexadecimal digit. */
103
#define svn_ctype_isxdigit(c) svn_ctype_test((c), SVN_CTYPE_XDIGIT)
104
105
/** Check if @a c is an ASCII graphical (visible printable) character. */
106
#define svn_ctype_isgraph(c) svn_ctype_test((c), SVN_CTYPE_GRAPH)
107
108
/** Check if @a c is an ASCII printable character. */
109
#define svn_ctype_isprint(c) svn_ctype_test((c), SVN_CTYPE_PRINT)
110
111
/** @} */
112
113
/**
114
* @defgroup ctype_extra Extended character classification
115
* @{
116
*/
117
118
/* Basic extended character classes */
119
#define SVN_CTYPE_UTF8LEAD 0x0100
/**< UTF-8 multibyte lead byte */
120
#define SVN_CTYPE_UTF8CONT 0x0200
/**< UTF-8 multibyte non-lead byte */
121
/* ### TBD
122
#define SVN_CTYPE_XMLNAME 0x0400
123
#define SVN_CTYPE_URISAFE 0x0800
124
*/
125
126
/* Derived extended character classes */
127
/** Part of a UTF-8 multibyte character. */
128
#define SVN_CTYPE_UTF8MBC (SVN_CTYPE_UTF8LEAD | SVN_CTYPE_UTF8CONT)
129
/** All valid UTF-8 bytes. */
130
#define SVN_CTYPE_UTF8 (SVN_CTYPE_ASCII | SVN_CTYPE_UTF8MBC)
131
132
/** Check if @a c is a UTF-8 multibyte lead byte. */
133
#define svn_ctype_isutf8lead(c) svn_ctype_test((c), SVN_CTYPE_UTF8LEAD)
134
135
/** Check if @a c is a UTF-8 multibyte continuation (non-lead) byte. */
136
#define svn_ctype_isutf8cont(c) svn_ctype_test((c), SVN_CTYLE_UTF8CONT)
137
138
/** Check if @a c is part of a UTF-8 multibyte character. */
139
#define svn_ctype_isutf8mbc(c) svn_ctype_test((c), SVN_CTYPE_UTF8MBC)
140
141
/** Check if @a c is valid in UTF-8. */
142
#define svn_ctype_isutf8(c) svn_ctype_test((c), SVN_CTYPE_UTF8)
143
144
/** @} */
145
146
/**
147
* @defgroup ctype_ascii ASCII character value constants
148
* @{
149
*/
150
151
#define SVN_CTYPE_ASCII_MINUS 45
/**< ASCII value of '-' */
152
#define SVN_CTYPE_ASCII_DOT 46
/**< ASCII value of '.' */
153
#define SVN_CTYPE_ASCII_COLON 58
/**< ASCII value of ':' */
154
#define SVN_CTYPE_ASCII_UNDERSCORE 95
/**< ASCII value of '_' */
155
#define SVN_CTYPE_ASCII_TAB 9
/**< ASCII value of a tab */
156
#define SVN_CTYPE_ASCII_LINEFEED 10
/**< ASCII value of a line feed */
157
#define SVN_CTYPE_ASCII_CARRIAGERETURN 13
158
/**< ASCII value of a carriage return */
159
#define SVN_CTYPE_ASCII_DELETE 127
160
/**< ASCII value of a delete character */
161
162
163
/** @} */
164
165
/**
166
* @defgroup ctype_case ASCII-subset case folding
167
* @{
168
*/
169
170
/**
171
* Compare two characters @a a and @a b, treating case-equivalent
172
* unaccented Latin (ASCII subset) letters as equal.
173
*
174
* Returns in integer greater than, equal to, or less than 0,
175
* according to whether @a a is considered greater than, equal to,
176
* or less than @a b.
177
*
178
* @since New in 1.5.
179
*/
180
int
181
svn_ctype_casecmp
(
int
a,
182
int
b);
183
184
185
/** @} */
186
187
#ifdef __cplusplus
188
}
189
#endif
/* __cplusplus */
190
191
#endif
/* SVN_CTYPE_H */
svn_ctype_table
const apr_uint32_t *const svn_ctype_table
Table of flags for character classification.
svn_ctype_casecmp
int svn_ctype_casecmp(int a, int b)
Compare two characters a and b, treating case-equivalent unaccented Latin (ASCII subset) letters as e...
Generated on Wed Nov 15 2017 14:25:48 for Subversion by
1.8.7