本文整理汇总了C++中Tag::children方法的典型用法代码示例。如果您正苦于以下问题:C++ Tag::children方法的具体用法?C++ Tag::children怎么用?C++ Tag::children使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tag
的用法示例。
在下文中一共展示了Tag::children方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleDiscoItemsResult
void Adhoc::handleDiscoItemsResult( Stanza *stanza, int context )
{
if( context != FetchAdhocCommands )
return;
AdhocTrackMap::iterator it = m_adhocTrackMap.begin();
for( ; it != m_adhocTrackMap.end(); ++it )
{
if( (*it).second.context == context && (*it).second.remote == stanza->from() )
{
Tag *q = stanza->findChild( "query", "xmlns", XMLNS_DISCO_ITEMS );
if( q )
{
StringMap commands;
const Tag::TagList& l = q->children();
Tag::TagList::const_iterator itt = l.begin();
for( ; itt != l.end(); ++itt )
{
const std::string& name = (*itt)->findAttribute( "name" );
const std::string& node = (*itt)->findAttribute( "node" );
if( (*itt)->name() == "item" && !name.empty() && !node.empty() )
{
commands[node] = name;
}
}
(*it).second.ah->handleAdhocCommands( (*it).second.remote, commands );
}
m_adhocTrackMap.erase( it );
break;
}
}
}
示例2:
GSIOTInfo::GSIOTInfo( const Tag* tag )
:StanzaExtension( ExtIot ), m_isInputDevice(false)
{
if( !tag || tag->name() != "gsiot" || tag->xmlns() != XMLNS_GSIOT )
return;
Tag *d = tag->findChild("device");
if(d)
{
Tag *ttypelist = d->findChild("typelist");
if( ttypelist )
{
const TagList& l = ttypelist->children();
TagList::const_iterator it = l.begin();
for( ; it != l.end(); ++it )
{
if((*it)->name() != "type")
continue;
m_getForType.insert( (IOTDeviceType)atoi( (*it)->cdata().c_str() ) );
}
}
}
//const TagList& l = tag->children();
//TagList::const_iterator it = l.begin();
//for( ; it != l.end(); ++it )
//{
// if((*it)->name() == "device"){
// this->m_deviceList.push_back(new GSIOTDevice(*it));
// }
//}
}
示例3: rowCount
int TagModel::rowCount(const QModelIndex & parent) const {
if (parent.column() >= COUNT_COL)
return 0;
if (!parent.isValid())
return mTagRoot->children().size();
Tag * tag = static_cast<Tag *>(parent.internalPointer());
return tag->children().size();
}
示例4: untagAuth_base
void XmppGSAuth_base::untagAuth_base( const Tag* tag )
{
Tag *tAuth = tag->findChild("authority");
if( tAuth )
{
if(tAuth->hasAttribute("method"))
{
m_srcmethod = tAuth->findAttribute("method");
std::string method = m_srcmethod;
g_toLowerCase( method );
if( method == "add" )
{
m_method = defCfgOprt_AddModify;
}
else if( method == "edit" )
{
m_method = defCfgOprt_Modify;
}
else if( method == "delete" )
{
m_method = defCfgOprt_Delete;
}
else if( method == "getself" )
{
m_method = defCfgOprt_GetSelf;
}
else if( method == "getsimple" )
{
m_method = defCfgOprt_GetSimple;
}
}
const TagList& l = tAuth->children();
TagList::const_iterator it = l.begin();
for( ; it != l.end(); ++it )
{
if((*it)->name() == "user")
{
GSIOTUser *pUser = new GSIOTUser(*it);
std::string jid = pUser->GetKeyJid();
if( GSIOTUserMgr::usermapFind( m_mapUser, jid ) == m_mapUser.end() )
{
GSIOTUserMgr::usermapInsert( m_mapUser, pUser );
}
else
{
delete pUser;
}
}
}
}
}
示例5: switch
bool SOCKS5BytestreamManager::handleIq( Stanza *stanza )
{
Tag* q = stanza->findChild( "query", "xmlns", XMLNS_BYTESTREAMS );
if( !q || !m_socks5BytestreamHandler )
return false;
if( m_trackMap.find( stanza->id() ) != m_trackMap.end() )
return false;
switch( stanza->subtype() )
{
case StanzaIqSet:
{
const std::string& sid = q->findAttribute( "sid" );
const std::string& mode = q->findAttribute( "mode" );
if( haveStream( stanza->from() ) || sid.empty() || mode == "udp" )
{
rejectSOCKS5Bytestream( stanza->from(), stanza->id(), StanzaErrorNotAcceptable );
return true;
}
AsyncS5BItem asi;
Tag::TagList& l = q->children();
Tag::TagList::const_iterator it = l.begin();
for( ; it != l.end(); ++it )
{
if( (*it)->name() == "streamhost" && (*it)->hasAttribute( "jid" )
&& (*it)->hasAttribute( "host" ) && (*it)->hasAttribute( "port" ) )
{
StreamHost sh;
sh.jid = (*it)->findAttribute( "jid" );
sh.host = (*it)->findAttribute( "host" );
sh.port = atoi( (*it)->findAttribute( "port" ).c_str() );
asi.sHosts.push_back( sh );
}
}
asi.id = stanza->id();
asi.from = stanza->from();
asi.incoming = true;
m_asyncTrackMap[sid] = asi;
m_socks5BytestreamHandler->handleIncomingSOCKS5BytestreamRequest( sid, stanza->from() );
break;
}
case StanzaIqError:
m_socks5BytestreamHandler->handleSOCKS5BytestreamError( stanza, std::string() );
break;
default:
break;
}
return true;
}
示例6: if
Tag *MRIMProtocol::getVCardTag(AbstractUser *user, GList *vcardEntries) {
PurpleNotifyUserInfoEntry *vcardEntry;
std::string label;
std::string firstName;
std::string lastName;
std::string header;
Tag *N = new Tag("N");
Tag *head = new Tag("ADR");
Tag *vcard = new Tag( "vCard" );
vcard->addAttribute( "xmlns", "vcard-temp" );
while (vcardEntries) {
vcardEntry = (PurpleNotifyUserInfoEntry *)(vcardEntries->data);
if (purple_notify_user_info_entry_get_label(vcardEntry) && purple_notify_user_info_entry_get_value(vcardEntry)){
label=(std::string)purple_notify_user_info_entry_get_label(vcardEntry);
Log("vcard label", label << " => " << (std::string)purple_notify_user_info_entry_get_value(vcardEntry));
if (label=="Firstname"){
N->addChild( new Tag("GIVEN", (std::string)purple_notify_user_info_entry_get_value(vcardEntry)));
firstName = (std::string)purple_notify_user_info_entry_get_value(vcardEntry);
}
else if (label=="Lastname"){
N->addChild( new Tag("FAMILY", (std::string)purple_notify_user_info_entry_get_value(vcardEntry)));
lastName = (std::string)purple_notify_user_info_entry_get_value(vcardEntry);
}
else if (label=="Nickname"){
vcard->addChild( new Tag("NICKNAME", (std::string)purple_notify_user_info_entry_get_value(vcardEntry)));
}
else if (label=="Sex"){
vcard->addChild( new Tag("GENDER", (std::string)purple_notify_user_info_entry_get_value(vcardEntry)));
}
else if (label=="Birthday"){
vcard->addChild( new Tag("BDAY", (std::string)purple_notify_user_info_entry_get_value(vcardEntry)));
}
else if (label=="E-Mail"){
vcard->addChild( new Tag("UID", (std::string)purple_notify_user_info_entry_get_value(vcardEntry)));
}
}
vcardEntries = vcardEntries->next;
}
if (!firstName.empty() || !lastName.empty())
vcard->addChild( new Tag("FN", firstName + " " + lastName));
// add photo ant N if any
if(!N->children().empty())
vcard->addChild(N);
return vcard;
}
示例7: if
XmppGSManager::XmppGSManager( const Tag* tag )
:StanzaExtension(ExtIotManager), m_method(defCfgOprt_Unknown)
{
if( !tag || tag->name() != "gsiot" || tag->xmlns() != XMLNS_GSIOT_MANAGER )
return;
Tag *tmgr = tag->findChild("manager");
if( tmgr )
{
if(tmgr->hasAttribute("method"))
{
m_srcmethod = tmgr->findAttribute("method");
std::string method = m_srcmethod;
g_toLowerCase( method );
if( method == "add" )
{
m_method = defCfgOprt_Add;
}
else if( method == "edit" )
{
m_method = defCfgOprt_Modify;
}
else if( method == "delete" )
{
m_method = defCfgOprt_Delete;
}
}
const TagList& l = tmgr->children();
TagList::const_iterator it = l.begin();
for( ; it != l.end(); ++it )
{
if((*it)->name() == "device")
{
m_devices.push_back( new GSIOTDevice(*it) );
}
}
}
}
示例8: if
XmppGSEvent::XmppGSEvent( const Tag* tag )
:StanzaExtension(ExtIotEvent), m_method(defCfgOprt_Unknown), m_pDevice(NULL), m_runstate(1)
{
if( !tag || tag->name() != "gsiot" || tag->xmlns() != XMLNS_GSIOT_EVENT )
return;
//GSIOTClient::XmppPrint( tag, "recv", stanza, false ); //jyc20170227 debug
//XmppGSEvent::PrintTag( tag , ExtIotEvent);
Tag *tmgr = tag->findChild("event");
if( tmgr )
{
Tag *tDevice = tmgr->findChild("device");
if( tDevice )
{
m_pDevice = new GSIOTDevice(tDevice);
}
else
{
LOGMSG( "not found device tag" );
return;
}
this->UntagEditAttr( tmgr );
if(tmgr->hasAttribute("method"))
{
m_srcmethod = tmgr->findAttribute("method");
std::string method = m_srcmethod;
g_toLowerCase( method );
if( method == "add" )
{
m_method = defCfgOprt_Add;
}
else if( method == "edit" )
{
m_method = defCfgOprt_Modify;
}
else if( method == "delete" )
{
m_method = defCfgOprt_Delete;
}
}
Tag *tdo = tmgr->findChild("do"); //jyc20170223 trans "edit trigger"
if( tdo )
{
const TagList& l = tdo->children();
TagList::const_iterator it = l.begin();
for( ; it != l.end(); ++it )
{
ControlEvent *pNew = NULL;
if((*it)->name() == "smsthing")
{
pNew = new AutoSendSMSEvent(*it);
}
else if((*it)->name() == "mailthing")
{
//...
}
else if((*it)->name() == "messagething")
{
pNew = new AutoNoticeEvent(*it);
}
else if((*it)->name() == "devicething")
{
pNew = new AutoControlEvent(*it);
}
else if((*it)->name() == "callthing")
{
//...
}
else if((*it)->name() == "eventthing")
{
pNew = new AutoEventthing(*it);
}
if( pNew )
{
if( m_pDevice )
{
pNew->SetDeviceType( m_pDevice->getType() );
pNew->SetDeviceID( m_pDevice->getId() );
}
m_Events.push_back( pNew );
}
}
}
Tag *tState = tmgr->findChild("state");
if( tState )
{
m_runstate = atoi( tState->cdata().c_str() );
}
}
}
示例9: if
XmppGSTalk::XmppGSTalk( const Tag* tag )
:StanzaExtension(ExtIotTalk), m_cmd(defTalkCmd_Unknown), m_result(true)
{
if( !tag || tag->name() != "gstalk" || tag->xmlns() != XMLNS_GSIOT_TALK )
return;
Tag *tmgr = tag->findChild("gstalk");
if( tmgr )
{
if( tmgr->findChild("command") )
{
m_strSrcCmd = tmgr->findChild("command")->cdata();
std::string strcmd = m_strSrcCmd;
g_toLowerCase( strcmd );
if( strcmd == "request" )
{
m_cmd = defTalkCmd_request;
}
else if( strcmd == "accept" )
{
m_cmd = defTalkCmd_accept;
}
else if( strcmd == "reject" )
{
m_cmd = defTalkCmd_reject;
}
else if( strcmd == "session" )
{
m_cmd = defTalkCmd_session;
}
else if( strcmd == "adddev" )
{
m_cmd = defTalkCmd_adddev;
}
else if( strcmd == "removedev" )
{
m_cmd = defTalkCmd_removedev;
}
else if( strcmd == "keepalive" )
{
m_cmd = defTalkCmd_keepalive;
}
else if( strcmd == "quit" )
{
m_cmd = defTalkCmd_quit;
}
else if( strcmd == "forcequit" )
{
m_cmd = defTalkCmd_forcequit;
}
else
{
m_cmd = defTalkCmd_Unknown;
}
}
if( tmgr->findChild("url") )
{
m_url = tmgr->findChild("url")->cdata();
}
Tag *tdevicelist = tmgr->findChild("devicelist");
if( tdevicelist )
{
const TagList& l = tdevicelist->children();
TagList::const_iterator it = l.begin();
for( ; it != l.end(); ++it )
{
Tag *tDev = (*it);
if( tDev->name() == "device" )
{
if( tDev->hasAttribute("type") && tDev->hasAttribute("id") )
{
IOTDeviceType dev_type = (IOTDeviceType)atoi( tDev->findAttribute("type").c_str() );
int dev_id = atoi( tDev->findAttribute("id").c_str() );
m_vecdev.push_back( GSIOTDeviceKey(dev_type,dev_id) );
}
}
}
}
}
}
示例10: main
//.........这里部分代码省略.........
fprintf( stderr, "test '%s' failed\n", name.c_str() );
printf( "f->tag(): %s\n", f->tag()->xml().c_str() );
printf( " t: %s\n", t->xml().c_str() );
}
name = "parse Tag 2.5";
if( !r->hasChild( "option", "label", "smoking barrel" ) )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
printf( "f->tag(): %s\n", f->tag()->xml().c_str() );
printf( " t: %s\n", t->xml().c_str() );
}
name = "parse Tag 2.6";
if( !r->findChild( "option" )->findChild( "value" ) )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
printf( "f->tag(): %s\n", f->tag()->xml().c_str() );
printf( " t: %s\n", t->xml().c_str() );
}
name = "parse Tag 2.7";
if( r->findChild( "option" )->findChild( "value" )->cdata() != "lock" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
printf( "f->tag(): %s\n", f->tag()->xml().c_str() );
printf( " t: %s\n", t->xml().c_str() );
}
name = "parse Tag 2.8";
TagList l = r->children();
TagList::const_iterator it = l.begin();
for( ; it != l.end(); ++it )
{
if( (*it)->name() == "option" && ( !(*it)->hasChildWithCData( "value", "lock" ) &&
!(*it)->hasChildWithCData( "value", "stock" ) &&
!(*it)->hasChildWithCData( "value", "smoking barrel" ) ) )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
printf( "f->tag(): %s\n", f->tag()->xml().c_str() );
printf( " t: %s\n", t->xml().c_str() );
}
}
name = "parse Tag 2.9";
if( !r->hasChildWithCData( "value", "lock" ) || !r->hasChildWithCData( "value", "stock" ) )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
printf( "f->tag(): %s\n", f->tag()->xml().c_str() );
printf( " t: %s\n", t->xml().c_str() );
}
delete f;
delete t;
delete r;
f = 0;
// -------
name = "boolean duplicate <value/>";
f = new DataFormField( DataFormField::TypeBoolean );
示例11: extractItems
void RosterManager::extractItems( Tag *tag, bool isPush )
{
Tag *t = tag->findChild( "query" );
const Tag::TagList& l = t->children();
Tag::TagList::const_iterator it = l.begin();
for( ; it != l.end(); ++it )
{
if( (*it)->name() == "item" )
{
StringList gl;
if( (*it)->hasChild( "group" ) )
{
const Tag::TagList& g = (*it)->children();
Tag::TagList::const_iterator it_g = g.begin();
for( ; it_g != g.end(); ++it_g )
{
gl.push_back( (*it_g)->cdata() );
}
}
const JID& jid = (*it)->findAttribute( "jid" );
Roster::iterator it_d = m_roster.find( jid.bare() );
if( it_d != m_roster.end() )
{
(*it_d).second->setName( (*it)->findAttribute( "name" ) );
const std::string& sub = (*it)->findAttribute( "subscription" );
if( sub == "remove" )
{
delete (*it_d).second;
m_roster.erase( it_d );
if( m_rosterListener )
m_rosterListener->handleItemRemoved( jid );
continue;
}
const std::string& ask = (*it)->findAttribute( "ask" );
bool a = false;
if( !ask.empty() )
a = true;
(*it_d).second->setSubscription( sub, a );
(*it_d).second->setGroups( gl );
(*it_d).second->setSynchronized();
if( isPush && m_rosterListener )
m_rosterListener->handleItemUpdated( jid );
}
else
{
const std::string& sub = (*it)->findAttribute( "subscription" );
if( sub == "remove" )
continue;
const std::string& name = (*it)->findAttribute( "name" );
const std::string& ask = (*it)->findAttribute( "ask" );
bool a = false;
if( !ask.empty() )
a = true;
StringList caps;
add( jid.bare(), name, gl, caps, sub, a );
if( isPush && m_rosterListener )
m_rosterListener->handleItemAdded( jid );
}
}
}
}
示例12: handleIq
//.........这里部分代码省略.........
field->addAttribute("type", "boolean");
field->addAttribute("var", "unregister");
field->addAttribute("label", tr(_language, _("Remove your registration")));
field->addChild( new Tag("value", "0") );
x->addChild(field);
}
query->addChild(x);
reply->addChild(query);
Transport::instance()->send( reply );
return true;
}
else if (iqTag->findAttribute("type") == "set") {
bool remove = false;
Tag *query;
Tag *usernametag;
Tag *passwordtag;
Tag *languagetag;
Tag *encodingtag;
std::string username("");
std::string password("");
std::string language("");
std::string encoding("");
UserRow res = Transport::instance()->sql()->getUserByJid(from.bare());
query = iqTag->findChild( "query" );
if (!query) return true;
Tag *xdata = query->findChild("x", "xmlns", "jabber:x:data");
if (xdata) {
if (query->hasChild( "remove" ))
remove = true;
for (std::list<Tag*>::const_iterator it = xdata->children().begin(); it != xdata->children().end(); ++it) {
std::string key = (*it)->findAttribute("var");
if (key.empty()) continue;
Tag *v = (*it)->findChild("value");
if (!v) continue;
if (key == "username")
username = v->cdata();
else if (key == "password")
password = v->cdata();
else if (key == "language")
language = v->cdata();
else if (key == "encoding")
encoding = v->cdata();
else if (key == "unregister")
remove = atoi(v->cdata().c_str());
}
}
else {
if (query->hasChild( "remove" ))
remove = true;
else {
usernametag = query->findChild("username");
passwordtag = query->findChild("password");
languagetag = query->findChild("language");
encodingtag = query->findChild("encoding");
if (languagetag)
language = languagetag->cdata();
else
language = Transport::instance()->getConfiguration().language;
示例13: handleIqID
bool Search::handleIqID( Stanza *stanza, int context )
{
TrackMap::iterator it = m_track.find( stanza->id() );
if( it != m_track.end() )
{
switch( stanza->subtype() )
{
case StanzaIqResult:
switch( context )
{
case FetchSearchFields:
{
Tag *q = stanza->findChild( "query" );
if( q && q->hasAttribute( "xmlns", XMLNS_SEARCH ) )
{
Tag *x = q->findChild( "x", "xmlns", XMLNS_X_DATA );
if( x )
{
DataForm *df = new DataForm( x );
(*it).second->handleSearchFields( stanza->from(), df );
}
else
{
int fields = 0;
std::string instructions;
if( q->hasChild( "first" ) )
fields |= SearchFieldFirst;
if( q->hasChild( "last" ) )
fields |= SearchFieldLast;
if( q->hasChild( "nick" ) )
fields |= SearchFieldNick;
if( q->hasChild( "email" ) )
fields |= SearchFieldEmail;
if( q->hasChild( "instructions" ) )
instructions = q->findChild( "instructions" )->cdata();
(*it).second->handleSearchFields( stanza->from(), fields, instructions );
}
}
break;
}
case DoSearch:
{
Tag *q = stanza->findChild( "query" );
if( q && q->hasAttribute( "xmlns", XMLNS_SEARCH ) )
{
Tag *x = q->findChild( "x", "xmlns", XMLNS_X_DATA );
if( x )
{
DataForm *df = new DataForm( x );
(*it).second->handleSearchResult( stanza->from(), df );
}
else
{
SearchResultList e;
SearchFieldStruct s;
const Tag::TagList &l = q->children();
Tag::TagList::const_iterator itl = l.begin();
for( ; itl != l.end(); ++itl )
{
if( (*itl)->name() == "item" )
{
s.jid.setJID( (*itl)->findAttribute( "jid" ) );
Tag *t = 0;
if( ( t = (*itl)->findChild( "first" ) ) != 0 )
s.first = t->cdata();
if( ( t = (*itl)->findChild( "last" ) ) != 0 )
s.last = t->cdata();
if( ( t = (*itl)->findChild( "nick" ) ) != 0 )
s.nick = t->cdata();
if( ( t = (*itl)->findChild( "email" ) ) != 0 )
s.email = t->cdata();
e.push_back( s );
}
}
(*it).second->handleSearchResult( stanza->from(), e );
}
}
break;
}
}
break;
case StanzaIqError:
(*it).second->handleSearchError( stanza->from(), stanza );
break;
default:
break;
}
m_track.erase( it );
}
return false;
}