softwareversion.cpp
/*
Copyright (c) 2008-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 "softwareversion.h"
#include "tag.h"
namespace gloox
{
SoftwareVersion::SoftwareVersion( const std::string& name,
const std::string& version,
const std::string& os )
: StanzaExtension( ExtVersion ), m_name( name ), m_version( version ), m_os( os )
{
}
SoftwareVersion::SoftwareVersion( const Tag* tag )
: StanzaExtension( ExtVersion )
{
if( !tag )
return;
Tag* t = tag->findChild( "name" );
if( t )
m_name = t->cdata();
t = tag->findChild( "version" );
if( t )
m_version = t->cdata();
t = tag->findChild( "os" );
if( t )
m_os = t->cdata();
}
SoftwareVersion::~SoftwareVersion()
{
}
const std::string& SoftwareVersion::filterString() const
{
static const std::string filter = "/iq/query[@xmlns='" + XMLNS_VERSION + "']";
return filter;
}
Tag* SoftwareVersion::tag() const
{
Tag* t = new Tag( "query" );
t->setXmlns( XMLNS_VERSION );
if( !m_name.empty() )
new Tag( t, "name", m_name );
if( !m_version.empty() )
new Tag( t, "version", m_version );
if( !m_os.empty() )
new Tag( t, "os", m_os );
return t;
}
}
gloox::SoftwareVersion::~SoftwareVersion
virtual ~SoftwareVersion()
Definition softwareversion.cpp:47
gloox::SoftwareVersion::name
const std::string & name() const
Definition softwareversion.h:61
gloox::SoftwareVersion::version
const std::string & version() const
Definition softwareversion.h:67
gloox::SoftwareVersion::os
const std::string & os() const
Definition softwareversion.h:73
gloox::SoftwareVersion::filterString
virtual const std::string & filterString() const
Definition softwareversion.cpp:51
gloox::SoftwareVersion::SoftwareVersion
SoftwareVersion(const std::string &name, const std::string &version, const std::string &os)
Definition softwareversion.cpp:21
gloox::SoftwareVersion::tag
virtual Tag * tag() const
Definition softwareversion.cpp:57
gloox::StanzaExtension::StanzaExtension
StanzaExtension(int type)
Definition stanzaextension.h:211
gloox::Tag
This is an abstraction of an XML element.
Definition tag.h:47
gloox::Tag::cdata
const std::string cdata() const
Definition tag.cpp:497
gloox::Tag::setXmlns
bool setXmlns(const std::string &xmlns, const std::string &prefix=EmptyString)
Definition tag.cpp:522
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::XMLNS_VERSION
const std::string XMLNS_VERSION
Definition gloox.cpp:39
gloox::ExtVersion
@ ExtVersion
Definition stanzaextension.h:56