⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlreader.hpp

📁 经典开源游戏glest的源代码
💻 HPP
📖 第 1 页 / 共 2 页
字号:
    //      ask for buffers of text from it and will handle making some    //      sense of it.    //    //  fSwapped    //      If the encoding is one of the ones we do intrinsically, and its    //      in a different byte order from our native order, then this is    //      set to remind us to byte swap it during transcoding.    //    //  fThrowAtEnd    //      Indicates whether the reader manager should throw an end of entity    //      exception at the end of this reader instance. This is usually    //      set for top level external entity references. It overrides the    //      reader manager's global flag that controls throwing at the end    //      of entities. Defaults to false.    //    //  fTranscoder    //      If the encoding is not one that we handle intrinsically, then    //      we use an an external transcoder to do it. This class is an    //      abstraction that allows us to use pluggable external transcoding    //      services (via XMLTransService in util.)    //    //  fType    //      Indicates whether this reader represents a PE or not. If this    //      flag is true and the fInLiteral flag is false, then we will put    //      out an extra space at the end.    //    //  fgCharCharsTable;    //      Pointer to XMLChar table, depends on XML version    //    //  fNEL    //      Boolean indicates if NEL and LSEP should be recognized as NEL    //    //  fXMLVersion    //      Enum to indicate if this Reader is conforming to XML 1.0 or XML 1.1    // -----------------------------------------------------------------------    unsigned int                fCharIndex;    XMLCh                       fCharBuf[kCharBufSize];    unsigned int                fCharsAvail;    unsigned char               fCharSizeBuf[kCharBufSize];    unsigned int                fCharOfsBuf[kCharBufSize];    XMLSSize_t                  fCurCol;    XMLSSize_t                  fCurLine;    XMLRecognizer::Encodings    fEncoding;    XMLCh*                      fEncodingStr;    bool                        fForcedEncoding;    bool                        fNoMore;    XMLCh*                      fPublicId;    unsigned int                fRawBufIndex;    XMLByte                     fRawByteBuf[kRawBufSize];    unsigned int                fRawBytesAvail;    unsigned int                fReaderNum;    RefFrom                     fRefFrom;    bool                        fSentTrailingSpace;    Sources                     fSource;    unsigned int                fSrcOfsBase;    bool                        fSrcOfsSupported;    bool                        fCalculateSrcOfs;    XMLCh*                      fSystemId;    BinInputStream*             fStream;    bool                        fSwapped;    bool                        fThrowAtEnd;    XMLTranscoder*              fTranscoder;    Types                       fType;    XMLByte*                    fgCharCharsTable;    bool                        fNEL;    XMLVersion                  fXMLVersion;    MemoryManager*              fMemoryManager;};// ---------------------------------------------------------------------------//  XMLReader: Public, query methods// ---------------------------------------------------------------------------inline bool XMLReader::isNameChar(const XMLCh toCheck) const{    return ((fgCharCharsTable[toCheck] & gNameCharMask) != 0);}inline bool XMLReader::isNCNameChar(const XMLCh toCheck) const{    return ((fgCharCharsTable[toCheck] & gNCNameCharMask) != 0);}inline bool XMLReader::isPlainContentChar(const XMLCh toCheck) const{    return ((fgCharCharsTable[toCheck] & gPlainContentCharMask) != 0);}inline bool XMLReader::isFirstNameChar(const XMLCh toCheck) const{    return ((fgCharCharsTable[toCheck] & gFirstNameCharMask) != 0);}inline bool XMLReader::isFirstNCNameChar(const XMLCh toCheck) const{    return (((fgCharCharsTable[toCheck] & gFirstNameCharMask) != 0)             && (toCheck != chColon));}inline bool XMLReader::isSpecialStartTagChar(const XMLCh toCheck) const{    return ((fgCharCharsTable[toCheck] & gSpecialStartTagCharMask) != 0);}inline bool XMLReader::isXMLChar(const XMLCh toCheck) const{    return ((fgCharCharsTable[toCheck] & gXMLCharMask) != 0);}inline bool XMLReader::isXMLLetter(const XMLCh toCheck) const{    return (((fgCharCharsTable[toCheck] & gFirstNameCharMask) != 0)            && (toCheck != chColon) && (toCheck != chUnderscore));}inline bool XMLReader::isWhitespace(const XMLCh toCheck) const{    return ((fgCharCharsTable[toCheck] & gWhitespaceCharMask) != 0);}inline bool XMLReader::isControlChar(const XMLCh toCheck) const{    return ((fgCharCharsTable[toCheck] & gControlCharMask) != 0);}// ---------------------------------------------------------------------------//  XMLReader: Buffer management methods// ---------------------------------------------------------------------------inline unsigned long XMLReader::charsLeftInBuffer() const{    return fCharsAvail - fCharIndex;}// ---------------------------------------------------------------------------//  XMLReader: Getter methods// ---------------------------------------------------------------------------inline XMLSSize_t XMLReader::getColumnNumber() const{    return fCurCol;}inline const XMLCh* XMLReader::getEncodingStr() const{    return fEncodingStr;}inline XMLSSize_t XMLReader::getLineNumber() const{    return fCurLine;}inline bool XMLReader::getNoMoreFlag() const{    return fNoMore;}inline const XMLCh* XMLReader::getPublicId() const{    return fPublicId;}inline unsigned int XMLReader::getReaderNum() const{    return fReaderNum;}inline XMLReader::RefFrom XMLReader::getRefFrom() const{    return fRefFrom;}inline XMLReader::Sources XMLReader::getSource() const{    return fSource;}inline const XMLCh* XMLReader::getSystemId() const{    return fSystemId;}inline bool XMLReader::getThrowAtEnd() const{    return fThrowAtEnd;}inline XMLReader::Types XMLReader::getType() const{    return fType;}// ---------------------------------------------------------------------------//  XMLReader: Setter methods// ---------------------------------------------------------------------------inline void XMLReader::setReaderNum(const unsigned int newNum){    fReaderNum = newNum;}inline void XMLReader::setThrowAtEnd(const bool newValue){    fThrowAtEnd = newValue;}inline void XMLReader::setXMLVersion(const XMLVersion version){    fXMLVersion = version;    if (version == XMLV1_1) {        fNEL = true;        fgCharCharsTable = XMLChar1_1::fgCharCharsTable1_1;    }    else {        fNEL = XMLChar1_0::enableNEL;        fgCharCharsTable = XMLChar1_0::fgCharCharsTable1_0;    }}// ---------------------------------------------------------------------------////  XMLReader: movePlainContentChars()////       Move as many plain (no special handling of any sort required) content//       characters as possible from this reader to the supplied destination buffer.////       This is THE hottest performance spot in the parser.//// ---------------------------------------------------------------------------inline void XMLReader::movePlainContentChars(XMLBuffer &dest){    unsigned int count = fCharIndex;    while (fCharIndex < fCharsAvail)    {        if (!isPlainContentChar(fCharBuf[fCharIndex]))            break;        fCharIndex++;    }    if (count != fCharIndex)    {        fCurCol    += (fCharIndex - count);        dest.append(&fCharBuf[count], fCharIndex - count);    }}// ---------------------------------------------------------------------------//  XMLReader: getNextCharIfNot() method inlined for speed// ---------------------------------------------------------------------------inline bool XMLReader::getNextCharIfNot(const XMLCh chNotToGet, XMLCh& chGotten){    //    //  See if there is at least a char in the buffer. Else, do the buffer    //  reload logic.    //    if (fCharIndex >= fCharsAvail)    {        // If fNoMore is set, then we have nothing else to give        if (fNoMore)            return false;        // Try to refresh        if (!refreshCharBuffer())            return false;    }    // Check the next char    if (fCharBuf[fCharIndex] == chNotToGet)        return false;    // Its not the one we want to skip so bump the index    chGotten = fCharBuf[fCharIndex++];    // Handle end of line normalization and line/col member maintenance.    //    // we can have end-of-line combinations with a leading    // chCR(xD), chLF(xA), chNEL(x85), or chLineSeparator(x2028)    //    // 0000000000001101 chCR    // 0000000000001010 chLF    // 0000000010000101 chNEL    // 0010000000101000 chLineSeparator    // -----------------------    // 1101111101010000 == ~(chCR|chLF|chNEL|chLineSeparator)    //    // if the result of the logical-& operation is    // true  : 'curCh' can not be chCR, chLF, chNEL or chLineSeparator    // false : 'curCh' can be chCR, chLF, chNEL or chLineSeparator    //    if ( chGotten & (XMLCh) ~(chCR|chLF|chNEL|chLineSeparator) )    {        fCurCol++;    } else    {        handleEOL(chGotten, false);    }    return true;}// ---------------------------------------------------------------------------//  XMLReader: getNextChar() method inlined for speed// ---------------------------------------------------------------------------inline bool XMLReader::getNextChar(XMLCh& chGotten){    //    //  See if there is at least a char in the buffer. Else, do the buffer    //  reload logic.    //    if (fCharIndex >= fCharsAvail)    {        // If fNoMore is set, then we have nothing else to give        if (fNoMore)            return false;        // Try to refresh        if (!refreshCharBuffer())            return false;    }    chGotten = fCharBuf[fCharIndex++];    // Handle end of line normalization and line/col member maintenance.    //    // we can have end-of-line combinations with a leading    // chCR(xD), chLF(xA), chNEL(x85), or chLineSeparator(x2028)    //    // 0000000000001101 chCR    // 0000000000001010 chLF    // 0000000010000101 chNEL    // 0010000000101000 chLineSeparator    // -----------------------    // 1101111101010000 == ~(chCR|chLF|chNEL|chLineSeparator)    //    // if the result of the logical-& operation is    // true  : 'curCh' can not be chCR, chLF, chNEL or chLineSeparator    // false : 'curCh' can be chCR, chLF, chNEL or chLineSeparator    //    if ( chGotten & (XMLCh) ~(chCR|chLF|chNEL|chLineSeparator) )    {        fCurCol++;    } else    {        handleEOL(chGotten, false);    }    return true;}// ---------------------------------------------------------------------------//  XMLReader: peekNextChar() method inlined for speed// ---------------------------------------------------------------------------inline bool XMLReader::peekNextChar(XMLCh& chGotten){    //    //  If there is something still in the buffer, get it. Else do the reload    //  scenario.    //    if (fCharIndex >= fCharsAvail)    {        // Try to refresh the buffer        if (!refreshCharBuffer())        {            chGotten = chNull;            return false;        }    }    chGotten = fCharBuf[fCharIndex];    //    //  Even though we are only peeking, we have to act the same as the    //  normal char get method in regards to newline normalization, though    //  its not as complicated as the actual character getting method's.    //    if ((chGotten == chCR || (fNEL && (chGotten == chNEL || chGotten == chLineSeparator)))        && (fSource == Source_External))        chGotten = chLF;    return true;}XERCES_CPP_NAMESPACE_END#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -