00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 #if !defined(XMLCHAR_HPP)
00071 #define XMLCHAR_HPP
00072
00073 #include <xercesc/util/XMLUniDefs.hpp>
00074
00075 XERCES_CPP_NAMESPACE_BEGIN
00076
00077
00078
00079
00080
00081 const XMLByte gLetterCharMask = 0x1;
00082 const XMLByte gFirstNameCharMask = 0x2;
00083 const XMLByte gNameCharMask = 0x4;
00084 const XMLByte gPlainContentCharMask = 0x8;
00085 const XMLByte gSpecialStartTagCharMask = 0x10;
00086 const XMLByte gControlCharMask = 0x20;
00087 const XMLByte gXMLCharMask = 0x40;
00088 const XMLByte gWhitespaceCharMask = 0x80;
00089
00090
00091
00092
00093 class XMLChar1_0
00094 {
00095 public:
00096
00097
00098
00099 static bool isAllSpaces
00100 (
00101 const XMLCh* const toCheck
00102 , const unsigned int count
00103 );
00104
00105 static bool containsWhiteSpace
00106 (
00107 const XMLCh* const toCheck
00108 , const unsigned int count
00109 );
00110
00111 static bool isValidName
00112 (
00113 const XMLCh* const toCheck
00114 , const unsigned int count
00115 );
00116
00117 static bool isValidNCName
00118 (
00119 const XMLCh* const toCheck
00120 , const unsigned int count
00121 );
00122
00123 static bool isValidQName
00124 (
00125 const XMLCh* const toCheck
00126 , const unsigned int count
00127 );
00128
00129
00130
00131
00132
00133 static bool isXMLLetter(const XMLCh toCheck, const XMLCh toCheck2 = 0);
00134 static bool isFirstNameChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
00135 static bool isNameChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
00136 static bool isPlainContentChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
00137 static bool isSpecialStartTagChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
00138 static bool isXMLChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
00139 static bool isWhitespace(const XMLCh toCheck);
00140 static bool isWhitespace(const XMLCh toCheck, const XMLCh toCheck2);
00141 static bool isControlChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
00142
00143 static bool isPublicIdChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
00144
00145
00146
00147
00151 static bool isNELRecognized();
00152
00156 static void enableNELWS();
00157
00158 private:
00159
00160
00161
00162 XMLChar1_0();
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 static XMLByte fgCharCharsTable1_0[0x10000];
00177 static bool enableNEL;
00178
00179 friend class XMLReader;
00180 };
00181
00182
00183
00184
00185
00186 inline bool XMLChar1_0::isXMLLetter(const XMLCh toCheck, const XMLCh toCheck2)
00187 {
00188 if (!toCheck2)
00189 return ((fgCharCharsTable1_0[toCheck] & gLetterCharMask) != 0);
00190 return false;
00191 }
00192
00193 inline bool XMLChar1_0::isFirstNameChar(const XMLCh toCheck, const XMLCh toCheck2)
00194 {
00195 if (!toCheck2)
00196 return ((fgCharCharsTable1_0[toCheck] & gFirstNameCharMask) != 0);
00197 return false;
00198 }
00199
00200 inline bool XMLChar1_0::isNameChar(const XMLCh toCheck, const XMLCh toCheck2)
00201 {
00202 if (!toCheck2)
00203 return ((fgCharCharsTable1_0[toCheck] & gNameCharMask) != 0);
00204 return false;
00205 }
00206
00207 inline bool XMLChar1_0::isPlainContentChar(const XMLCh toCheck, const XMLCh toCheck2)
00208 {
00209 if (!toCheck2)
00210 return ((fgCharCharsTable1_0[toCheck] & gPlainContentCharMask) != 0);
00211 else {
00212 if ((toCheck >= 0xD800) && (toCheck <= 0xDBFF))
00213 if ((toCheck2 >= 0xDC00) && (toCheck2 <= 0xDFFF))
00214 return true;
00215 }
00216 return false;
00217 }
00218
00219
00220 inline bool XMLChar1_0::isSpecialStartTagChar(const XMLCh toCheck, const XMLCh toCheck2)
00221 {
00222 if (!toCheck2)
00223 return ((fgCharCharsTable1_0[toCheck] & gSpecialStartTagCharMask) != 0);
00224 return false;
00225 }
00226
00227 inline bool XMLChar1_0::isXMLChar(const XMLCh toCheck, const XMLCh toCheck2)
00228 {
00229 if (!toCheck2)
00230 return ((fgCharCharsTable1_0[toCheck] & gXMLCharMask) != 0);
00231 else {
00232 if ((toCheck >= 0xD800) && (toCheck <= 0xDBFF))
00233 if ((toCheck2 >= 0xDC00) && (toCheck2 <= 0xDFFF))
00234 return true;
00235 }
00236 return false;
00237 }
00238
00239 inline bool XMLChar1_0::isWhitespace(const XMLCh toCheck)
00240 {
00241 return ((fgCharCharsTable1_0[toCheck] & gWhitespaceCharMask) != 0);
00242 }
00243
00244 inline bool XMLChar1_0::isWhitespace(const XMLCh toCheck, const XMLCh toCheck2)
00245 {
00246 if (!toCheck2)
00247 return ((fgCharCharsTable1_0[toCheck] & gWhitespaceCharMask) != 0);
00248 return false;
00249 }
00250
00251 inline bool XMLChar1_0::isControlChar(const XMLCh toCheck, const XMLCh toCheck2)
00252 {
00253 if (!toCheck2)
00254 return ((fgCharCharsTable1_0[toCheck] & gControlCharMask) != 0);
00255 return false;
00256 }
00257
00258 inline bool XMLChar1_0::isNELRecognized() {
00259
00260 return enableNEL;
00261 }
00262
00263
00264
00265
00266
00267 class XMLChar1_1
00268 {
00269 public:
00270
00271
00272
00273 static bool isAllSpaces
00274 (
00275 const XMLCh* const toCheck
00276 , const unsigned int count
00277 );
00278
00279 static bool containsWhiteSpace
00280 (
00281 const XMLCh* const toCheck
00282 , const unsigned int count
00283 );
00284
00285 static bool isValidName
00286 (
00287 const XMLCh* const toCheck
00288 , const unsigned int count
00289 );
00290
00291 static bool isValidNCName
00292 (
00293 const XMLCh* const toCheck
00294 , const unsigned int count
00295 );
00296
00297 static bool isValidQName
00298 (
00299 const XMLCh* const toCheck
00300 , const unsigned int count
00301 );
00302
00303
00304
00305
00306 static bool isXMLLetter(const XMLCh toCheck, const XMLCh toCheck2 = 0);
00307 static bool isFirstNameChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
00308 static bool isNameChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
00309 static bool isPlainContentChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
00310 static bool isSpecialStartTagChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
00311 static bool isXMLChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
00312 static bool isWhitespace(const XMLCh toCheck, const XMLCh toCheck2 = 0);
00313 static bool isControlChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
00314
00315 static bool isPublicIdChar(const XMLCh toCheck, const XMLCh toCheck2 = 0);
00316
00317 private:
00318
00319
00320
00321 XMLChar1_1();
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332 static XMLByte fgCharCharsTable1_1[0x10000];
00333
00334 friend class XMLReader;
00335 };
00336
00337
00338
00339
00340
00341 inline bool XMLChar1_1::isXMLLetter(const XMLCh toCheck, const XMLCh toCheck2)
00342 {
00343 if (!toCheck2)
00344 return ((fgCharCharsTable1_1[toCheck] & gLetterCharMask) != 0);
00345 return false;
00346 }
00347
00348 inline bool XMLChar1_1::isFirstNameChar(const XMLCh toCheck, const XMLCh toCheck2)
00349 {
00350 if (!toCheck2)
00351 return ((fgCharCharsTable1_1[toCheck] & gFirstNameCharMask) != 0);
00352 else {
00353 if ((toCheck >= 0xD800) && (toCheck <= 0xDB7F))
00354 if ((toCheck2 >= 0xDC00) && (toCheck2 <= 0xDFFF))
00355 return true;
00356 }
00357 return false;
00358 }
00359
00360 inline bool XMLChar1_1::isNameChar(const XMLCh toCheck, const XMLCh toCheck2)
00361 {
00362 if (!toCheck2)
00363 return ((fgCharCharsTable1_1[toCheck] & gNameCharMask) != 0);
00364 else {
00365 if ((toCheck >= 0xD800) && (toCheck <= 0xDB7F))
00366 if ((toCheck2 >= 0xDC00) && (toCheck2 <= 0xDFFF))
00367 return true;
00368 }
00369 return false;
00370 }
00371
00372 inline bool XMLChar1_1::isPlainContentChar(const XMLCh toCheck, const XMLCh toCheck2)
00373 {
00374 if (!toCheck2)
00375 return ((fgCharCharsTable1_1[toCheck] & gPlainContentCharMask) != 0);
00376 else {
00377 if ((toCheck >= 0xD800) && (toCheck <= 0xDBFF))
00378 if ((toCheck2 >= 0xDC00) && (toCheck2 <= 0xDFFF))
00379 return true;
00380 }
00381 return false;
00382 }
00383
00384
00385 inline bool XMLChar1_1::isSpecialStartTagChar(const XMLCh toCheck, const XMLCh toCheck2)
00386 {
00387 if (!toCheck2)
00388 return ((fgCharCharsTable1_1[toCheck] & gSpecialStartTagCharMask) != 0);
00389 return false;
00390 }
00391
00392 inline bool XMLChar1_1::isXMLChar(const XMLCh toCheck, const XMLCh toCheck2)
00393 {
00394 if (!toCheck2)
00395 return ((fgCharCharsTable1_1[toCheck] & gXMLCharMask) != 0);
00396 else {
00397 if ((toCheck >= 0xD800) && (toCheck <= 0xDBFF))
00398 if ((toCheck2 >= 0xDC00) && (toCheck2 <= 0xDFFF))
00399 return true;
00400 }
00401 return false;
00402 }
00403
00404 inline bool XMLChar1_1::isWhitespace(const XMLCh toCheck, const XMLCh toCheck2)
00405 {
00406 if (!toCheck2)
00407 return ((fgCharCharsTable1_1[toCheck] & gWhitespaceCharMask) != 0);
00408 return false;
00409 }
00410
00411 inline bool XMLChar1_1::isControlChar(const XMLCh toCheck, const XMLCh toCheck2)
00412 {
00413 if (!toCheck2)
00414 return ((fgCharCharsTable1_1[toCheck] & gControlCharMask) != 0);
00415 return false;
00416 }
00417
00418
00419 XERCES_CPP_NAMESPACE_END
00420
00421 #endif