summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2019-07-19 13:01:51 (GMT)
committerKevin Smith <git@kismith.co.uk>2020-01-09 15:48:42 (GMT)
commit3d00d04ffbf40845058f6ede4da2592bb27a255d (patch)
treeb12dc80807e68cfdf901ea3bc6f469298894a3a6 /Swiften
parent261ba8d8595ed8cb90f9c4feb1d6ef642942bcba (diff)
downloadswift-3d00d04ffbf40845058f6ede4da2592bb27a255d.zip
swift-3d00d04ffbf40845058f6ede4da2592bb27a255d.tar.bz2
Add copy/move ctors for JIDs
Test-Information: Unit tests still pass. Change-Id: I4e5b63104e482a79a933f337082c579db7bb8cff
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/JID/JID.cpp27
-rw-r--r--Swiften/JID/JID.h5
2 files changed, 32 insertions, 0 deletions
diff --git a/Swiften/JID/JID.cpp b/Swiften/JID/JID.cpp
index a584b79..eb72014 100644
--- a/Swiften/JID/JID.cpp
+++ b/Swiften/JID/JID.cpp
@@ -72,6 +72,33 @@ JID::JID(const std::string& node, const std::string& domain, const std::string&
nameprepAndSetComponents(node, domain, resource);
}
+JID::JID(const JID& other) {
+ this->operator=(other);
+}
+
+JID::JID(JID&& other) {
+ this->operator=(std::move(other));
+}
+
+JID& JID::operator=(const JID& other) {
+ valid_ = other.valid_;
+ node_ = other.node_;
+ domain_ = other.domain_;
+ hasResource_ = other.hasResource_;
+ resource_ = other.resource_;
+ return *this;
+}
+
+JID& JID::operator=(JID&& other) {
+ valid_ = other.valid_;
+ other.valid_ = false;
+ node_ = std::move(other.node_);
+ domain_ = std::move(other.domain_);
+ hasResource_ = other.hasResource_;
+ resource_ = std::move(other.resource_);
+ return *this;
+}
+
void JID::initializeFromString(const std::string& jid) {
if (String::beginsWith(jid, '@')) {
valid_ = false;
diff --git a/Swiften/JID/JID.h b/Swiften/JID/JID.h
index e98b796..aecc7cb 100644
--- a/Swiften/JID/JID.h
+++ b/Swiften/JID/JID.h
@@ -75,6 +75,11 @@ namespace Swift {
*/
JID(const std::string& node, const std::string& domain, const std::string& resource);
+ JID(const JID& other);
+ JID(JID&& other);
+ JID& operator=(const JID& other);
+ JID& operator=(JID&& other);
+
/**
* @return Is a correctly-formatted JID.
*/