summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/JID/JID.h')
-rw-r--r--Swiften/JID/JID.h43
1 files changed, 35 insertions, 8 deletions
diff --git a/Swiften/JID/JID.h b/Swiften/JID/JID.h
index a4461ba..aefd3df 100644
--- a/Swiften/JID/JID.h
+++ b/Swiften/JID/JID.h
@@ -1,4 +1,4 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
@@ -8,8 +8,12 @@
#include <string>
-//#include <iosfwd>
-#include <iostream>
+#include <iosfwd>
+
+#include <Swiften/Base/API.h>
+#include <boost/optional/optional_fwd.hpp>
namespace Swift {
+ class IDNConverter;
+
/**
* This represents the JID used in XMPP
@@ -23,5 +27,5 @@ namespace Swift {
* guaranteed to work correctly if they do.
*/
- class JID {
+ class SWIFTEN_API JID {
public:
enum CompareType {
@@ -44,4 +48,6 @@ namespace Swift {
/**
* See std::string constructor.
+ *
+ * Must not be NULL.
*/
JID(const char*);
@@ -129,4 +135,12 @@ namespace Swift {
}
+ /**
+ * Get the full JID with the supplied resource.
+ */
+ JID withResource(const std::string& resource) const {
+ JID result(this->getNode(), this->getDomain(), resource);
+ return result;
+ }
+
std::string toString() const;
@@ -145,8 +159,5 @@ namespace Swift {
}
- friend std::ostream& operator<<(std::ostream& os, const Swift::JID& j) {
- os << j.toString();
- return os;
- }
+ SWIFTEN_API friend std::ostream& operator<<(std::ostream& os, const Swift::JID& j);
friend bool operator==(const Swift::JID& a, const Swift::JID& b) {
@@ -158,4 +169,17 @@ namespace Swift {
}
+ /**
+ * Returns an empty optional if the JID is invalid, and an
+ * optional with a value if the JID is valid.
+ */
+ static boost::optional<JID> parse(const std::string&);
+
+ /**
+ * If Swiften was compiled with SWIFTEN_JID_NO_DEFAULT_IDN_CONVERTER (not default), use this method at
+ * the beginning of the program to set an IDN converter to use for JID IDN conversions.
+ * By default, this method shouldn't be used.
+ */
+ static void setIDNConverter(IDNConverter*);
+
private:
void nameprepAndSetComponents(const std::string& node, const std::string& domain, const std::string& resource);
@@ -169,3 +193,6 @@ namespace Swift {
std::string resource_;
};
+
+ SWIFTEN_API std::ostream& operator<<(std::ostream& os, const Swift::JID& j);
}
+