error.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef ERROR_H__
00014 #define ERROR_H__
00015
00016 #include "gloox.h"
00017 #include "stanzaextension.h"
00018
00019 #include <string>
00020 #include <map>
00021
00022 namespace gloox
00023 {
00024
00025 class Tag;
00026
00034 class GLOOX_API Error : public StanzaExtension
00035 {
00036 public:
00037
00038
00039
00040
00041
00042
00047 Error( const Tag* tag = 0 );
00048
00055 Error( StanzaErrorType type, StanzaError error, Tag* appError = 0 )
00056 : StanzaExtension( ExtError ), m_type( type ),
00057 m_error( error ), m_appError( appError )
00058 {}
00059
00063 virtual ~Error();
00064
00069 StanzaErrorType type() const { return m_type; }
00070
00075 StanzaError error() const { return m_error; }
00076
00083 const Tag* appError() const { return m_appError; }
00084
00094 const std::string& text( const std::string& lang = EmptyString ) const;
00095
00103 void setText( const std::string& text, const std::string& lang = EmptyString )
00104 {
00105 m_text[lang] = text;
00106 }
00107
00108
00109 virtual const std::string& filterString() const;
00110
00111
00112 virtual StanzaExtension* newInstance( const Tag* tag ) const
00113 {
00114 return new Error( tag );
00115 }
00116
00117
00118 virtual Tag* tag() const;
00119
00120
00121 virtual StanzaExtension* clone() const
00122 {
00123 return new Error( *this );
00124 }
00125
00126 private:
00127 Error( const Error& error );
00128
00129 void setValues( const Tag* tag );
00130
00131 StanzaErrorType m_type;
00132 StanzaError m_error;
00133 Tag* m_appError;
00134 StringMap m_text;
00135 };
00136
00137 }
00138
00139 #endif