summaryrefslogtreecommitdiff
path: root/src/irc/iid.hpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-06-11 02:37:11 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-06-11 02:37:11 +0200
commit7c1a38999c2eebfbd0939c9f8f8f864f10d9bc9a (patch)
tree258af2b9ab6c31640f4454dd22867ac688e8345b /src/irc/iid.hpp
parent6210a9d50b216f22a8b755c2c9daea66659514f0 (diff)
downloadbiboumi-7c1a38999c2eebfbd0939c9f8f8f864f10d9bc9a.tar.gz
biboumi-7c1a38999c2eebfbd0939c9f8f8f864f10d9bc9a.tar.bz2
biboumi-7c1a38999c2eebfbd0939c9f8f8f864f10d9bc9a.tar.xz
biboumi-7c1a38999c2eebfbd0939c9f8f8f864f10d9bc9a.zip
Rewrite the whole IID usage
IRC users and channels are now distinguished by the separator used in the IID (% or !). ref #2468
Diffstat (limited to 'src/irc/iid.hpp')
-rw-r--r--src/irc/iid.hpp63
1 files changed, 50 insertions, 13 deletions
diff --git a/src/irc/iid.hpp b/src/irc/iid.hpp
index a62ac71..2302a18 100644
--- a/src/irc/iid.hpp
+++ b/src/irc/iid.hpp
@@ -4,17 +4,40 @@
#include <string>
/**
- * A name representing an IRC channel, on the same model than the XMPP JIDs (but much simpler).
- * The separator between the server and the channel name is '%'
- * #test%irc.freenode.org has :
- * - chan: "#test" (the # is part of the name, it could very well be absent, or & instead
- * - server: "irc.freenode.org"
- * #test has:
- * - chan: "#test"
- * - server: ""
- * %irc.freenode.org:
- * - chan: ""
- * - server: "irc.freenode.org"
+ * A name representing an IRC channel on an IRC server, or an IRC user on an
+ * IRC server, or just an IRC server.
+ *
+ * The separator for an user is '!', for a channel it's '%'. If no separator
+ * is present, it's just an irc server.
+ * It’s possible to have an empty-string server, but it makes no sense in
+ * the biboumi context.
+ *
+ * #test%irc.example.org has :
+ * - local: "#test" (the # is part of the name, it could very well be absent, or & (for example) instead)
+ * - server: "irc.example.org"
+ * - is_channel: true
+ * - is_user: false
+ *
+ * %irc.example.org:
+ * - local: ""
+ * - server: "irc.example.org"
+ * - is_channel: true
+ * - is_user: false
+ * Note: this is the special empty-string channel, used internal in biboumi
+ * but has no meaning on IRC.
+ *
+ * foo!irc.example.org
+ * - local: "foo"
+ * - server: "irc.example.org"
+ * - is_channel: false
+ * - is_user: true
+ * Note: the empty-string user (!irc.example.org) has no special meaning in biboumi
+ *
+ * irc.example.org:
+ * - local: ""
+ * - server: "irc.example.org"
+ * - is_channel: false
+ * - is_user: false
*/
class Iid
{
@@ -22,14 +45,28 @@ public:
explicit Iid(const std::string& iid);
explicit Iid();
- std::string chan;
- std::string server;
+ void set_local(const std::string& loc);
+ void set_server(const std::string& serv);
+ const std::string& get_local() const;
+ const std::string& get_server() const;
+
+ bool is_channel;
+ bool is_user;
+
+ std::string get_sep() const;
private:
+ std::string local;
+ std::string server;
+
Iid(const Iid&) = delete;
Iid(Iid&&) = delete;
Iid& operator=(const Iid&) = delete;
Iid& operator=(Iid&&) = delete;
};
+namespace std {
+ const std::string to_string(const Iid& iid);
+}
+
#endif // IID_INCLUDED