xmlchar.cpp
来自「IBM的解析xml的工具Xerces的源代码」· C++ 代码 · 共 801 行 · 第 1/5 页
CPP
801 行
/* * Copyright 2002,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *//* * $Id: XMLChar.cpp,v 1.9 2004/09/08 13:56:24 peiyongz Exp $ */// ---------------------------------------------------------------------------// Includes// ---------------------------------------------------------------------------#include <xercesc/util/XMLChar.hpp>#include <xercesc/util/XMLString.hpp>#include <xercesc/internal/CharTypeTables.hpp>#include <string.h>XERCES_CPP_NAMESPACE_BEGIN// ---------------------------------------------------------------------------// XMLChar1_0: static data initialization// ---------------------------------------------------------------------------bool XMLChar1_0::enableNEL = false;// ---------------------------------------------------------------------------// XMLChar1_0: Public, static methods// ---------------------------------------------------------------------------// Checks whether all of the chars in the passed buffer are whitespace or// not. Breaks out on the first non-whitespace.//bool XMLChar1_0::isAllSpaces(const XMLCh* const toCheck , const unsigned int count){ const XMLCh* curCh = toCheck; const XMLCh* endPtr = toCheck + count; while (curCh < endPtr) { if (!(fgCharCharsTable1_0[*curCh++] & gWhitespaceCharMask)) return false; } return true;}//// Checks whether at least one of the chars in the passed buffer are whitespace or// not.//bool XMLChar1_0::containsWhiteSpace(const XMLCh* const toCheck , const unsigned int count){ const XMLCh* curCh = toCheck; const XMLCh* endPtr = toCheck + count; while (curCh < endPtr) { if (fgCharCharsTable1_0[*curCh++] & gWhitespaceCharMask) return true; } return false;}bool XMLChar1_0::isValidNCName(const XMLCh* const toCheck , const unsigned int count){ const XMLCh* curCh = toCheck; const XMLCh* endPtr = toCheck + count; if (*curCh== chColon || !(fgCharCharsTable1_0[*curCh++] & gFirstNameCharMask)) return false; while (curCh < endPtr) { if (*curCh== chColon || !(fgCharCharsTable1_0[*curCh++] & gNameCharMask)) return false; } return true;}bool XMLChar1_0::isValidNmtoken(const XMLCh* const toCheck , const unsigned int count){ const XMLCh* curCh = toCheck; const XMLCh* endPtr = toCheck + count; while (curCh < endPtr) { if (!(fgCharCharsTable1_0[*curCh++] & gNameCharMask)) return false; } return true;}bool XMLChar1_0::isValidName(const XMLCh* const toCheck , const unsigned int count){ const XMLCh* curCh = toCheck; const XMLCh* endPtr = toCheck + count; if (!(fgCharCharsTable1_0[*curCh++] & gFirstNameCharMask)) return false; while (curCh < endPtr) { if (!(fgCharCharsTable1_0[*curCh++] & gNameCharMask)) return false; } return true;}/** * isValidQName * * [6] QName ::= (Prefix ':')? LocalPart * [7] Prefix ::= NCName * [8] LocalPart ::= NCName * */bool XMLChar1_0::isValidQName(const XMLCh* const toCheck , const unsigned int count){ int length = count; int colonPos = XMLString::indexOf(toCheck, chColon); if ((colonPos == 0) || // ":abcd" (colonPos == length-1)) // "abcd:" return false; // // prefix // if (colonPos != -1) { if (isValidNCName(toCheck, colonPos) == false) return false; } // // LocalPart // return isValidNCName(toCheck+colonPos+1, length-colonPos-1);}//// This one is not called terribly often, so its done manually in order// give up more bits in the character characteristics table for more often// used characteristics.//bool XMLChar1_0::isPublicIdChar(const XMLCh toCheck, const XMLCh toCheck2){ if (!toCheck2) { const XMLCh* curTable = gPublicIdChars; // Check the ranges
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?