gloox
1.0.24
src
pubsubitem.cpp
1
/*
2
Copyright (c) 2005-2019 by Jakob Schröter <js@camaya.net>
3
This file is part of the gloox library. http://camaya.net/gloox
4
5
This software is distributed under a license. The full license
6
agreement can be found in the file LICENSE in this distribution.
7
This software may not be copied, modified, sold or distributed
8
other than expressed in the named license agreement.
9
10
This software is distributed without any warranty.
11
*/
12
13
14
#include "pubsubitem.h"
15
#include "tag.h"
16
17
namespace
gloox
18
{
19
20
namespace
PubSub
21
{
22
23
Item::Item
()
24
: m_payload( 0 )
25
{
26
}
27
28
Item::Item
(
const
Tag
* tag )
29
: m_payload( 0 )
30
{
31
if
( !
tag
||
tag
->
name
() !=
"item"
)
32
return
;
33
34
m_id =
tag
->
findAttribute
(
"id"
);
35
36
if
(
tag
->
children
().size() )
37
m_payload =
tag
->
children
().front()->clone();
38
}
39
40
Item::Item
(
const
Item
& item )
41
: m_payload( item.m_payload ? item.m_payload->clone() : 0 )
42
{
43
m_id = item.m_id;
44
}
45
46
Item::~Item
()
47
{
48
delete
m_payload;
49
}
50
51
void
Item::setPayload
(
Tag
* tag )
52
{
53
delete
m_payload;
54
m_payload =
tag
;
55
}
56
57
Tag
*
Item::tag
()
const
58
{
59
Tag
* t =
new
Tag
(
"item"
);
60
t->
addAttribute
(
"id"
, m_id );
61
if
( m_payload )
62
t->
addChild
( m_payload->
clone
() );
63
64
return
t;
65
}
66
67
}
68
69
}
gloox::Tag::clone
Tag * clone() const
Definition:
tag.cpp:670
gloox::PubSub::Item::~Item
~Item()
Definition:
pubsubitem.cpp:46
gloox::PubSub::Item
Abstracts a PubSub Item (XEP-0060).
Definition:
pubsubitem.h:38
gloox::Tag::children
const TagList & children() const
Definition:
tag.cpp:510
gloox::Tag::findAttribute
const std::string & findAttribute(const std::string &name) const
Definition:
tag.cpp:589
gloox::Tag::addChild
void addChild(Tag *child)
Definition:
tag.cpp:424
gloox::PubSub::Item::tag
Tag * tag() const
Definition:
pubsubitem.cpp:57
gloox
The namespace for the gloox library.
Definition:
adhoc.cpp:28
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::name
const std::string & name() const
Definition:
tag.h:394
gloox::PubSub::Item::setPayload
void setPayload(Tag *tag)
Definition:
pubsubitem.cpp:51
gloox::PubSub::Item::Item
Item()
Definition:
pubsubitem.cpp:23
Generated on Mon Aug 17 2020 01:21:43 for gloox by
1.8.18