📄 xmlreader.hpp
字号:
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. if (chGotten == chCR) { // // Do the normalization. We return chLF regardless of which was // found. We also eat a chCR followed by an chLF. // // We only do this if the content being spooled is not already // internalized. // if (fSource == Source_External) { // // See if we have another char left. If not, don't bother. // Else, see if its an chLF to eat. If it is, bump the // index again. // if (fCharIndex < fCharsAvail) { if (fCharBuf[fCharIndex] == chLF || ((fCharBuf[fCharIndex] == chNEL) && fNEL)) fCharIndex++; } else { if (refreshCharBuffer()) { if (fCharBuf[fCharIndex] == chLF || ((fCharBuf[fCharIndex] == chNEL) && fNEL)) fCharIndex++; } } // And return just an chLF chGotten = chLF; } // And handle the line/col stuff fCurCol = 1; fCurLine++; } else if (chGotten == chLF || ((chGotten == chNEL || chGotten == chLineSeparator) && fNEL)) { chGotten = chLF; fCurLine++; fCurCol = 1; } else if (chGotten) { // // Only do this is not a null char. Null chars are not part of the // real content. They are just marker characters inserted into // the stream. // fCurCol++; } 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. if (chGotten == chCR) { // // Do the normalization. We return chLF regardless of which was // found. We also eat a chCR followed by an chLF. // // We only do this if the content being spooled is not already // internalized. // if (fSource == Source_External) { // // See if we have another char left. If not, don't bother. // Else, see if its an chLF to eat. If it is, bump the // index again. // if ((fCharIndex < fCharsAvail) || refreshCharBuffer()) { if (fCharBuf[fCharIndex] == chLF || ((fCharBuf[fCharIndex] == chNEL) && fNEL)) fCharIndex++; } // And return just an chLF chGotten = chLF; } // And handle the line/col stuff fCurCol = 1; fCurLine++; } else if (chGotten == chLF || ((chGotten == chNEL || chGotten == chLineSeparator) && fNEL)) { chGotten = chLF; fCurLine++; fCurCol = 1; } else if (chGotten) { // // Only do this is not a null char. Null chars are not part of the // real content. They are just marker characters inserted into // the stream. // fCurCol++; } 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 || ((chGotten == chNEL || chGotten == chLineSeparator) && fNEL)) && (fSource == Source_External)) chGotten = chLF; return true;}XERCES_CPP_NAMESPACE_END#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -