Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

stanza.h

00001 /*
00002   Copyright (c) 2005-2008 by Jakob Schroeter <js@camaya.net>
00003   This file is part of the gloox library. http://camaya.net/gloox
00004 
00005   This software is distributed under a license. The full license
00006   agreement can be found in the file LICENSE in this distribution.
00007   This software may not be copied, modified, sold or distributed
00008   other than expressed in the named license agreement.
00009 
00010   This software is distributed without any warranty.
00011 */
00012 
00013 
00014 #ifndef STANZA_H__
00015 #define STANZA_H__
00016 
00017 #include "gloox.h"
00018 #include "tag.h"
00019 #include "jid.h"
00020 #include "stanzaextension.h"
00021 
00022 namespace gloox
00023 {
00024 
00025   class Error;
00026 
00033   class GLOOX_API Stanza
00034   {
00035     public:
00039       virtual ~Stanza();
00040 
00045       const JID& from() const { return m_from; }
00046 
00051       const JID& to() const { return m_to; }
00052 
00057       const std::string& id() const { return m_id; }
00058 
00063       const Error* error() const;
00064 
00070       const std::string& xmlLang() const { return m_xmllang; }
00071 
00079       void addExtension( const StanzaExtension* se );
00080 
00086       const StanzaExtension* findExtension( int type ) const;
00087 
00097       template< class T >
00098       inline const T* findExtension( int type ) const
00099       {
00100         return static_cast<const T*>( findExtension( type ) );
00101       }
00102 
00107       const StanzaExtensionList& extensions() const { return m_extensionList; }
00108 
00112       void removeExtensions();
00113 
00121       virtual Tag* tag() const = 0;
00122 
00123 #ifdef GLOOX_TESTS
00124       void setFrom( const JID& from ) { m_from = from; }
00125 #endif
00126 
00127     protected:
00133       Stanza( Tag* tag );
00134 
00140       Stanza( const JID& to );
00141 
00142       StanzaExtensionList m_extensionList;
00143       std::string m_id;
00144       std::string m_xmllang;
00145       JID m_from;
00146       JID m_to;
00147 
00148       static const std::string& findLang( const StringMap* map,
00149                                           const std::string& defaultData,
00150                                           const std::string& lang );
00151 
00152       static void setLang( StringMap** map,
00153                            std::string& defaultLang,
00154                            const Tag* tag );
00155 
00156       static void setLang( StringMap** map,
00157                            std::string& defaultLang,
00158                            const std::string& data,
00159                            const std::string& xmllang );
00160 
00161       static void getLangs( const StringMap* map,
00162                             const std::string& defaultData,
00163                             const std::string& name, Tag* tag );
00164 
00165     private:
00166       Stanza( const Stanza& );
00167 
00168   };
00169 
00170 }
00171 
00172 #endif // STANZA_H__

Generated on Mon Jun 23 10:50:19 2008 for gloox by  doxygen 1.4.1