Subversion 1.6.16
|
00001 /** 00002 * @copyright 00003 * ==================================================================== 00004 * Copyright (c) 2000-2004, 2008 CollabNet. All rights reserved. 00005 * 00006 * This software is licensed as described in the file COPYING, which 00007 * you should have received as part of this distribution. The terms 00008 * are also available at http://subversion.tigris.org/license-1.html. 00009 * If newer versions of this license are posted there, you may use a 00010 * newer version instead, at your option. 00011 * 00012 * This software consists of voluntary contributions made by many 00013 * individuals. For exact contribution history, see the revision 00014 * history and logs, available at http://subversion.tigris.org/. 00015 * ==================================================================== 00016 * @endcopyright 00017 * 00018 * @file svn_ctype.h 00019 * @brief Character classification routines 00020 * @since New in 1.2. 00021 */ 00022 00023 00024 #ifndef SVN_CTYPE_H 00025 #define SVN_CTYPE_H 00026 00027 #include <apr.h> 00028 00029 00030 #ifdef __cplusplus 00031 extern "C" { 00032 #endif /* __cplusplus */ 00033 00034 00035 /** Table of flags for character classification. */ 00036 extern const apr_uint32_t *const svn_ctype_table; 00037 00038 00039 /** Check if @a c is in the character class described by @a flags. 00040 * The @a flags is a bitwise-or combination of @c SVN_CTYPE_* 00041 * constants. Uses #svn_ctype_table. 00042 */ 00043 #define svn_ctype_test(c, flags) \ 00044 (0 != (svn_ctype_table[(unsigned char)(c)] & (flags))) 00045 00046 00047 /** 00048 * @defgroup ctype_basic Basic character classification - 7-bit ASCII only 00049 * @{ 00050 */ 00051 00052 /* Basic character classes */ 00053 #define SVN_CTYPE_CNTRL 0x0001 /**< Control character */ 00054 #define SVN_CTYPE_SPACE 0x0002 /**< Whitespace */ 00055 #define SVN_CTYPE_DIGIT 0x0004 /**< Decimal digit */ 00056 #define SVN_CTYPE_UPPER 0x0008 /**< Uppercase letter */ 00057 #define SVN_CTYPE_LOWER 0x0010 /**< Lowercase letter */ 00058 #define SVN_CTYPE_PUNCT 0x0020 /**< Punctuation mark */ 00059 #define SVN_CTYPE_XALPHA 0x0040 /**< Hexadecimal digits A to F */ 00060 #define SVN_CTYPE_ASCII 0x0080 /**< ASCII subset*/ 00061 00062 /* Derived character classes */ 00063 /** ASCII letter */ 00064 #define SVN_CTYPE_ALPHA (SVN_CTYPE_LOWER | SVN_CTYPE_UPPER) 00065 /** ASCII letter or decimal digit */ 00066 #define SVN_CTYPE_ALNUM (SVN_CTYPE_ALPHA | SVN_CTYPE_DIGIT) 00067 /** ASCII hexadecimal digit */ 00068 #define SVN_CTYPE_XDIGIT (SVN_CTYPE_DIGIT | SVN_CTYPE_XALPHA) 00069 /** Printable ASCII except space */ 00070 #define SVN_CTYPE_GRAPH (SVN_CTYPE_PUNCT | SVN_CTYPE_ALNUM) 00071 /** All printable ASCII */ 00072 #define SVN_CTYPE_PRINT (SVN_CTYPE_GRAPH | SVN_CTYPE_SPACE) 00073 00074 00075 /** Check if @a c is an ASCII control character. */ 00076 #define svn_ctype_iscntrl(c) svn_ctype_test((c), SVN_CTYPE_CNTRL) 00077 00078 /** Check if @a c is an ASCII whitespace character. */ 00079 #define svn_ctype_isspace(c) svn_ctype_test((c), SVN_CTYPE_SPACE) 00080 00081 /** Check if @a c is an ASCII digit. */ 00082 #define svn_ctype_isdigit(c) svn_ctype_test((c), SVN_CTYPE_DIGIT) 00083 00084 /** Check if @a c is an ASCII uppercase letter. */ 00085 #define svn_ctype_isupper(c) svn_ctype_test((c), SVN_CTYPE_UPPER) 00086 00087 /** Check if @a c is an ASCII lowercase letter. */ 00088 #define svn_ctype_islower(c) svn_ctype_test((c), SVN_CTYPE_LOWER) 00089 00090 /** Check if @a c is an ASCII punctuation mark. */ 00091 #define svn_ctype_ispunct(c) svn_ctype_test((c), SVN_CTYPE_PUNCT) 00092 00093 /** Check if @a c is an ASCII character. */ 00094 #define svn_ctype_isascii(c) svn_ctype_test((c), SVN_CTYPE_ASCII) 00095 00096 /** Check if @a c is an ASCII letter. */ 00097 #define svn_ctype_isalpha(c) svn_ctype_test((c), SVN_CTYPE_ALPHA) 00098 00099 /** Check if @a c is an ASCII letter or decimal digit. */ 00100 #define svn_ctype_isalnum(c) svn_ctype_test((c), SVN_CTYPE_ALNUM) 00101 00102 /** Check if @a c is an ASCII hexadecimal digit. */ 00103 #define svn_ctype_isxdigit(c) svn_ctype_test((c), SVN_CTYPE_XDIGIT) 00104 00105 /** Check if @a c is an ASCII graphical (visible printable) character. */ 00106 #define svn_ctype_isgraph(c) svn_ctype_test((c), SVN_CTYPE_GRAPH) 00107 00108 /** Check if @a c is an ASCII printable character. */ 00109 #define svn_ctype_isprint(c) svn_ctype_test((c), SVN_CTYPE_PRINT) 00110 00111 /** @} */ 00112 00113 /** 00114 * @defgroup ctype_extra Extended character classification 00115 * @{ 00116 */ 00117 00118 /* Basic extended character classes */ 00119 #define SVN_CTYPE_UTF8LEAD 0x0100 /**< UTF-8 multibyte lead byte */ 00120 #define SVN_CTYPE_UTF8CONT 0x0200 /**< UTF-8 multibyte non-lead byte */ 00121 /* ### TBD 00122 #define SVN_CTYPE_XMLNAME 0x0400 00123 #define SVN_CTYPE_URISAFE 0x0800 00124 */ 00125 00126 /* Derived extended character classes */ 00127 /** Part of a UTF-8 multibyte character. */ 00128 #define SVN_CTYPE_UTF8MBC (SVN_CTYPE_UTF8LEAD | SVN_CTYPE_UTF8CONT) 00129 /** All valid UTF-8 bytes. */ 00130 #define SVN_CTYPE_UTF8 (SVN_CTYPE_ASCII | SVN_CTYPE_UTF8MBC) 00131 00132 /** Check if @a c is a UTF-8 multibyte lead byte. */ 00133 #define svn_ctype_isutf8lead(c) svn_ctype_test((c), SVN_CTYPE_UTF8LEAD) 00134 00135 /** Check if @a c is a UTF-8 multibyte continuation (non-lead) byte. */ 00136 #define svn_ctype_isutf8cont(c) svn_ctype_test((c), SVN_CTYLE_UTF8CONT) 00137 00138 /** Check if @a c is part of a UTF-8 multibyte character. */ 00139 #define svn_ctype_isutf8mbc(c) svn_ctype_test((c), SVN_CTYPE_UTF8MBC) 00140 00141 /** Check if @a c is valid in UTF-8. */ 00142 #define svn_ctype_isutf8(c) svn_ctype_test((c), SVN_CTYPE_UTF8) 00143 00144 /** @} */ 00145 00146 /** 00147 * @defgroup ctype_ascii ASCII character value constants 00148 * @{ 00149 */ 00150 00151 #define SVN_CTYPE_ASCII_MINUS 45 /**< ASCII value of '-' */ 00152 #define SVN_CTYPE_ASCII_DOT 46 /**< ASCII value of '.' */ 00153 #define SVN_CTYPE_ASCII_COLON 58 /**< ASCII value of ':' */ 00154 #define SVN_CTYPE_ASCII_UNDERSCORE 95 /**< ASCII value of '_' */ 00155 #define SVN_CTYPE_ASCII_TAB 9 /**< ASCII value of a tab */ 00156 #define SVN_CTYPE_ASCII_LINEFEED 10 /**< ASCII value of a line feed */ 00157 #define SVN_CTYPE_ASCII_CARRIAGERETURN 13 00158 /**< ASCII value of a carriage return */ 00159 #define SVN_CTYPE_ASCII_DELETE 127 00160 /**< ASCII value of a delete character */ 00161 00162 00163 /** @} */ 00164 00165 /** 00166 * @defgroup ctype_case ASCII-subset case folding 00167 * @{ 00168 */ 00169 00170 /** 00171 * Compare two characters @a a and @a b, treating case-equivalent 00172 * unaccented Latin (ASCII subset) letters as equal. 00173 * 00174 * Returns in integer greater than, equal to, or less than 0, 00175 * according to whether @a a is considered greater than, equal to, 00176 * or less than @a b. 00177 * 00178 * @since New in 1.5. 00179 */ 00180 int 00181 svn_ctype_casecmp(int a, 00182 int b); 00183 00184 00185 /** @} */ 00186 00187 #ifdef __cplusplus 00188 } 00189 #endif /* __cplusplus */ 00190 00191 #endif /* SVN_CTYPE_H */