- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

# svn_ctype.h

Go to the documentation of this file.

    00001 /**
    00002  * @copyright
    00003  * ====================================================================
    00004  *    Licensed to the Apache Software Foundation (ASF) under one
    00005  *    or more contributor license agreements.  See the NOTICE file
    00006  *    distributed with this work for additional information
    00007  *    regarding copyright ownership.  The ASF licenses this file
    00008  *    to you under the Apache License, Version 2.0 (the
    00009  *    "License"); you may not use this file except in compliance
    00010  *    with the License.  You may obtain a copy of the License at
    00011  *
    00012  *      http://www.apache.org/licenses/LICENSE-2.0
    00013  *
    00014  *    Unless required by applicable law or agreed to in writing,
    00015  *    software distributed under the License is distributed on an
    00016  *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    00017  *    KIND, either express or implied.  See the License for the
    00018  *    specific language governing permissions and limitations
    00019  *    under the License.
    00020  * ====================================================================
    00021  * @endcopyright
    00022  *
    00023  * @file svn_ctype.h
    00024  * @brief Character classification routines
    00025  * @since New in 1.2.
    00026  */
    00027
    00028
    00029 #ifndef SVN_CTYPE_H
    00030 #define SVN_CTYPE_H
    00031
    00032 #include <apr.h>
    00033
    00034
    00035 #ifdef __cplusplus
    00036 extern "C" {
    00037 #endif /* __cplusplus */
    00038
    00039
    00040 /** Table of flags for character classification. */
    00041 extern const apr_uint32_t *const svn_ctype_table;
    00042
    00043
    00044 /** Check if @a c is in the character class described by @a flags.
    00045  * The @a flags is a bitwise-or combination of @c SVN_CTYPE_*
    00046  * constants. Uses #svn_ctype_table.
    00047  */
    00048 #define svn_ctype_test(c, flags) \
    00049   (0 != (svn_ctype_table[(unsigned char)(c)] & (flags)))
    00050
    00051
    00052 /**
    00053  * @defgroup ctype_basic Basic character classification - 7-bit ASCII only
    00054  * @{
    00055  */
    00056
    00057 /* Basic character classes */
    00058 #define SVN_CTYPE_CNTRL    0x0001 /**< Control character */
    00059 #define SVN_CTYPE_SPACE    0x0002 /**< Whitespace */
    00060 #define SVN_CTYPE_DIGIT    0x0004 /**< Decimal digit */
    00061 #define SVN_CTYPE_UPPER    0x0008 /**< Uppercase letter */
    00062 #define SVN_CTYPE_LOWER    0x0010 /**< Lowercase letter */
    00063 #define SVN_CTYPE_PUNCT    0x0020 /**< Punctuation mark */
    00064 #define SVN_CTYPE_XALPHA   0x0040 /**< Hexadecimal digits A to F */
    00065 #define SVN_CTYPE_ASCII    0x0080 /**< ASCII subset*/
    00066
    00067 /* Derived character classes */
    00068 /** ASCII letter */
    00069 #define SVN_CTYPE_ALPHA    (SVN_CTYPE_LOWER | SVN_CTYPE_UPPER)
    00070 /** ASCII letter or decimal digit */
    00071 #define SVN_CTYPE_ALNUM    (SVN_CTYPE_ALPHA | SVN_CTYPE_DIGIT)
    00072 /** ASCII hexadecimal digit */
    00073 #define SVN_CTYPE_XDIGIT   (SVN_CTYPE_DIGIT | SVN_CTYPE_XALPHA)
    00074 /** Printable ASCII except space */
    00075 #define SVN_CTYPE_GRAPH    (SVN_CTYPE_PUNCT | SVN_CTYPE_ALNUM)
    00076 /** All printable ASCII */
    00077 #define SVN_CTYPE_PRINT    (SVN_CTYPE_GRAPH | SVN_CTYPE_SPACE)
    00078
    00079
    00080 /** Check if @a c is an ASCII control character. */
    00081 #define svn_ctype_iscntrl(c)  svn_ctype_test((c), SVN_CTYPE_CNTRL)
    00082
    00083 /** Check if @a c is an ASCII whitespace character. */
    00084 #define svn_ctype_isspace(c)  svn_ctype_test((c), SVN_CTYPE_SPACE)
    00085
    00086 /** Check if @a c is an ASCII digit. */
    00087 #define svn_ctype_isdigit(c)  svn_ctype_test((c), SVN_CTYPE_DIGIT)
    00088
    00089 /** Check if @a c is an ASCII uppercase letter. */
    00090 #define svn_ctype_isupper(c)  svn_ctype_test((c), SVN_CTYPE_UPPER)
    00091
    00092 /** Check if @a c is an ASCII lowercase letter. */
    00093 #define svn_ctype_islower(c)  svn_ctype_test((c), SVN_CTYPE_LOWER)
    00094
    00095 /** Check if @a c is an ASCII punctuation mark. */
    00096 #define svn_ctype_ispunct(c)  svn_ctype_test((c), SVN_CTYPE_PUNCT)
    00097
    00098 /** Check if @a c is an ASCII character. */
    00099 #define svn_ctype_isascii(c)  svn_ctype_test((c), SVN_CTYPE_ASCII)
    00100
    00101 /** Check if @a c is an ASCII letter. */
    00102 #define svn_ctype_isalpha(c)  svn_ctype_test((c), SVN_CTYPE_ALPHA)
    00103
    00104 /** Check if @a c is an ASCII letter or decimal digit. */
    00105 #define svn_ctype_isalnum(c)  svn_ctype_test((c), SVN_CTYPE_ALNUM)
    00106
    00107 /** Check if @a c is an ASCII hexadecimal digit. */
    00108 #define svn_ctype_isxdigit(c) svn_ctype_test((c), SVN_CTYPE_XDIGIT)
    00109
    00110 /** Check if @a c is an ASCII graphical (visible printable) character. */
    00111 #define svn_ctype_isgraph(c)  svn_ctype_test((c), SVN_CTYPE_GRAPH)
    00112
    00113 /** Check if @a c is an ASCII printable character. */
    00114 #define svn_ctype_isprint(c)  svn_ctype_test((c), SVN_CTYPE_PRINT)
    00115
    00116 /** @} */
    00117
    00118 /**
    00119  * @defgroup ctype_extra Extended character classification
    00120  * @{
    00121  */
    00122
    00123 /* Basic extended character classes */
    00124 #define SVN_CTYPE_UTF8LEAD 0x0100 /**< UTF-8 multibyte lead byte */
    00125 #define SVN_CTYPE_UTF8CONT 0x0200 /**< UTF-8 multibyte non-lead byte */
    00126 /* ### TBD
    00127 #define SVN_CTYPE_XMLNAME  0x0400
    00128 #define SVN_CTYPE_URISAFE  0x0800
    00129 */
    00130
    00131 /* Derived extended character classes */
    00132 /** Part of a UTF-8 multibyte character. */
    00133 #define SVN_CTYPE_UTF8MBC  (SVN_CTYPE_UTF8LEAD | SVN_CTYPE_UTF8CONT)
    00134 /** All valid UTF-8 bytes. */
    00135 #define SVN_CTYPE_UTF8     (SVN_CTYPE_ASCII | SVN_CTYPE_UTF8MBC)
    00136
    00137 /** Check if @a c is a UTF-8 multibyte lead byte. */
    00138 #define svn_ctype_isutf8lead(c) svn_ctype_test((c), SVN_CTYPE_UTF8LEAD)
    00139
    00140 /** Check if @a c is a UTF-8 multibyte continuation (non-lead) byte. */
    00141 #define svn_ctype_isutf8cont(c) svn_ctype_test((c), SVN_CTYLE_UTF8CONT)
    00142
    00143 /** Check if @a c is part of a UTF-8 multibyte character. */
    00144 #define svn_ctype_isutf8mbc(c)  svn_ctype_test((c), SVN_CTYPE_UTF8MBC)
    00145
    00146 /** Check if @a c is valid in UTF-8. */
    00147 #define svn_ctype_isutf8(c)     svn_ctype_test((c), SVN_CTYPE_UTF8)
    00148
    00149 /** @} */
    00150
    00151 /**
    00152  * @defgroup ctype_ascii ASCII character value constants
    00153  * @{
    00154  */
    00155
    00156 #define SVN_CTYPE_ASCII_MINUS            45 /**< ASCII value of '-' */
    00157 #define SVN_CTYPE_ASCII_DOT              46 /**< ASCII value of '.' */
    00158 #define SVN_CTYPE_ASCII_COLON            58 /**< ASCII value of ':' */
    00159 #define SVN_CTYPE_ASCII_UNDERSCORE       95 /**< ASCII value of '_' */
    00160 #define SVN_CTYPE_ASCII_TAB               9 /**< ASCII value of a tab */
    00161 #define SVN_CTYPE_ASCII_LINEFEED         10 /**< ASCII value of a line feed */
    00162 #define SVN_CTYPE_ASCII_CARRIAGERETURN   13
    00163   /**< ASCII value of a carriage return */
    00164 #define SVN_CTYPE_ASCII_DELETE          127
    00165   /**< ASCII value of a delete character */
    00166
    00167
    00168 /** @} */
    00169
    00170 /**
    00171  * @defgroup ctype_case ASCII-subset case folding
    00172  * @{
    00173  */
    00174
    00175 /**
    00176  * Compare two characters @a a and @a b, treating case-equivalent
    00177  * unaccented Latin (ASCII subset) letters as equal.
    00178  *
    00179  * Returns in integer greater than, equal to, or less than 0,
    00180  * according to whether @a a is considered greater than, equal to,
    00181  * or less than @a b.
    00182  *
    00183  * @since New in 1.5.
    00184  */
    00185 int
    00186 svn_ctype_casecmp(int a,
    00187                   int b);
    00188
    00189
    00190 /** @} */
    00191
    00192 #ifdef __cplusplus
    00193 }
    00194 #endif /* __cplusplus */
    00195
    00196 #endif /* SVN_CTYPE_H */

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines