本文整理汇总了C++中Tag::findAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ Tag::findAttribute方法的具体用法?C++ Tag::findAttribute怎么用?C++ Tag::findAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tag
的用法示例。
在下文中一共展示了Tag::findAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseFileList
void FileTransfer::parseFileList( const TagList& files )
{
TagList::const_iterator it = files.begin();
for( ; it != files.end(); ++it )
{
File f;
Tag *t = (*it)->findChild( "name" );
f.name = t ? t->cdata() : EmptyString;
t = (*it)->findChild( "desc" );
f.desc = t ? t->cdata() : EmptyString;
t = (*it)->findChild( "date" );
f.date = t ? t->cdata() : EmptyString;
t = (*it)->findChild( "size" );
f.size = t ? atoi( t->cdata().c_str() ) : -1;
t = (*it)->findChild( "range" );
if( t )
{
f.range = true;
f.offset = t->hasAttribute( "offset" ) ? atoi( t->findAttribute( "offset" ).c_str() ) : -1;
}
t = (*it)->findChild( "hash", XMLNS, XMLNS_HASHES );
if( t )
{
f.hash_algo = t->findAttribute( "algo" );
f.hash = t->cdata();
}
m_files.push_back( f );
}
}
示例2: handleIq
bool InBandBytestreamManager::handleIq( Stanza *stanza )
{
Tag *o = 0;
if( ( stanza->subtype() == StanzaIqSet ) &&
( ( o = stanza->findChild( "open", "xmlns", XMLNS_IBB ) ) != 0 ) )
{
InBandBytestream *ibb = new InBandBytestream( 0, m_parent );
const std::string sid = o->findAttribute( "sid" );
ibb->setSid( sid );
if( !m_inbandBytestreamHandler )
rejectInBandBytestream( ibb, stanza->from(), stanza->id() );
if( !m_syncInbandBytestreams )
{
AsyncIBBItem item;
item.ibb = ibb;
item.from = stanza->from();
item.id = stanza->id();
m_asyncTrackMap[sid] = item;
}
bool t = m_inbandBytestreamHandler->handleIncomingInBandBytestream( stanza->from(), ibb );
if( m_syncInbandBytestreams && t )
{
acceptInBandBytestream( ibb, stanza->from(), stanza->id() );
}
else if( m_syncInbandBytestreams && !t )
{
rejectInBandBytestream( ibb, stanza->from(), stanza->id() );
}
}
else if( ( stanza->subtype() == StanzaIqSet ) &&
( ( o = stanza->findChild( "close", "xmlns", XMLNS_IBB ) ) != 0 ) &&
o->hasAttribute( "sid" ) )
{
IBBMap::iterator it = m_ibbMap.find( o->findAttribute( "sid" ) );
if( it != m_ibbMap.end() )
{
(*it).second->closed();
Tag *iq = new Tag( "iq" );
iq->addAttribute( "type", "result" );
iq->addAttribute( "to", stanza->from().full() );
iq->addAttribute( "id", stanza->id() );
m_parent->send( iq );
}
}
else
{
return false;
}
return true;
}
示例3: StanzaExtension
jFileTransfer::StreamHostQuery::StreamHostQuery(const Tag *tag) : StanzaExtension(SExtFileTransfer)
{
if(!tag)
return;
Tag *streamhost = tag->findChild("streamhost");
if(!streamhost)
return;
m_jid = JID(streamhost->findAttribute("jid"));
m_host = streamhost->findAttribute("host");
m_port = atoi(streamhost->findAttribute("port").c_str());
m_zeroconf = streamhost->findAttribute("zeroconf");
}
示例4: 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;
}
示例5: filter
void InBandBytestream::filter( Stanza *stanza )
{
if( !m_inbandBytestreamDataHandler || !m_open )
return;
if( stanza->subtype() == StanzaMessageError )
{
m_inbandBytestreamDataHandler->handleInBandError( m_sid, stanza->from(), stanza->error() );
m_open = false;
}
Tag *data = 0;
if( ( data = stanza->findChild( "data", "xmlns", XMLNS_IBB ) ) == 0 )
return;
const std::string& sid = data->findAttribute( "sid" );
if( sid.empty() || sid != m_sid )
return;
const std::string& seq = data->findAttribute( "seq" );
if( seq.empty() )
{
m_open = false;
return;
}
std::stringstream str;
int sequence = 0;
str << seq;
str >> sequence;
if( m_lastChunkReceived + 1 != sequence )
{
m_open = false;
return;
}
m_lastChunkReceived = sequence;
if( !data->cdata().length() )
{
m_open = false;
return;
}
m_inbandBytestreamDataHandler->handleInBandData( Base64::decode64( data->cdata() ), sid );
}
示例6: send
void ClientBase::send( IQ& iq, IqHandler*, int )
{
Tag* tag = iq.tag();
switch( m_test )
{
case 1:
{
Tag* si = tag->findChild( "si", "xmlns", XMLNS_SI );
if( tag->findAttribute( "to" ) == to.full() && si && *(si->findChild( "file" )) == *t1
&& *(si->findChild( "feature" )) == *t2 && si->findAttribute( "mime-type" ) == "binary/octet-stream"
&& si->findAttribute( "profile" ) == g_profile )
m_ok = true;
break;
}
}
delete tag;
}
示例7: 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;
}
}
}
}
}
示例8: setResource
void ResourceManager::setResource(const Presence &stanza) {
std::string resource = stanza.from().resource();
if (resource.empty())
return;
Tag *stanzaTag = stanza.tag();
Tag *c = stanzaTag->findChildWithAttrib("xmlns", "http://jabber.org/protocol/caps");
int caps = -1;
// presence has caps
if (c != NULL) {
caps = Transport::instance()->getCapabilities(c->findAttribute("ver"));
}
setResource(resource, stanza.priority(), caps, (int) stanza.presence(), stanza.status());
delete stanzaTag;
}
示例9: handleIq
bool Adhoc::handleIq( Stanza *stanza )
{
if( stanza->subtype() != StanzaIqSet )
return false;
if( stanza->hasChild( "command" ) )
{
Tag *c = stanza->findChild( "command" );
const std::string& node = c->findAttribute( "node" );
AdhocCommandProviderMap::const_iterator it = m_adhocCommandProviders.find( node );
if( !node.empty() && ( it != m_adhocCommandProviders.end() ) )
{
(*it).second->handleAdhocCommand( node, c, stanza->from(), stanza->id() );
return true;
}
}
return false;
}
示例10: StanzaExtension
Adhoc::Command::Command( const Tag* tag )
: StanzaExtension( ExtAdhocCommand ), m_plugin( 0 ), m_actions( 0 )
{
if( !tag || tag->name() != "command" || tag->xmlns() != XMLNS_ADHOC_COMMANDS )
return;
m_node = tag->findAttribute( "node" );
m_sessionid = tag->findAttribute( "sessionid" );
m_status = static_cast<Status>( util::lookup( tag->findAttribute( "status" ), cmdStatusStringValues ) );
Tag* a = tag->findChild( "actions" );
if( a )
{
// Multi-stage response
m_action = static_cast<Action>( util::deflookup2( a->findAttribute( "action" ), cmdActionStringValues, Complete ) );
if( a->hasChild( "prev" ) )
m_actions |= Previous;
if( a->hasChild( "next" ) )
m_actions |= Next;
if( a->hasChild( "complete" ) )
m_actions |= Complete;
}
else
{
m_action = static_cast<Action>( util::deflookup2( tag->findAttribute( "action" ), cmdActionStringValues, Execute ) );
}
const ConstTagList& l = tag->findTagList( "/command/note" );
ConstTagList::const_iterator it = l.begin();
for( ; it != l.end(); ++it )
m_notes.push_back( new Note( (*it) ) );
Tag* x = tag->findChild( "x", "xmlns", XMLNS_X_DATA );
if( x )
m_plugin = new DataForm( x );
else
{
Tag* x = tag->findChild( "iodata", "xmlns", XMLNS_IODATA );
if( x )
m_plugin = new IOData( x );
}
}
示例11: 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) );
}
}
}
}
示例12: 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() );
}
}
}
示例13: if
XmppGSPlayback::XmppGSPlayback( const Tag* tag )
:StanzaExtension(ExtIotPlayback), m_camera_id(0), m_startdt(0), m_enddt(0), m_state(defPBState_Unknown), m_sound(-1)
{
if( !tag || tag->name() != "gsiot" || tag->xmlns() != XMLNS_GSIOT_PLAYBACK )
return;
Tag *tmgr = tag->findChild("playback");
if( tmgr )
{
Tag *tcamera = tmgr->findChild("device");
if( tcamera )
{
if( tcamera->hasAttribute("id") )
{
m_camera_id = atoi( tcamera->findAttribute("id").c_str() );
}
}
if( tmgr->findChild("startdate") )
{
m_startdt = atoi( tmgr->findChild("startdate")->cdata().c_str() );
}
if( tmgr->findChild("enddate") )
{
m_enddt = atoi( tmgr->findChild("enddate")->cdata().c_str() );
}
if( tmgr->findChild("url") )
{
m_url = tmgr->findChild("url")->cdata();
}
//#ifdef _DEBUG
#if 0
std::string useUrl_lastback;
if( IsRUNCODEEnable( defCodeIndex_TEST_Debug_TempCode ) )
{
if( !g_IsRTMFP_url( m_url ) ) useUrl_lastback = m_url;
//m_url = "rtmfp://192.168.0.76:1985/p2p";
m_url = "rtmfp://p2p.gsss.cn:1985/p2p";
//m_url = "rtmfp://unknownp2p.gsss.cn:1985/p2p";
GUID guid;
::CoCreateGuid( &guid );
m_url += "/";
m_url += g_BufferToString( (unsigned char*)&guid, sizeof( guid ), false, false );
}
#endif
if( IsRUNCODEEnable( defCodeIndex_RTMFP_DelFromUrlStreamID ) && g_IsRTMFP_url( m_url ) )
{
std::vector<std::string> useUrl_unit_vec;
split( m_url, useUrl_unit_vec, "/" );
const int unitsize = useUrl_unit_vec.size();
// 偶数个表示最后一个为streamid,去掉
if( 0 == (unitsize%2) )
{
g_replace_all_distinct( m_url, std::string( "/" )+useUrl_unit_vec[unitsize-1], "" );
}
}
Tag *tchildlist_url_backup = tmgr->findChild("url_backup");
if( tchildlist_url_backup )
{
const TagList& l = tchildlist_url_backup->children();
TagList::const_iterator it = l.begin();
for( ; it != l.end(); ++it )
{
Tag *tChild = (*it);
if( tChild->name() == "url" )
{
m_url_backup.push_back( tChild->cdata() );
}
}
}
//if( !useUrl_lastback.empty() ) m_url_backup.push_back( useUrl_lastback );
if( tmgr->findChild("key") )
{
m_key = tmgr->findChild("key")->cdata();
}
if( tmgr->findChild("state") )
{
std::string strState = tmgr->findChild("state")->cdata();
g_toLowerCase( strState );
if( strState == "start" )
{
m_state = defPBState_Start;
}
else if( strState == "stop" )
{
m_state = defPBState_Stop;
}
else if( strState == "set" )
{
//.........这里部分代码省略.........
示例14: main
//.........这里部分代码省略.........
++fail;
fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
}
//-------
name = "xml() 2";
t->addAttribute( "test", "bacd" );
if( t->xml() != "<toe foo='bar' test='bacd'><uni u3='3u'><who w3='3w'><zoo z3='3z'/></who><yps y3='3y'/>"
"</uni><vie v3='3v' v32='3v2'><xep x3='3x'/></vie><vie/></toe>" )
{
++fail;
fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
}
//-------
name = "hasChild 1";
if( !t->hasChild( "uni" ) || !t->hasChild( "vie" ) || !u->hasChild( "who" ) || !w->hasChild( "zoo" )
|| !u->hasChild( "yps" ) )
{
++fail;
fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
}
//-------
name = "hasAttribute 1";
if( !t->hasAttribute( "test" ) || !t->hasAttribute( "test", "bacd" )
|| !t->hasAttribute( "foo" ) || !t->hasAttribute( "foo", "bar" ) )
{
++fail;
fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
}
//-------
name = "findAttribute 1";
if( t->findAttribute( "test" ) != "bacd" || t->findAttribute( "foo" ) != "bar" )
{
++fail;
fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
}
//-------
name = "findChild 1";
c = t->findChild( "uni" );
if( c != u )
{
++fail;
fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
}
//-------
name = "findChild 2";
c = t->findChild( "uni", "u3" );
if( c != u )
{
++fail;
fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
}
//-------
name = "findChild 3";
c = t->findChild( "uni", "u3", "3u" );
if( c != u )
{
++fail;
fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
}
示例15: 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) );
}
}
}
}
}
}