pubsubitem.cpp
/*
Copyright (c) 2005-2023 by Jakob Schröter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#include "pubsubitem.h"
#include "tag.h"
namespace gloox
{
namespace PubSub
{
Item::Item()
: m_payload( 0 )
{
}
Item::Item( const Tag* tag )
: m_payload( 0 )
{
if( !tag || tag->name() != "item" )
return;
m_id = tag->findAttribute( "id" );
if( tag->children().size() )
m_payload = tag->children().front()->clone();
}
Item::Item( const Item& item )
: m_payload( item.m_payload ? item.m_payload->clone() : 0 )
{
m_id = item.m_id;
}
Item::~Item()
{
delete m_payload;
}
void Item::setPayload( Tag* tag )
{
delete m_payload;
m_payload = tag;
}
Tag* Item::tag() const
{
Tag* t = new Tag( "item" );
t->addAttribute( "id", m_id );
if( m_payload )
t->addChild( m_payload->clone() );
return t;
}
}
}
gloox::PubSub::Item::~Item
~Item()
Definition pubsubitem.cpp:46
gloox::PubSub::Item::setPayload
void setPayload(Tag *tag)
Definition pubsubitem.cpp:51
gloox::PubSub::Item::Item
Item()
Definition pubsubitem.cpp:23
gloox::PubSub::Item::tag
Tag * tag() const
Definition pubsubitem.cpp:57
gloox::Tag
This is an abstraction of an XML element.
Definition tag.h:47
gloox::Tag::addAttribute
bool addAttribute(Attribute *attr)
Definition tag.cpp:354
gloox::Tag::addChild
void addChild(Tag *child)
Definition tag.cpp:424
gloox::PubSub
Namespace holding all the Pubsub-related structures and definitions.
Definition pubsub.h:28
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28