Public Types | Public Member Functions | Static Public Member Functions | Friends

Swift::JID Class Reference

This represents the JID used in XMPP (RFC6120 - http://tools.ietf.org/html/rfc6120 ). More...

Collaboration diagram for Swift::JID:

List of all members.

Public Types

enum  CompareType { WithResource, WithoutResource }

Public Member Functions

 JID (const std::string &jid=std::string())
 Create a JID from its String representation.
 JID (const char *)
 See std::string constructor.
 JID (const std::string &node, const std::string &domain)
 Create a bare JID from the node and domain parts.
 JID (const std::string &node, const std::string &domain, const std::string &resource)
 Create a bare JID from the node, domain and resource parts.
bool isValid () const
const std::string & getNode () const
 e.g.
const std::string & getDomain () const
 e.g.
const std::string & getResource () const
 e.g.
bool isBare () const
 Is a bare JID, i.e.
std::string getUnescapedNode () const
 Returns the node of the current JID, unescaped according to XEP-0106.
JID toBare () const
 Get the JID without a resource.
std::string toString () const
bool equals (const JID &o, CompareType compareType) const
int compare (const JID &o, CompareType compareType) const
 operator std::string () const
bool operator< (const Swift::JID &b) const

Static Public Member Functions

static std::string getEscapedNode (const std::string &node)
 Returns the given node, escaped according to XEP-0106.

Friends

std::ostream & operator<< (std::ostream &os, const Swift::JID &j)
bool operator== (const Swift::JID &a, const Swift::JID &b)
bool operator!= (const Swift::JID &a, const Swift::JID &b)

Detailed Description

This represents the JID used in XMPP (RFC6120 - http://tools.ietf.org/html/rfc6120 ).

For a description of format, see the RFC or page 14 of XMPP: The Definitive Guide (Saint-Andre et al.)

Particularly - a Bare JID is a JID without a resource part.

A JID can be invalid (when isValid() returns false). No member methods are guaranteed to work correctly if they do.

Definition at line 27 of file JID.h.


Member Enumeration Documentation

Enumerator:
WithResource 
WithoutResource 

Definition at line 29 of file JID.h.


Constructor & Destructor Documentation

Swift::JID::JID ( const std::string &  jid = std::string()  ) 

Create a JID from its String representation.

e.g. wonderland.lit wonderland.lit/rabbithole alice@wonderland.lit alice@wonderland.lit/TeaParty

Parameters:
jid String representation. Invalid JID if empty or invalid.
Swift::JID::JID ( const char *   ) 

See std::string constructor.

Swift::JID::JID ( const std::string &  node,
const std::string &  domain 
)

Create a bare JID from the node and domain parts.

JID("node@domain") == JID("node", "domain") unless you pass in empty values.

Parameters:
node JID node part.
domain JID domain part.
Swift::JID::JID ( const std::string &  node,
const std::string &  domain,
const std::string &  resource 
)

Create a bare JID from the node, domain and resource parts.

JID("node@domain/resource") == JID("node", "domain", "resource") unless you pass in empty values.

Parameters:
node JID node part.
domain JID domain part.
resource JID resource part.

Member Function Documentation

int Swift::JID::compare ( const JID o,
CompareType  compareType 
) const
bool Swift::JID::equals ( const JID o,
CompareType  compareType 
) const [inline]

Definition at line 135 of file JID.h.

const std::string& Swift::JID::getDomain (  )  const [inline]

e.g.

JID("node@domain").getDomain() == "domain"

Definition at line 91 of file JID.h.

static std::string Swift::JID::getEscapedNode ( const std::string &  node  )  [static]

Returns the given node, escaped according to XEP-0106.

The resulting node is a valid node for a JID, whereas the input value can contain characters that are not allowed.

const std::string& Swift::JID::getNode (  )  const [inline]

e.g.

JID("node@domain").getNode() == "node"

Returns:
could be empty.

Definition at line 84 of file JID.h.

const std::string& Swift::JID::getResource (  )  const [inline]

e.g.

JID("node@domain/resource").getResource() == "resource"

Returns:
could be empty.

Definition at line 99 of file JID.h.

std::string Swift::JID::getUnescapedNode (  )  const

Returns the node of the current JID, unescaped according to XEP-0106.

bool Swift::JID::isBare (  )  const [inline]

Is a bare JID, i.e.

has no resource part.

Definition at line 106 of file JID.h.

bool Swift::JID::isValid (  )  const [inline]
Returns:
Is a correctly-formatted JID.

Definition at line 76 of file JID.h.

Referenced by Swift::IQRouter::isAccountJID().

Swift::JID::operator std::string (  )  const [inline]

Definition at line 141 of file JID.h.

References toString().

bool Swift::JID::operator< ( const Swift::JID b  )  const [inline]

Definition at line 145 of file JID.h.

References WithResource.

JID Swift::JID::toBare (  )  const [inline]

Get the JID without a resource.

Returns:
Invalid if the original is invalid.

Definition at line 126 of file JID.h.

std::string Swift::JID::toString (  )  const

Friends And Related Function Documentation

bool operator!= ( const Swift::JID a,
const Swift::JID b 
) [friend]

Definition at line 158 of file JID.h.

std::ostream& operator<< ( std::ostream &  os,
const Swift::JID j 
) [friend]

Definition at line 149 of file JID.h.

bool operator== ( const Swift::JID a,
const Swift::JID b 
) [friend]

Definition at line 154 of file JID.h.