pubsubitem.cpp

00001 /*
00002   Copyright (c) 2005-2009 by Jakob Schroeter <js@camaya.net>
00003   This file is part of the gloox library. http://camaya.net/gloox
00004 
00005   This software is distributed under a license. The full license
00006   agreement can be found in the file LICENSE in this distribution.
00007   This software may not be copied, modified, sold or distributed
00008   other than expressed in the named license agreement.
00009 
00010   This software is distributed without any warranty.
00011 */
00012 
00013 
00014 #include "pubsubitem.h"
00015 #include "tag.h"
00016 
00017 namespace gloox
00018 {
00019 
00020   namespace PubSub
00021   {
00022 
00023     Item::Item()
00024       : m_payload( 0 )
00025     {
00026     }
00027 
00028     Item::Item( const Tag* tag )
00029       : m_payload( 0 )
00030     {
00031       if( !tag || tag->name() != "item" )
00032         return;
00033 
00034       m_id = tag->findAttribute( "id" );
00035 
00036       if( tag->children().size() )
00037         m_payload = tag->children().front()->clone();
00038     }
00039 
00040     Item::Item( const Item& item )
00041       : m_payload( item.m_payload ? item.m_payload->clone() : 0 )
00042     {
00043       m_id = item.m_id;
00044     }
00045 
00046     Item::~Item()
00047     {
00048       delete m_payload;
00049     }
00050 
00051     Tag* Item::tag() const
00052     {
00053       Tag* t = new Tag( "item" );
00054       t->addAttribute( "id", m_id );
00055       if( m_payload )
00056         t->addChild( m_payload->clone() );
00057 
00058       return t;
00059     }
00060 
00061   }
00062 
00063 }

Generated by  doxygen 1.6.2