Skip to content
Snippets Groups Projects
XMLScanner.cpp 70 KiB
Newer Older
Khaled Noaman's avatar
Khaled Noaman committed
            if (gotLeadingSurrogate)
            {
                if ((nextCh < 0xDC00) || (nextCh > 0xDFFF))
                    emitError(XMLErrs::Expected2ndSurrogateChar);
            }
            // Its got to at least be a valid XML character
Tinny Ng's avatar
Tinny Ng committed
            else if (!fReaderMgr.getCurrentReader()->isXMLChar(nextCh)) {
Khaled Noaman's avatar
Khaled Noaman committed

                XMLCh tmpBuf[9];
                XMLString::binToText
                (
                    nextCh
                    , tmpBuf
                    , 8
                    , 16
                );
                emitError(XMLErrs::InvalidCharacter, tmpBuf);
            }

            gotLeadingSurrogate = false;
        }
Khaled Noaman's avatar
Khaled Noaman committed
        if (curState == InText)
        {
            // If its a dash, go to OneDash state. Otherwise take as text
            if (nextCh == chDash)
                curState = OneDash;
            else
                bbComment.append(nextCh);
        }
        else if (curState == OneDash)
        {
            //  If its another dash, then we change to the two dashes states.
            //  Otherwise, we have to put in the deficit dash and the new
            //  character and go back to InText.
            if (nextCh == chDash)
            {
                curState = TwoDashes;
            }
            else
            {
                bbComment.append(chDash);
                bbComment.append(nextCh);
                curState = InText;
            }
        }
        else if (curState == TwoDashes)
        {
            // The next character must be the closing bracket
            if (nextCh != chCloseAngle)
            {
                emitError(XMLErrs::IllegalSequenceInComment);
                fReaderMgr.skipPastChar(chCloseAngle);
                return;
            }
            break;
        }
    }
Khaled Noaman's avatar
Khaled Noaman committed
    // If we have an available handler, call back with the comment.
    if (fDocHandler)
    {
        fDocHandler->docComment
        (
            bbComment.getRawBuffer()
        );
Khaled Noaman's avatar
Khaled Noaman committed
//  Most equal signs can have white space around them, so this little guy
//  just makes the calling code cleaner by eating whitespace.
bool XMLScanner::scanEq()
{
    fReaderMgr.skipPastSpaces();
    if (fReaderMgr.skippedChar(chEqual))
    {
        fReaderMgr.skipPastSpaces();
        return true;
    }
    return false;
Khaled Noaman's avatar
Khaled Noaman committed

unsigned int
XMLScanner::scanUpToWSOr(XMLBuffer& toFill, const XMLCh chEndChar)
Khaled Noaman's avatar
Khaled Noaman committed
    fReaderMgr.getUpToCharOrWS(toFill, chEndChar);
    return toFill.getLen();
Tinny Ng's avatar
Tinny Ng committed
XERCES_CPP_NAMESPACE_END