本文整理汇总了C++中parser::Event::type方法的典型用法代码示例。如果您正苦于以下问题:C++ Event::type方法的具体用法?C++ Event::type怎么用?C++ Event::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parser::Event
的用法示例。
在下文中一共展示了Event::type方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2: processEvent
/**
* Process events from incoming stream.
*/
void Stream::processEvent(const Parser::Event& event)
{
switch ( event.type() ) {
case Parser::Event::DocumentOpen:
{
qDebug("[XMPP::Stream] Remote entity has opened the stream");
handleStreamOpen(event);
emit streamOpened();
}
break;
case Parser::Event::DocumentClose:
{
qWarning("[XMPP::Stream] Remote entity has closed the stream");
emit streamClosed();
}
break;
case Parser::Event::Element:
processStanza(event);
break;
case Parser::Event::Error:
qCritical("[XMPP::Stream] Parser error");
break;
}
}
示例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);
}