jid.h
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
00152 static std::string escapeNode( const std::string& node );
00153
00159 static std::string unescapeNode( const std::string& node );
00160
00161 private:
00165 void setStrings() { setBare(); setFull(); }
00166
00171 void setBare();
00172
00176 void setFull();
00177
00178 std::string m_resource;
00179 std::string m_username;
00180 std::string m_server;
00181 std::string m_serverRaw;
00182 std::string m_bare;
00183 std::string m_full;
00184 bool m_valid;
00185
00186 };
00187
00188 }
00189
00190 #endif // JID_H__