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
parent261ba8d8595ed8cb90f9c4feb1d6ef642942bcba (diff)
downloadswift-3d00d04ffbf40845058f6ede4da2592bb27a255d.zip
swift-3d00d04ffbf40845058f6ede4da2592bb27a255d.tar.bz2
Add copy/move ctors for JIDs
Test-Information: Unit tests still pass. Change-Id: I4e5b63104e482a79a933f337082c579db7bb8cff
-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&
72 nameprepAndSetComponents(node, domain, resource); 72 nameprepAndSetComponents(node, domain, resource);
73} 73}
74 74
75JID::JID(const JID& other) {
76 this->operator=(other);
77}
78
79JID::JID(JID&& other) {
80 this->operator=(std::move(other));
81}
82
83JID& JID::operator=(const JID& other) {
84 valid_ = other.valid_;
85 node_ = other.node_;
86 domain_ = other.domain_;
87 hasResource_ = other.hasResource_;
88 resource_ = other.resource_;
89 return *this;
90}
91
92JID& JID::operator=(JID&& other) {
93 valid_ = other.valid_;
94 other.valid_ = false;
95 node_ = std::move(other.node_);
96 domain_ = std::move(other.domain_);
97 hasResource_ = other.hasResource_;
98 resource_ = std::move(other.resource_);
99 return *this;
100}
101
75void JID::initializeFromString(const std::string& jid) { 102void JID::initializeFromString(const std::string& jid) {
76 if (String::beginsWith(jid, '@')) { 103 if (String::beginsWith(jid, '@')) {
77 valid_ = false; 104 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 {
75 */ 75 */
76 JID(const std::string& node, const std::string& domain, const std::string& resource); 76 JID(const std::string& node, const std::string& domain, const std::string& resource);
77 77
78 JID(const JID& other);
79 JID(JID&& other);
80 JID& operator=(const JID& other);
81 JID& operator=(JID&& other);
82
78 /** 83 /**
79 * @return Is a correctly-formatted JID. 84 * @return Is a correctly-formatted JID.
80 */ 85 */