Operator
C++ library for plugging into matrix.org
types.hh
Go to the documentation of this file.
1 
20 #ifndef __OPERATOR_TYPES_HH_
21 #define __OPERATOR_TYPES_HH_
22 
23 #include "error.hh"
24 
25 #include <string>
26 #include <json.hpp>
27 
28 namespace Operator {
29  class ServerName {
30  std::string name;
31  public:
32  ServerName(std::string _name) : name(_name) {}
33  std::string getName() { return name; }
34  bool empty() { return name.empty(); }
35  };
36 
37  namespace User {
38  class IDOrLocalpart {
39  std::string id;
40  public:
41  IDOrLocalpart(std::string _id) : id(_id) {}
42  std::string getLocalPart() const;
43  ServerName getServer() const;
44  };
45 
46  class ID : public IDOrLocalpart {
47  public:
48  ID(std::string mxid) : IDOrLocalpart(mxid) {}
49  std::string getLocalPart() const;
50  ServerName getServer() const;
51  };
52 
53  namespace ThreePID {
54  class ThreePID {
55  std::string address;
56  std::string medium;
57  public:
58  ThreePID(std::string _addr, std::string _medium) : address(_addr), medium(_medium) {}
59  const std::string &getAddress() const { return address; }
60  const std::string &getMedium() const { return medium; }
61  };
62 
63  class Email : public ThreePID {
64  public:
65  Email(std::string email) : ThreePID(email, "email") {}
66  };
67  }
68  }
69 
70  namespace Room {
71  class IDOrAlias {
72  std::string room;
73  public:
74  IDOrAlias(std::string _room) : room(_room) {}
75  const std::string &getName() const { return room; }
76  };
77 
78  class ID : public IDOrAlias {
79  public:
80  ID(std::string room) : IDOrAlias(room) {}
81  };
82 
83  class Alias : public IDOrAlias {
84  Alias(std::string room) : IDOrAlias(room) {}
85  };
86  }
87 
90  template<typename... T> using callback_t = typename std::function<void (std::shared_ptr<Error::Error> err, T...)>;
91 }
92 
93 #endif // __OPERATOR_TYPES_HH_
Definition: client.hh:32
Definition: types.hh:54
Definition: types.hh:38
Definition: types.hh:29
Definition: types.hh:83
Definition: types.hh:63
Definition: types.hh:46
Error handling.
Definition: types.hh:71
typename std::function< void(std::shared_ptr< Error::Error > err, T...)> callback_t
general type for callbacks
Definition: structs.hh:43
Definition: types.hh:78