error.h
/*
Copyright (c) 2007-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 ERROR_H__
#define ERROR_H__
#include "gloox.h"
#include "stanzaextension.h"
#include <string>
#include <map>
namespace gloox
{
class Tag;
class GLOOX_API Error : public StanzaExtension
{
public:
// Error()
// : StanzaExtension( ExtError ), m_type( StanzaErrorTypeUndefined ),
// m_error( StanzaErrorUndefined ), m_appError( 0 )
// {}
Error( const Tag* tag = 0 );
Error( StanzaErrorType type, StanzaError error, Tag* appError = 0 )
: StanzaExtension( ExtError ), m_type( type ),
m_error( error ), m_appError( appError )
{}
virtual ~Error();
StanzaErrorType type() const { return m_type; }
StanzaError error() const { return m_error; }
const Tag* appError() const { return m_appError; }
void setAppError( Tag* appError );
const std::string& text( const std::string& lang = EmptyString ) const;
void setText( const std::string& text, const std::string& lang = EmptyString )
{
m_text[lang] = text;
}
// reimplemented from StanzaExtension
virtual const std::string& filterString() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* newInstance( const Tag* tag ) const
{
return new Error( tag );
}
// reimplemented from StanzaExtension
virtual Tag* tag() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* clone() const
{
return new Error( *this );
}
private:
Error( const Error& error );
void setValues( const Tag* tag );
StanzaErrorType m_type;
StanzaError m_error;
Tag* m_appError;
StringMap m_text;
};
}
#endif // ERROR_H__
gloox::Error
A stanza error abstraction implemented as a StanzaExtension.
Definition error.h:35
gloox::Error::clone
virtual StanzaExtension * clone() const
Definition error.h:127
gloox::Error::appError
const Tag * appError() const
Definition error.h:83
gloox::Error::Error
Error(const Tag *tag=0)
Definition error.cpp:67
gloox::Error::type
StanzaErrorType type() const
Definition error.h:69
gloox::Error::setText
void setText(const std::string &text, const std::string &lang=EmptyString)
Definition error.h:109
gloox::Error::Error
Error(StanzaErrorType type, StanzaError error, Tag *appError=0)
Definition error.h:55
gloox::Error::newInstance
virtual StanzaExtension * newInstance(const Tag *tag) const
Definition error.h:118
gloox::Error::text
const std::string & text(const std::string &lang=EmptyString) const
Definition error.cpp:132
gloox::Error::error
StanzaError error() const
Definition error.h:75
gloox::Error::tag
virtual Tag * tag() const
Definition error.cpp:109
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
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::EmptyString
const std::string EmptyString
Definition gloox.cpp:124
gloox::StanzaError
StanzaError
Definition gloox.h:872
gloox::StanzaErrorType
StanzaErrorType
Definition gloox.h:857
gloox::ExtError
@ ExtError
Definition stanzaextension.h:47
gloox::StringMap
std::map< std::string, std::string > StringMap
Definition gloox.h:1261