00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef JID_H__
00016 #define JID_H__
00017
00018 #include "macros.h"
00019
00020 #include <string>
00021
00022 namespace gloox
00023 {
00030 class GLOOX_API JID
00031 {
00032 public:
00033
00037 JID() : m_valid( false ) {}
00038
00043 JID( const std::string& jid ) : m_valid( true ) { setJID( jid ); }
00044
00048 ~JID() {}
00049
00055 bool setJID( const std::string& jid );
00056
00061 const std::string& full() const { return m_full; }
00062
00067 const std::string& bare() const { return m_bare; }
00068
00074 JID bareJID() const { return JID( bare() ); }
00075
00080 bool setUsername( const std::string& username );
00081
00086 bool setServer( const std::string& server );
00087
00092 bool setResource( const std::string& resource );
00093
00098 const std::string& username() const { return m_username; }
00099
00104 const std::string& server() const { return m_server; }
00105
00110 const std::string& serverRaw() const { return m_serverRaw; }
00111
00116 const std::string& resource() const { return m_resource; }
00117
00122 bool operator==( const std::string& right ) const { return full() == right; }
00123
00128 bool operator!=( const std::string& right ) const { return full() != right; }
00129
00134 bool operator==( const JID& right ) const { return full() == right.full(); }
00135
00140 bool operator!=( const JID& right ) const { return full() != right.full(); }
00141
00145 operator bool() const { return m_valid; }
00146
00147 private:
00151 void setStrings() { setBare(); setFull(); }
00152
00157 void setBare();
00158
00162 void setFull();
00163
00164 std::string m_resource;
00165 std::string m_username;
00166 std::string m_server;
00167 std::string m_serverRaw;
00168 std::string m_bare;
00169 std::string m_full;
00170 bool m_valid;
00171
00172 };
00173
00174 }
00175
00176 #endif // JID_H__