本文整理汇总了C++中Tag::cdata方法的典型用法代码示例。如果您正苦于以下问题:C++ Tag::cdata方法的具体用法?C++ Tag::cdata怎么用?C++ Tag::cdata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tag
的用法示例。
在下文中一共展示了Tag::cdata方法的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: handleMessage
virtual void handleMessage( const Message& msg, MessageSession * /*session*/ )
{
Tag* m = msg.tag();
Tag *x = m->findChild( "xtls", "xmlns", "test:xtls" );
if( x )
{
printf( "decrypting: %d\n", x->cdata().length() );
m_tls->decrypt( Base64::decode64( x->cdata() ) );
xtlsSend();
}
delete m;
}
示例3: handleIqID
bool UniqueMUCRoom::handleIqID( Stanza *stanza, int context )
{
switch( stanza->subtype() )
{
case StanzaIqResult:
if( context == RequestUniqueName )
{
Tag *u = stanza->findChild( "unique", XMLNS_MUC_UNIQUE );
if( u )
{
const std::string& name = u->cdata();
if( !name.empty() )
setName( name );
}
}
break;
case StanzaIqError:
if( context == RequestUniqueName )
{
SHA s;
s.feed( m_parent->jid().full() );
s.feed( m_parent->getID() );
setName( s.hex() );
}
break;
default:
break;
}
MUCRoom::join();
return false;
}
示例4: if
Presence::Presence( Tag* tag )
: Stanza( tag ), m_subtype( Invalid ), m_stati( 0 ), m_priority( 0 )
{
if( !tag || tag->name() != "presence" )
return;
const std::string& type = tag->findAttribute( TYPE );
if( type.empty() )
m_subtype = Available;
else
m_subtype = (PresenceType)util::lookup( type, msgTypeStringValues );
if( m_subtype == Available )
{
Tag* t = tag->findChild( "show" );
if( t )
m_subtype = (PresenceType)util::lookup( t->cdata(), msgShowStringValues );
}
const TagList& c = tag->children();
TagList::const_iterator it = c.begin();
for( ; it != c.end(); ++it )
{
if( (*it)->name() == "status" )
setLang( &m_stati, m_status, (*it) );
else if( (*it)->name() == "priority" )
m_priority = atoi( (*it)->cdata().c_str() );
}
}
示例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: if
DataFormField::DataFormField( Tag *tag )
: m_type( FIELD_TYPE_INVALID ), m_required( false )
{
if( !tag )
return;
if( tag->hasAttribute( "type", "boolean" ) )
m_type = FIELD_TYPE_BOOLEAN;
else if( tag->hasAttribute( "type", "fixed" ) )
m_type = FIELD_TYPE_FIXED;
else if( tag->hasAttribute( "type", "hidden" ) )
m_type = FIELD_TYPE_HIDDEN;
else if( tag->hasAttribute( "type", "jid-multi" ) )
m_type = FIELD_TYPE_JID_MULTI;
else if( tag->hasAttribute( "type", "jid-single" ) )
m_type = FIELD_TYPE_JID_SINGLE;
else if( tag->hasAttribute( "type", "list-multi" ) )
m_type = FIELD_TYPE_LIST_MULTI;
else if( tag->hasAttribute( "type", "list-single" ) )
m_type = FIELD_TYPE_LIST_SINGLE;
else if( tag->hasAttribute( "type", "text-multi" ) )
m_type = FIELD_TYPE_TEXT_MULTI;
else if( tag->hasAttribute( "type", "text-private" ) )
m_type = FIELD_TYPE_TEXT_PRIVATE;
else if( tag->hasAttribute( "type", "text-single" ) )
m_type = FIELD_TYPE_TEXT_SINGLE;
if( tag->hasAttribute( "var" ) )
m_name = tag->findAttribute( "var" );
if( tag->hasAttribute( "label" ) )
m_label = tag->findAttribute( "label" );
Tag::TagList l = tag->children();
Tag::TagList::const_iterator it = l.begin();
for( ; it != l.end(); ++it )
{
if( (*it)->name() == "desc" )
m_desc = (*it)->cdata();
else if( (*it)->name() == "required" )
m_required = true;
else if( (*it)->name() == "value" )
{
if( m_type == FIELD_TYPE_TEXT_MULTI || m_type == FIELD_TYPE_LIST_MULTI )
m_values.push_back( (*it)->cdata() );
else
m_value = (*it)->cdata();
}
else if( (*it)->name() == "option" )
{
Tag *v = (*it)->findChild( "value" );
if( v )
m_options[(*it)->findAttribute( "label" )] = v->cdata();
}
}
}
示例7: StanzaExtension
SoftwareVersion::SoftwareVersion( const Tag* tag )
: StanzaExtension( ExtVersion )
{
if( !tag )
return;
Tag* t = tag->findChild( "name" );
if( t )
m_name = t->cdata();
t = tag->findChild( "version" );
if( t )
m_version = t->cdata();
t = tag->findChild( "os" );
if( t )
m_os = t->cdata();
}
示例8:
const std::string AdhocTag::getValue(const std::string &var) {
if (xdata == NULL)
return "";
Tag *v = xdata->findChildWithAttrib("var", var);
if (!v)
return "";
Tag *value =v->findChild("value");
if (!value)
return "";
return value->cdata();
}
示例9: if
DataFormField::DataFormField( const Tag* tag )
: m_type( TypeInvalid ), m_required( false )
{
if( !tag )
return;
const std::string& type = tag->findAttribute( TYPE );
if( type.empty() )
{
if( !tag->name().empty() )
m_type = TypeNone;
}
else
m_type = (FieldType)util::lookup( type, fieldTypeValues );
if( tag->hasAttribute( "var" ) )
m_name = tag->findAttribute( "var" );
if( tag->hasAttribute( "label" ) )
m_label = tag->findAttribute( "label" );
const TagList& l = tag->children();
TagList::const_iterator it = l.begin();
for( ; it != l.end(); ++it )
{
if( (*it)->name() == "desc" )
m_desc = (*it)->cdata();
else if( (*it)->name() == "required" )
m_required = true;
else if( (*it)->name() == "value" )
{
if( m_type == TypeTextMulti || m_type == TypeListMulti || m_type == TypeJidMulti )
addValue( (*it)->cdata() );
else
setValue( (*it)->cdata() );
}
else if( (*it)->name() == "option" )
{
Tag* v = (*it)->findChild( "value" );
if( v )
m_options.insert( std::make_pair( (*it)->findAttribute( "label" ), v->cdata() ) );
}
}
}
示例10: StanzaExtension
MoodsExtenstion::MoodsExtenstion(const Tag* tag)
: StanzaExtension( ExtUser+107 )
{
if(!tag)
return;
TagList tag_list = tag->children();
if ( !tag_list.empty() )
m_mood_name = jProtocol::fromStd(tag_list.front()->name());
if(m_mood_name=="text")
m_mood_name="";
if(!m_mood_name.isEmpty())
{
if(!jPluginSystem::instance().getMoodTr().contains(m_mood_name))
m_mood_name="undefined";
Tag* t = tag->findChild( "text" );
if( t )
m_mood_text = jProtocol::fromStd(t->cdata());
}
}
示例11: processResourceBind
void Client::processResourceBind( Stanza *stanza )
{
switch( stanza->subtype() )
{
case StanzaIqResult:
{
Tag *bind = stanza->findChild( "bind" );
Tag *jid = bind->findChild( "jid" );
m_jid.setJID( jid->cdata() );
m_resourceBound = true;
if( m_streamFeatures & StreamFeatureSession )
createSession();
else
connected();
break;
}
case StanzaIqError:
{
Tag *error = stanza->findChild( "error" );
if( stanza->hasChild( "error", "type", "modify" )
&& error->hasChild( "bad-request", "xmlns", XMLNS_XMPP_STANZAS ) )
{
notifyOnResourceBindError( RbErrorBadRequest );
}
else if( stanza->hasChild( "error", "type", "cancel" ) )
{
if( error->hasChild( "not-allowed", "xmlns", XMLNS_XMPP_STANZAS ) )
notifyOnResourceBindError( RbErrorNotAllowed );
else if( error->hasChild( "conflict", "xmlns", XMLNS_XMPP_STANZAS ) )
notifyOnResourceBindError( RbErrorConflict );
else
notifyOnResourceBindError( RbErrorUnknownError );
}
else
notifyOnResourceBindError( RbErrorUnknownError );
break;
}
default:
break;
}
}
示例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
int main( int /*argc*/, char** /*argv*/ )
{
int fail = 0;
std::string name;
Tag *t = new Tag( "toe" ); t->addAttribute( "foo", "bar" );
Tag *u = new Tag( t, "uni" ); u->addAttribute( "u3", "3u" );
Tag *v = new Tag( t, "vie" ); v->addAttribute( "v3", "3v" );
Tag *v2 = new Tag( t, "vie" ); v->addAttribute( "v32", "3v2" );
Tag *w = new Tag( u, "who" ); w->addAttribute( "w3", "3w" );
Tag *x = new Tag( v, "xep" ); x->addAttribute( "x3", "3x" );
Tag *y = new Tag( u, "yps" ); y->addAttribute( "y3", "3y" );
Tag *z = new Tag( w, "zoo" ); z->addAttribute( "z3", "3z" );
Tag *c = 0;
Tag *d = 0;
// -------
name = "simple ctor";
if( t->name() != "toe" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
// -------
name = "cdata ctor";
c = new Tag( "cod", "foobar" );
if( c->name() != "cod" || c->cdata() != "foobar" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete c;
c = 0;
//-------
name = "clone test 1";
c = z->clone();
if( *z != *c )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete c;
c = 0;
//-------
name = "clone test 2";
c = t->clone();
if( *t != *c )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete c;
c = 0;
//-------
name = "operator== test 1";
c = new Tag( "name" );
if( *t == *c )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete c;
c = 0;
//-------
name = "operator== test 2";
c = new Tag( "test" );
c->addAttribute( "me", "help" );
c->addChild( new Tag( "yes" ) );
if( *t == *c )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete c;
c = 0;
//-------
name = "operator== test 3";
c = new Tag( "hello" );
c->addAttribute( "test", "bacd" );
c->addChild( new Tag( "hello" ) );
d = new Tag( "hello" );
d->addAttribute( "test", "bacd" );
d->addChild( new Tag( "helloo" ) );
if( *d == *c )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete c;
delete d;
c = 0;
d = 0;
//-------
name = "operator!= test 1";
//.........这里部分代码省略.........
示例15: handleIqID
bool Adhoc::handleIqID( Stanza * stanza, int context )
{
if( context != ExecuteAdhocCommand || stanza->subtype() != StanzaIqResult )
return false;
AdhocTrackMap::iterator it = m_adhocTrackMap.begin();
for( ; it != m_adhocTrackMap.end(); ++it )
{
if( (*it).second.context == context && (*it).second.remote == stanza->from() )
{
Tag *c = stanza->findChild( "command", "xmlns", XMLNS_ADHOC_COMMANDS );
if( c )
{
const std::string& command = c->findAttribute( "node" );
const std::string& id = c->findAttribute( "sessionid" );
Tag *a = c->findChild( "actions" );
int actions = ActionCancel;
Adhoc::AdhocExecuteActions def = ActionCancel;
if( a )
{
if( a->hasChild( "prev" ) )
actions |= ActionPrevious;
if( a->hasChild( "next" ) )
actions |= ActionNext;
if( a->hasChild( "complete" ) )
actions |= ActionComplete;
const std::string& d = a->findAttribute( "execute" );
if( d == "next" )
def = ActionNext;
else if( d == "prev" )
def = ActionPrevious;
else if( d == "complete" )
def = ActionComplete;
}
Tag *n = c->findChild( "note" );
std::string note;
AdhocNoteType type = AdhocNoteInfo;
if( n )
{
note = n->cdata();
if( n->hasAttribute( "type", "warn" ) )
type = AdhocNoteWarn;
else if( n->hasAttribute( "type", "error" ) )
type = AdhocNoteError;
}
const std::string& s = c->findAttribute( "status" );
AdhocCommandStatus status = AdhocCommandStatusUnknown;
if( s == "executing" )
status = AdhocCommandExecuting;
else if( s == "completed" )
status = AdhocCommandCompleted;
else if( s == "canceled" )
status = AdhocCommandCanceled;
DataForm form;
Tag *x = c->findChild( "x", "xmlns", XMLNS_X_DATA );
if( x )
form.parse( x );
(*it).second.ah->handleAdhocExecutionResult( stanza->from(), command, status, id, form,
actions, def, note, type );
}
m_adhocTrackMap.erase( it );
return true;
}
}
return false;
}