diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-12-17 15:25:20 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-12-17 16:11:19 (GMT) |
commit | bdb8ace202917809c5492aa37921e0ffd0354730 (patch) | |
tree | 52e93ebf3a555c690086b1bce0b2e01c1bf943b6 /Swiften/JID | |
parent | e32059da8bffc67806862bf78f762d67fb3e4848 (diff) | |
download | swift-contrib-bdb8ace202917809c5492aa37921e0ffd0354730.zip swift-contrib-bdb8ace202917809c5492aa37921e0ffd0354730.tar.bz2 |
Added eclipse project file.
Diffstat (limited to 'Swiften/JID')
-rw-r--r-- | Swiften/JID/JID.h | 134 |
1 files changed, 73 insertions, 61 deletions
diff --git a/Swiften/JID/JID.h b/Swiften/JID/JID.h index ad89c85..0bfb858 100644 --- a/Swiften/JID/JID.h +++ b/Swiften/JID/JID.h @@ -1,68 +1,80 @@ -#ifndef SWIFTEN_JID_H -#define SWIFTEN_JID_H +#pragma once #include "Swiften/Base/String.h" namespace Swift { - class JID - { - public: - enum CompareType { WithResource, WithoutResource }; - - explicit JID(const String& = String()); - explicit JID(const char*); - JID(const String& node, const String& domain); - JID(const String& node, const String& domain, const String& resource); - - bool isValid() const { return !domain_.isEmpty(); /* FIXME */ } - - const String& getNode() const { return node_; } - const String& getDomain() const { return domain_; } - const String& getResource() const { return resource_; } - bool isBare() const { return !hasResource_; } - - JID toBare() const { return JID(getNode(), getDomain()); /* FIXME: Duplicate unnecessary nameprepping. Probably ok. */ } - - String toString() const; - - bool equals(const JID& o, CompareType compareType) const { - return compare(o, compareType) == 0; - } - - int compare(const JID& o, CompareType compareType) const; - - operator String () const { return toString(); } - - bool operator<(const Swift::JID& b) const { - return compare(b, Swift::JID::WithResource) < 0; - } - - friend std::ostream& operator<<(std::ostream& os, const Swift::JID& j) { - os << j.toString(); - return os; - } - - friend bool operator==(const Swift::JID& a, const Swift::JID& b) { - return a.compare(b, Swift::JID::WithResource) == 0; - } - - friend bool operator!=(const Swift::JID& a, const Swift::JID& b) { - return a.compare(b, Swift::JID::WithResource) != 0; - } - - protected: - void nameprepAndSetComponents(const String& node, const String& domain, const String& resource); + class JID { + public: + enum CompareType { + WithResource, WithoutResource + }; + + explicit JID(const String& = String()); + explicit JID(const char*); + JID(const String& node, const String& domain); + JID(const String& node, const String& domain, const String& resource); + + bool isValid() const { + return !domain_.isEmpty(); /* FIXME */ + } + + const String& getNode() const { + return node_; + } + const String& getDomain() const { + return domain_; + } + const String& getResource() const { + return resource_; + } + bool isBare() const { + return !hasResource_; + } + + JID toBare() const { + return JID(getNode(), getDomain()); /* FIXME: Duplicate unnecessary nameprepping. Probably ok. */ + } + + String toString() const; + + bool equals(const JID& o, CompareType compareType) const { + return compare(o, compareType) == 0; + } + + int compare(const JID& o, CompareType compareType) const; + + operator String() const { + return toString(); + } + + bool operator<(const Swift::JID& b) const { + return compare(b, Swift::JID::WithResource) < 0; + } + + friend std::ostream& operator<<(std::ostream& os, const Swift::JID& j) { + os << j.toString(); + return os; + } + + friend bool operator==(const Swift::JID& a, const Swift::JID& b) { + return a.compare(b, Swift::JID::WithResource) == 0; + } + + friend bool operator!=(const Swift::JID& a, const Swift::JID& b) { + return a.compare(b, Swift::JID::WithResource) != 0; + } + + protected: + void nameprepAndSetComponents(const String& node, const String& domain, + const String& resource); + + private: + void initializeFromString(const String&); - private: - void initializeFromString(const String&); - - private: - String node_; - String domain_; - bool hasResource_; - String resource_; + private: + String node_; + String domain_; + bool hasResource_; + String resource_; }; } - -#endif - |