コード例 #1
0
void XMLDocumentParser::parse()
{
    while (!isStopped() && !m_parserPaused && !m_stream.atEnd()) {
        m_stream.readNext();
        switch (m_stream.tokenType()) {
        case QXmlStreamReader::StartDocument:
            startDocument();
            break;
        case QXmlStreamReader::EndDocument:
            endDocument();
            break;
        case QXmlStreamReader::StartElement:
            parseStartElement();
            break;
        case QXmlStreamReader::EndElement:
            parseEndElement();
            break;
        case QXmlStreamReader::Characters: {
            if (m_stream.isCDATA()) {
                //cdata
                parseCdata();
            } else {
                //characters
                parseCharacters();
            }
            break;
        }
        case QXmlStreamReader::Comment:
            parseComment();
            break;
        case QXmlStreamReader::DTD:
            //qDebug()<<"------------- DTD";
            parseDtd();
            break;
        case QXmlStreamReader::EntityReference: {
            //qDebug()<<"---------- ENTITY = "<<m_stream.name().toString()
            //        <<", t = "<<m_stream.text().toString();
            if (isXHTMLDocument()) {
                QString entity = m_stream.name().toString();
                if (!m_leafTextNode)
                    enterText();
                // qDebug()<<" ------- adding entity "<<str;
                m_leafTextNode->appendData(decodeNamedEntity(entity), IGNORE_EXCEPTION);
            }
            break;
        }
        case QXmlStreamReader::ProcessingInstruction:
            parseProcessingInstruction();
            break;
        default: {
            if (m_stream.error() != QXmlStreamReader::PrematureEndOfDocumentError) {
                XMLErrors::ErrorType type = (m_stream.error() == QXmlStreamReader::NotWellFormedError) ?
                                 XMLErrors::fatal : XMLErrors::warning;
                handleError(type, qPrintable(m_stream.errorString()), textPosition());
            }
            break;
        }
        }
    }
}
コード例 #2
0
bool  QXmlDefaultHandler_QtDShell::__override_endDocument(bool static_call)
{
    if (static_call) {
        return QXmlDefaultHandler::endDocument();
    } else {
        return endDocument();
    }
}
コード例 #3
0
/*!
  \internal

   Treats \a outputItem as a node and calls the appropriate function,
   e.g., attribute() or comment(), depending on its
   QXmlNodeModelIndex::NodeKind.

   This is a helper function that subclasses can use to multiplex
   Nodes received via item().
 */
void QAbstractXmlReceiver::sendAsNode(const QPatternist::Item &outputItem)
{
    Q_ASSERT(outputItem);
    Q_ASSERT(outputItem.isNode());
    const QXmlNodeModelIndex asNode = outputItem.asNode();

    switch(asNode.kind())
    {
        case QXmlNodeModelIndex::Attribute:
        {
            const QString &v = outputItem.stringValue();
            attribute(asNode.name(), QStringRef(&v));
            return;
        }
        case QXmlNodeModelIndex::Element:
        {
            startElement(asNode.name());

            /* First the namespaces, then attributes, then the children. */
            asNode.sendNamespaces(this);
            sendFromAxis<QXmlNodeModelIndex::AxisAttribute>(asNode);
            sendFromAxis<QXmlNodeModelIndex::AxisChild>(asNode);

            endElement();

            return;
        }
        case QXmlNodeModelIndex::Text:
        {
            const QString &v = asNode.stringValue();
            characters(QStringRef(&v));
            return;
        }
        case QXmlNodeModelIndex::ProcessingInstruction:
        {
            processingInstruction(asNode.name(), outputItem.stringValue());
            return;
        }
        case QXmlNodeModelIndex::Comment:
        {
            comment(outputItem.stringValue());
            return;
        }
        case QXmlNodeModelIndex::Document:
        {
            startDocument();
            sendFromAxis<QXmlNodeModelIndex::AxisChild>(asNode);
            endDocument();
            return;
        }
        case QXmlNodeModelIndex::Namespace:
            Q_ASSERT_X(false, Q_FUNC_INFO, "Not implemented");
    }

    Q_ASSERT_X(false, Q_FUNC_INFO,
               QString::fromLatin1("Unknown node type: %1").arg(asNode.kind()).toUtf8().constData());
}
コード例 #4
0
void JsonStreamingParser::endObject() {
    int popped = stack[stackPos];
    stackPos--;
    if (popped != STACK_OBJECT) {
      // throw new ParsingError($this->_line_number, $this->_char_number,
      // "Unexpected end of object encountered.");
    }
    myListener->endObject();
    state = STATE_AFTER_VALUE;
    if (stackPos == 0) {
      endDocument();
    }
  }
コード例 #5
0
ファイル: XMLDocumentParserQt.cpp プロジェクト: 13W/phantomjs
void XMLDocumentParser::parse()
{
    while (!isStopped() && !m_parserPaused && !m_stream.atEnd()) {
        m_stream.readNext();
        switch (m_stream.tokenType()) {
        case QXmlStreamReader::StartDocument: {
            startDocument();
        }
            break;
        case QXmlStreamReader::EndDocument: {
            endDocument();
        }
            break;
        case QXmlStreamReader::StartElement: {
#if ENABLE(XHTMLMP)
            if (document()->isXHTMLMPDocument() && !m_hasDocTypeDeclaration) {
                handleError(fatal, "DOCTYPE declaration lost.", lineNumber(), columnNumber());
                break;
            }
#endif
            parseStartElement();
        }
            break;
        case QXmlStreamReader::EndElement: {
            parseEndElement();
        }
            break;
        case QXmlStreamReader::Characters: {
            if (m_stream.isCDATA()) {
                //cdata
                parseCdata();
            } else {
                //characters
                parseCharacters();
            }
        }
            break;
        case QXmlStreamReader::Comment: {
            parseComment();
        }
            break;
        case QXmlStreamReader::DTD: {
            //qDebug()<<"------------- DTD";
            parseDtd();
#if ENABLE(XHTMLMP)
            m_hasDocTypeDeclaration = true;
#endif
        }
            break;
        case QXmlStreamReader::EntityReference: {
            //qDebug()<<"---------- ENTITY = "<<m_stream.name().toString()
            //        <<", t = "<<m_stream.text().toString();
            if (isXHTMLDocument()
#if ENABLE(XHTMLMP)
                || isXHTMLMPDocument()
#endif
               ) {
                QString entity = m_stream.name().toString();
                UChar c = decodeNamedEntity(entity.toUtf8().constData());
                if (!m_currentNode->isTextNode())
                    enterText();
                ExceptionCode ec = 0;
                String str(&c, 1);
                // qDebug()<<" ------- adding entity "<<str;
                static_cast<Text*>(m_currentNode)->appendData(str, ec);
            }
        }
            break;
        case QXmlStreamReader::ProcessingInstruction: {
            parseProcessingInstruction();
        }
            break;
        default: {
            if (m_stream.error() != QXmlStreamReader::PrematureEndOfDocumentError) {
                ErrorType type = (m_stream.error() == QXmlStreamReader::NotWellFormedError) ?
                                 fatal : warning;
                handleError(type, qPrintable(m_stream.errorString()), lineNumber(),
                            columnNumber());
            }
        }
            break;
        }
    }
}
コード例 #6
0
 void KmlGenerator::putKmlFooter() {
     endDocument();
     endKml();
 }
コード例 #7
0
    //---------------------------------------------------------------
    StreamWriter::~StreamWriter()
    {
        endDocument();
		delete mCharacterBuffer;
		delete mBufferFlusher;
    }
コード例 #8
0
ファイル: xmldoc.cpp プロジェクト: alilloyd/livecode
void CXMLDocument::endDocumentCallback(void *ctx)
{
	if (allowcallbacks)
		CB_endDocument();
	endDocument(ctx);
}
コード例 #9
0
ファイル: maintikz.c プロジェクト: Memedsmile/Schnyder
int main(int argc, char *argv[]){

  int nbedge = 13;
  Edge** edges = malloc((nbedge+1)*(sizeof (Edge*)));

  Edge* A = malloc(sizeof(Edge));
  A->origin = 1;
  A->dest = 2;
  A->couleur = -1;
  A->oriente = 0;
  edges[0] = A;

  Edge* B = malloc(sizeof(Edge));
  B->origin = 2;
  B->dest = 6;
  B->couleur = -1;
  B->oriente = 0;
  edges[1] = B;
  
  Edge* C = malloc(sizeof(Edge));
  C->origin = 1;
  C->dest = 6;
  C->couleur = -1;
  C->oriente = 0;
  edges[2] = C;
  
  Edge* D = malloc(sizeof(Edge));
  D->origin = 2;
  D->dest = 4;
  D->couleur = -1;
  D->oriente = 0;
  edges[3] = D;

  Edge* E = malloc(sizeof(Edge));
  E->origin = 4;
  E->dest = 6;
  E->couleur = -1;
  E->oriente = 0;
  edges[4] = E;

  Edge* F = malloc(sizeof(Edge));
  F->origin = 6;
  F->dest = 8;
  F->couleur = -1;
  F->oriente = 0;
  edges[5] = F;

  Edge* G = malloc(sizeof(Edge));
  G->origin = 1;
  G->dest = 8;
  G->couleur = -1;
  G->oriente = 0;
  edges[6] = G;

  Edge* H = malloc(sizeof(Edge));
  H->origin = 2;
  H->dest = 3;
  H->couleur = -1;
  H->oriente = 0;
  edges[7] = H;

  Edge* I = malloc(sizeof(Edge));
  I->origin = 3;
  I->dest = 4;
  I->couleur = -1;
  I->oriente = 0;
  edges[8] = I;

  Edge* J = malloc(sizeof(Edge));
  J->origin = 4;
  J->dest = 5;
  J->couleur = -1;
  J->oriente = 0;
  edges[9] = J;

  Edge* K = malloc(sizeof(Edge));
  K->origin = 6;
  K->dest = 5;
  K->couleur = -1;
  K->oriente = 0;
  edges[10] = K;
  
  Edge* L = malloc(sizeof(Edge));
  L->origin = 6;
  L->dest = 7;
  L->couleur = -1;
  L->oriente = 0;
  edges[11] = L;

  Edge* M = malloc(sizeof(Edge));
  M->origin = 7;
  M->dest = 8;
  M->couleur = -1;
  M->oriente = 0;
  edges[12] = M;
  edges[13] = NULL;


  Graph* T = malloc(sizeof(Graph));
  allocGraph(edges, T, 8);

  Graph** tabT = enumTriang(8);    
  
  FILE* desc = fopen(name,"w");
  beginDocument(desc);
  enumGraph(desc, tabT);
  endDocument(desc);
}