stanza.h
/*
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.
*/
#ifndef STANZA_H__
#define STANZA_H__
#include "gloox.h"
#include "tag.h"
#include "jid.h"
#include "stanzaextension.h"
namespace gloox
{
class Error;
class GLOOX_API Stanza
{
public:
virtual ~Stanza();
void setFrom( const JID& from ) { m_from = from; }
const JID& from() const { return m_from; }
const JID& to() const { return m_to; }
const std::string& id() const { return m_id; }
const Error* error() const;
const std::string& xmlLang() const { return m_xmllang; }
void addExtension( const StanzaExtension* se );
const StanzaExtension* findExtension( int type ) const;
template< class T >
inline const T* findExtension( int type ) const
{
return static_cast<const T*>( findExtension( type ) );
}
const StanzaExtensionList& extensions() const { return m_extensionList; }
void removeExtensions();
void setEmbeddedStanza() { m_hasEmbeddedStanza = true; }
bool hasEmbeddedStanza() const { return m_hasEmbeddedStanza; }
Stanza* embeddedStanza() const;
Tag* embeddedTag() const;
virtual Tag* tag() const = 0;
protected:
Stanza( Tag* tag );
Stanza( const JID& to );
StanzaExtensionList m_extensionList;
std::string m_id;
std::string m_xmllang;
JID m_from;
JID m_to;
static const std::string& findLang( const StringMap* map,
const std::string& defaultData,
const std::string& lang );
static void setLang( StringMap** map,
std::string& defaultLang,
const Tag* tag );
static void setLang( StringMap** map,
std::string& defaultLang,
const std::string& data,
const std::string& xmllang );
static void getLangs( const StringMap* map,
const std::string& defaultData,
const std::string& name, Tag* tag );
private:
Stanza( const Stanza& );
bool m_hasEmbeddedStanza;
};
}
#endif // STANZA_H__
gloox::Error
A stanza error abstraction implemented as a StanzaExtension.
Definition error.h:35
gloox::JID
An abstraction of a JID.
Definition jid.h:31
gloox::StanzaExtension
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
Definition stanzaextension.h:204
gloox::Stanza
This is the base class for XMPP stanza abstractions.
Definition stanza.h:34
gloox::Stanza::setFrom
void setFrom(const JID &from)
Definition stanza.h:45
gloox::Stanza::id
const std::string & id() const
Definition stanza.h:63
gloox::Stanza::Stanza
Stanza(Tag *tag)
Definition stanza.cpp:31
gloox::Stanza::extensions
const StanzaExtensionList & extensions() const
Definition stanza.h:113
gloox::Stanza::tag
virtual Tag * tag() const =0
gloox::Stanza::findExtension
const T * findExtension(int type) const
Definition stanza.h:104
gloox::Stanza::hasEmbeddedStanza
bool hasEmbeddedStanza() const
Definition stanza.h:135
gloox::Stanza::xmlLang
const std::string & xmlLang() const
Definition stanza.h:76
gloox::Stanza::from
const JID & from() const
Definition stanza.h:51
gloox::Stanza::to
const JID & to() const
Definition stanza.h:57
gloox::Stanza::findExtension
const StanzaExtension * findExtension(int type) const
Definition stanza.cpp:57
gloox::Stanza::setEmbeddedStanza
void setEmbeddedStanza()
Definition stanza.h:126
gloox::Tag
This is an abstraction of an XML element.
Definition tag.h:47
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::StanzaExtensionList
std::list< const StanzaExtension * > StanzaExtensionList
Definition gloox.h:1272
gloox::StringMap
std::map< std::string, std::string > StringMap
Definition gloox.h:1261