当前位置: 首页>>代码示例>>C++>>正文


C++ Event::element方法代码示例

本文整理汇总了C++中parser::Event::element方法的典型用法代码示例。如果您正苦于以下问题:C++ Event::element方法的具体用法?C++ Event::element怎么用?C++ Event::element使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在parser::Event的用法示例。


在下文中一共展示了Event::element方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: processStanza

/**
 * Process incoming stanza (first-level element).
 */
void Stream::processStanza(const Parser::Event& event)
{
    QString id = event.element().attribute("id");
    if (!id.isEmpty() && d->scb.contains(id)) {
        Private::StanzaCallback cb = d->scb.value(id);
        QObject *obj = cb.first;
        qDebug("[XMPP::Stream] Invoke %s::%s for stanza with id %s",
               obj->metaObject()->className(), qPrintable(cb.second), qPrintable(id));
        QMetaObject::invokeMethod(obj, cb.second.toLocal8Bit().constData(), Q_ARG(XMPP::Stanza, event.element()));
        d->scb.remove(id);
    }
    if ( event.qualifiedName() == "stream:error" ) {
        handleStreamError(event);
    } else if ( event.qualifiedName() == "message" ) {
        emit stanzaMessage(event.element());
    } else if ( event.qualifiedName() == "iq" ) {
        emit stanzaIQ(event.element());
    } else if ( event.qualifiedName() == "presence" ) {
        emit stanzaPresence(event.element());
    } else {
        if (!handleUnknownElement(event))
            qDebug("[XMPP::Stream] Unhandled first-level element: %s",
                    qPrintable(event.qualifiedName()));
    }
}
开发者ID:holycheater,项目名称:qt-icq-transport,代码行数:28,代码来源:stream.cpp

示例2: baseStep

bool XmlProtocol::baseStep(const Parser::Event &pe)
{
	// Basic
	if(state == SendOpen) {
		sendTagOpen();
		event = ESend;
		if(incoming)
			state = Open;
		else
			state = RecvOpen;
		return true;
	}
	else if(state == RecvOpen) {
		if(incoming)
			state = SendOpen;
		else
			state = Open;

		// note: event will always be DocumentOpen here
		handleDocOpen(pe);
		event = ERecvOpen;
		return true;
	}
	else if(state == Open) {
		QDomElement e;
		if(pe.type() == Parser::Event::Element)
			e = pe.element();
		return doStep(e);
	}
	// Closing
	else {
		if(closeWritten) {
			if(peerClosed) {
				event = EPeerClosed;
				return true;
			}
			else
				return handleCloseFinished();
		}

		need = NNotify;
		notify = NSend;
		return false;
	}
}
开发者ID:ExtensionHealthcare,项目名称:iris,代码行数:45,代码来源:xmlprotocol.cpp

示例3: processStep

bool XmlProtocol::processStep()
{
	Parser::Event pe;
	notify = 0;
	transferItemList.clear();

	if(state != Closing && (state == RecvOpen || stepAdvancesParser())) {
		// if we get here, then it's because we're in some step that advances the parser
		pe = xml.readNext();
		if(!pe.isNull()) {
			// note: error/close events should be handled for ALL steps, so do them here
			switch(pe.type()) {
				case Parser::Event::DocumentOpen: {
					transferItemList += TransferItem(pe.actualString(), false);

					//stringRecv(pe.actualString());
					break;
				}
				case Parser::Event::DocumentClose: {
					transferItemList += TransferItem(pe.actualString(), false);

					//stringRecv(pe.actualString());
					if(incoming) {
						sendTagClose();
						event = ESend;
						peerClosed = true;
						state = Closing;
					}
					else {
						event = EPeerClosed;
					}
					return true;
				}
				case Parser::Event::Element: {
					QDomElement e = elemDoc.importNode(pe.element(),true).toElement();
					transferItemList += TransferItem(e, false);

					//elementRecv(pe.element());
					break;
				}
				case Parser::Event::Error: {
					if(incoming) {
						// If we get a parse error during the initial element exchange,
						// flip immediately into 'open' mode so that we can report an error.
						if(state == RecvOpen) {
							sendTagOpen();
							state = Open;
						}
						return handleError();
					}
					else {
						event = EError;
						errorCode = ErrParse;
						return true;
					}
				}
			}
		}
		else {
			if(state == RecvOpen || stepRequiresElement()) {
				need = NNotify;
				notify |= NRecv;
				return false;
			}
		}
	}

	return baseStep(pe);
}
开发者ID:ExtensionHealthcare,项目名称:iris,代码行数:69,代码来源:xmlprotocol.cpp

示例4: handleStreamError

/**
 * Handles stream erorrs (\<stream:error/\> element).
 */
void Stream::handleStreamError(const Parser::Event& event)
{
    d->lastStreamError = StreamError( event.element() );
    emit streamError();
}
开发者ID:holycheater,项目名称:qt-icq-transport,代码行数:8,代码来源:stream.cpp


注:本文中的parser::Event::element方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。