jid.h
/*
Copyright (c) 2005-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 JID_H__
#define JID_H__
#include "macros.h"
#include <string>
namespace gloox
{
class GLOOX_API JID
{
public:
JID() : m_valid( false ) {}
JID( const std::string& jid ) : m_valid( true ) { setJID( jid ); }
~JID() {}
bool setJID( const std::string& jid );
const std::string& full() const { return m_full; }
const std::string& bare() const { return m_bare; }
JID bareJID() const { return JID( bare() ); }
bool setUsername( const std::string& username );
bool setServer( const std::string& server );
bool setResource( const std::string& resource );
const std::string& username() const { return m_username; }
const std::string& server() const { return m_server; }
const std::string& serverRaw() const { return m_serverRaw; }
const std::string& resource() const { return m_resource; }
bool operator==( const std::string& right ) const { return full() == right; }
bool operator!=( const std::string& right ) const { return full() != right; }
bool operator==( const JID& right ) const { return full() == right.full(); }
bool operator!=( const JID& right ) const { return full() != right.full(); }
bool operator<( const JID& right ) const { return full() < right.full(); }
bool operator<=( const JID& right ) const { return full() <= right.full(); }
bool operator>( const JID& right ) const { return full() > right.full(); }
bool operator>=( const JID& right ) const { return full() >= right.full(); }
operator bool() const { return m_valid; }
static std::string escapeNode( const std::string& node );
static std::string unescapeNode( const std::string& node );
private:
void setStrings() { setBare(); setFull(); }
void setBare();
void setFull();
std::string m_resource;
std::string m_username;
std::string m_server;
std::string m_serverRaw;
std::string m_bare;
std::string m_full;
bool m_valid;
};
}
#endif // JID_H__
gloox::JID::operator!=
bool operator!=(const std::string &right) const
Definition jid.h:128
gloox::JID::~JID
~JID()
Definition jid.h:48
gloox::JID::operator==
bool operator==(const JID &right) const
Definition jid.h:134
gloox::JID::username
const std::string & username() const
Definition jid.h:98
gloox::JID::server
const std::string & server() const
Definition jid.h:104
gloox::JID::setJID
bool setJID(const std::string &jid)
Definition jid.cpp:21
gloox::JID::operator<
bool operator<(const JID &right) const
Definition jid.h:148
gloox::JID::JID
JID(const std::string &jid)
Definition jid.h:43
gloox::JID::operator==
bool operator==(const std::string &right) const
Definition jid.h:122
gloox::JID::resource
const std::string & resource() const
Definition jid.h:116
gloox::JID::operator>=
bool operator>=(const JID &right) const
Definition jid.h:169
gloox::JID::operator<=
bool operator<=(const JID &right) const
Definition jid.h:155
gloox::JID::JID
JID()
Definition jid.h:37
gloox::JID::operator!=
bool operator!=(const JID &right) const
Definition jid.h:140
gloox::JID::full
const std::string & full() const
Definition jid.h:61
gloox::JID::operator>
bool operator>(const JID &right) const
Definition jid.h:162
gloox::JID::serverRaw
const std::string & serverRaw() const
Definition jid.h:110
gloox::JID::bareJID
JID bareJID() const
Definition jid.h:74
gloox::JID::bare
const std::string & bare() const
Definition jid.h:67
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28