gloox  1.0.16
nickname.cpp
1 /*
2  Copyright (c) 2007-2015 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 #include "nickname.h"
14 #include "tag.h"
15 
16 namespace gloox
17 {
18 
19  Nickname::Nickname( const Tag* tag )
21  {
22  if( tag )
23  m_nick = tag->cdata();
24  }
25 
26  const std::string& Nickname::filterString() const
27  {
28  static const std::string filter =
29  "/presence/nick[@xmlns='" + XMLNS_NICKNAME + "']"
30  "|/message/nick[@xmlns='" + XMLNS_NICKNAME + "']";
31  return filter;
32  }
33 
34  Tag* Nickname::tag() const
35  {
36  if( m_nick.empty() )
37  return 0;
38 
39  Tag* n = new Tag( "nick", XMLNS, XMLNS_NICKNAME );
40  n->setCData( m_nick );
41  return n;
42  }
43 
44 }
const std::string XMLNS
Definition: gloox.cpp:121
const std::string XMLNS_NICKNAME
Definition: gloox.cpp:99
bool setCData(const std::string &cdata)
Definition: tag.cpp:446
The namespace for the gloox library.
Definition: adhoc.cpp:27
This class abstracts a stanza extension, which is usually an element in a specific namespace...
const std::string cdata() const
Definition: tag.cpp:496
Tag * tag() const
Definition: nickname.cpp:34
virtual const std::string & filterString() const
Definition: nickname.cpp:26
Nickname(const Tag *tag)
Definition: nickname.cpp:19
This is an abstraction of an XML element.
Definition: tag.h:46