~singpolyma/biboumi

ref: 7c1a38999c2eebfbd0939c9f8f8f864f10d9bc9a biboumi/src/irc/iid.hpp -rw-r--r-- 1.7 KiB
7c1a3899 — Florent Le Coz Rewrite the whole IID usage 8 years ago
                                                                                
bf7b05ef Florent Le Coz
7c1a3899 Florent Le Coz
bf7b05ef Florent Le Coz
a418b6ed Florent Le Coz
bf7b05ef Florent Le Coz
7c1a3899 Florent Le Coz
bf7b05ef Florent Le Coz
7c1a3899 Florent Le Coz
bf7b05ef Florent Le Coz
7c1a3899 Florent Le Coz
bf7b05ef Florent Le Coz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef IID_INCLUDED
# define IID_INCLUDED

#include <string>

/**
 * 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
{
public:
  explicit Iid(const std::string& iid);
  explicit Iid();

  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