summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-03-28 13:40:14 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-03-28 13:40:43 (GMT)
commitb61486fefe602e0d18fa5279021006f87b965307 (patch)
tree437585cbef1179e1ec31f79789591d5610200c29 /Swiften/JID/JID.cpp
parentdae28dd45e43fc6e6ef2ec4c6c65d5d736ed86f8 (diff)
downloadswift-contrib-b61486fefe602e0d18fa5279021006f87b965307.zip
swift-contrib-b61486fefe602e0d18fa5279021006f87b965307.tar.bz2
Moved Swiften to a separate module.
Diffstat (limited to 'Swiften/JID/JID.cpp')
m---------Swiften0
-rw-r--r--Swiften/JID/JID.cpp86
2 files changed, 0 insertions, 86 deletions
diff --git a/Swiften b/Swiften
new file mode 160000
+Subproject 8213ba16d0043d2461f4b031c881d61dda5a38c
diff --git a/Swiften/JID/JID.cpp b/Swiften/JID/JID.cpp
deleted file mode 100644
index 3be8386..0000000
--- a/Swiften/JID/JID.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-#include <stringprep.h>
-#include <vector>
-#include <iostream>
-
-#include "Swiften/JID/JID.h"
-#include "Swiften/StringPrep/StringPrep.h"
-
-namespace Swift {
-
-JID::JID(const char* jid) {
- initializeFromString(String(jid));
-}
-
-JID::JID(const String& jid) {
- initializeFromString(jid);
-}
-
-JID::JID(const String& node, const String& domain) : hasResource_(false) {
- nameprepAndSetComponents(node, domain, "");
-}
-
-JID::JID(const String& node, const String& domain, const String& resource) : hasResource_(true) {
- nameprepAndSetComponents(node, domain, resource);
-}
-
-void JID::initializeFromString(const String& jid) {
- if (jid.beginsWith('@')) {
- return;
- }
-
- String bare, resource;
- size_t slashIndex = jid.find('/');
- if (slashIndex != jid.npos()) {
- hasResource_ = true;
- bare = jid.getSubstring(0, slashIndex);
- resource = jid.getSubstring(slashIndex + 1, jid.npos());
- }
- else {
- hasResource_ = false;
- bare = jid;
- }
- std::pair<String,String> nodeAndDomain = bare.getSplittedAtFirst('@');
- if (nodeAndDomain.second.isEmpty()) {
- nameprepAndSetComponents("", nodeAndDomain.first, resource);
- }
- else {
- nameprepAndSetComponents(nodeAndDomain.first, nodeAndDomain.second, resource);
- }
-}
-
-
-void JID::nameprepAndSetComponents(const String& node, const String& domain, const String& resource) {
- node_ = StringPrep::getPrepared(node, StringPrep::NamePrep);
- domain_ = StringPrep::getPrepared(domain, StringPrep::XMPPNodePrep);
- resource_ = StringPrep::getPrepared(resource, StringPrep::XMPPResourcePrep);
-}
-
-String JID::toString() const {
- String string;
- if (!node_.isEmpty()) {
- string += node_ + "@";
- }
- string += domain_;
- if (!isBare()) {
- string += "/" + resource_;
- }
- return string;
-}
-
-int JID::compare(const Swift::JID& o, CompareType compareType) const {
- if (node_ < o.node_) { return -1; }
- if (node_ > o.node_) { return 1; }
- if (domain_ < o.domain_) { return -1; }
- if (domain_ > o.domain_) { return 1; }
- if (compareType == WithResource) {
- if (hasResource_ != o.hasResource_) {
- return hasResource_ ? 1 : -1;
- }
- if (resource_ < o.resource_) { return -1; }
- if (resource_ > o.resource_) { return 1; }
- }
- return 0;
-}
-
-} // namespace Swift
-