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


C++ Tag::clone方法代码示例

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


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

示例1: StanzaExtension

  // ---- SIManager::SI ----
  SIManager::SI::SI( const Tag* tag )
    : StanzaExtension( ExtSI ), m_tag1( 0 ), m_tag2( 0 )
  {
    if( !tag || tag->name() != "si" || tag->xmlns() != XMLNS_SI )
      return;

    m_valid = true;

    m_id = tag->findAttribute( "id" );
    m_mimetype = tag->findAttribute( "mime-type" );
    m_profile = tag->findAttribute( "profile" );

    Tag* c = tag->findChild( "file", "xmlns", XMLNS_SI_FT );
    if ( c )
      m_tag1 = c->clone();
    c = tag->findChild( "feature", "xmlns", XMLNS_FEATURE_NEG );
    if( c )
      m_tag2 = c->clone();
  }
开发者ID:Abhi347,项目名称:s3eGloox,代码行数:20,代码来源:simanager.cpp

示例2: StanzaExtension

  Forward::Forward( const Tag* tag )
    : StanzaExtension( ExtForward ),
      m_stanza( 0 ), m_tag( 0 ), m_delay( 0 )
  {
    if( !tag || !( tag->name() == "forwarded" && tag->hasAttribute( XMLNS, XMLNS_STANZA_FORWARDING ) ) )
      return;

    m_delay = new DelayedDelivery( tag->findChild( "delay", XMLNS, XMLNS_DELAY ) );

    Tag* m = tag->findChild( "message" );
    if( !m )
      return;

    m_tag = m->clone();
    m_stanza = new Message( m );
  }
开发者ID:SiteView,项目名称:eccmeteor,代码行数:16,代码来源:forward.cpp

示例3: Tag

AdhocTag::AdhocTag(const IQ &stanza) : Tag("command") {
    m_from = stanza.from().full();
    m_id = stanza.id();
    xdata = NULL;
    Tag *iq = stanza.tag();
    Tag *command = iq->findChild("command");
    if (command) {
        const Tag::AttributeList & attributes = command->attributes();
        for (Tag::AttributeList::const_iterator it = attributes.begin(); it != attributes.end(); it++) {
            addAttribute(std::string((*it)->name()), std::string((*it)->value()));
        }
        Tag *x = command->findChildWithAttrib("xmlns","jabber:x:data");
        if (x) {
            xdata = x->clone();
            addChild(xdata);
        }
    }
    delete iq;
}
开发者ID:bochi,项目名称:spectrum-gw,代码行数:19,代码来源:adhoctag.cpp

示例4: 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";
//.........这里部分代码省略.........
开发者ID:jvalvert,项目名称:societas,代码行数:101,代码来源:tag_test.cpp

示例5: addUsers

void SpectrumMUCConversation::addUsers(AbstractUser *user, GList *cbuddies) {
	Log(m_jid, "ADDING USERS3");
	GList *l = cbuddies;
	while (l != NULL) {
		PurpleConvChatBuddy *cb = (PurpleConvChatBuddy *)l->data;
// 		std::string alias(cb->alias ? cb->alias: "");
		std::string name(cb->name);
		int flags = GPOINTER_TO_INT(cb->flags);
// 		PURPLE_CBFLAGS_OP
// 		<presence
// 		from='[email protected]/firstwitch'
// 		to='[email protected]/pda'>
// 		<x xmlns='http://jabber.org/protocol/muc#user'>
// 		<item affiliation='member' role='participant'/>
// 		</x>
// 		</presence>
		Tag *tag = new Tag("presence");
		tag->addAttribute("from", m_jid + "/" + name);
		tag->addAttribute("to", user->jid() + m_res);

		Tag *x = new Tag("x");
		x->addAttribute("xmlns", "http://jabber.org/protocol/muc#user");

		Tag *item = new Tag("item");


		if (flags & PURPLE_CBFLAGS_OP || flags & PURPLE_CBFLAGS_HALFOP) {
			item->addAttribute("affiliation", "admin");
			item->addAttribute("role", "moderator");
		}
		else if (flags & PURPLE_CBFLAGS_FOUNDER) {
			item->addAttribute("affiliation", "owner");
			item->addAttribute("role", "moderator");
		}
		else {
			item->addAttribute("affiliation", "member");
			item->addAttribute("role", "participant");
		}

		if (name == m_nickname) {
			Tag *status = new Tag("status");
			status->addAttribute("code", "110");
			item->addChild(status);
		}

		x->addChild(item);
		tag->addChild(x);

		if (name == m_nickname) {
			if (m_lastPresence)
				delete m_lastPresence;
			m_lastPresence = tag->clone();
		}
		Transport::instance()->send(tag);

		l = l->next;
	}
	if (!m_connected && !m_topic.empty()) {
		sendTopic(user);
	}
	m_connected = true;
}
开发者ID:bochi,项目名称:spectrum-gw,代码行数:62,代码来源:spectrummucconversation.cpp

示例6: AdhocPlugin

  IOData::IOData( const Tag* tag )
    : AdhocPlugin( ExtIOData ),
      m_in( 0 ), m_out( 0 ), m_error( 0 ),
      m_type( TypeInvalid )
  {
    if( !tag || !( tag->name() == "iodata" && tag->hasAttribute( XMLNS, XMLNS_IODATA ) ) )
      return;

    m_status.elapsed = -1;
    m_status.remaining = -1;
    m_status.percentage = -1;

    m_type = ioType( tag->findAttribute( "type" ) );
    Tag* m = 0;
    switch( m_type )
    {
      case TypeInput:
        m = tag->findChild( "in" );
        if( m )
          m_in = m->clone();
        break;
      case TypeIoSchemataResult:
        m = tag->findChild( "desc" );
        if( m )
          m_desc = m->cdata();

        m = tag->findChild( "out" );
        if( m )
          m_out = m->clone();

        m = tag->findChild( "in" );
        if( m )
          m_in = m->clone();
        break;
      case TypeOutput:
        m = tag->findChild( "out" );
        if( m )
          m_out = m->clone();
        break;
      case TypeError:
        m = tag->findChild( "error" );
        if( m )
          m_error = m->clone();
        break;
      case TypeStatus:
        m = tag->findChild( "status" );
        if( m )
        {
          Tag* t = m->findChild( "elapsed" );
          if( t )
            m_status.elapsed = atoi( t->cdata().c_str() );

          t = m->findChild( "remaining" );
          if( t )
            m_status.remaining = atoi( t->cdata().c_str() );

          t = m->findChild( "percentage" );
          if( t )
            m_status.percentage = atoi( t->cdata().c_str() );

          t = m->findChild( "information" );
          if( t )
            m_status.info = t->cdata();
        }
        break;
      case TypeIoSchemataGet:
      case TypeGetStatus:
      case TypeGetOutput:
      default:
        break;
    }

  }
开发者ID:OSUser,项目名称:avbot,代码行数:73,代码来源:iodata.cpp

示例7: main

int main( int /*argc*/, char** /*argv*/ )
{
  int fail = 0;
  std::string name;
  IOData *i = 0;
  Tag* t = 0;
  Tag* f = 0;
  Tag* s = new Tag( "iodata" );
  s->setXmlns( XMLNS_IODATA );


  // -------
  name = "parsing 0 tag";
  i = new IOData( 0 );
  if( i->tag() != 0 )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete i;
  i = 0;

  // -------
  name = "parsing 'io-schemata-get' type";
  s->addAttribute( "type", "io-schemata-get" );
  i = new IOData( s );
  if( i->tag()->xml() != s->xml() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete i;
  i = 0;

  // -------
  name = "parsing 'input' type";
  t = s->clone();
  t->addAttribute( "type", "input" );
  f = new Tag( t, "in" );
  new Tag( f, "foo" );
  i = new IOData( t );
  if( i->tag()->xml() != t->xml() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\ni: %s\ns: %s\n", name.c_str(), i->tag()->xml().c_str(), t->xml().c_str() );
  }
  delete i;
  i = 0;
  delete t;
  t = 0;

  // -------
  name = "parsing 'getStatus' type";
  s->addAttribute( "type", "getStatus" );
  i = new IOData( s );
  if( i->tag()->xml() != s->xml() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete i;
  i = 0;

  // -------
  name = "parsing 'getOutput' type";
  s->addAttribute( "type", "getOutput" );
  i = new IOData( s );
  if( i->tag()->xml() != s->xml() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete i;
  i = 0;

  // -------
  name = "parsing 'io-schemata-result' type";
  t = s->clone();
  t->addAttribute( "type", "io-schemata-result" );
  f = new Tag( t, "in" );
  new Tag( f, "foo" );
  f = new Tag( t, "out" );
  new Tag( f, "foobar" );
  f = new Tag( t, "desc", "some description" );
  i = new IOData( t );
  if( i->tag()->xml() != t->xml() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\ni: %s\ns: %s\n", name.c_str(), i->tag()->xml().c_str(), t->xml().c_str() );
  }
  delete i;
  i = 0;
  delete t;
  t = 0;

  // -------
  name = "parsing 'output' type";
  t = s->clone();
  t->addAttribute( "type", "output" );
  f = new Tag( t, "out" );
//.........这里部分代码省略.........
开发者ID:github188,项目名称:BasicFunctionCodeBase,代码行数:101,代码来源:iodata_test.cpp


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