]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_regex.h
b10a5115b8cab3b6f7ee14a541b09167239b4b3a
[user/henk/code/inspircd.git] / src / modules / m_regex.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *          the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #ifndef _M_REGEX_H
15 #define _M_REGEX_H
16
17 #include "inspircd.h"
18
19 class Regex : public classbase
20 {
21 protected:
22         std::string regex_string; // The raw uncompiled regex string.
23         InspIRCd* ServerInstance;
24
25         // Constructor may as well be protected, as this class is abstract.
26         Regex(const std::string& rx, InspIRCd* Me) : regex_string(rx), ServerInstance(Me)
27         {
28         }
29
30 public:
31
32         virtual ~Regex()
33         {
34         }
35
36         virtual bool Matches(const std::string& text) = 0;
37
38         const std::string& GetRegexString() const
39         {
40                 return regex_string;
41         }
42 };
43
44 class RegexFactoryRequest : public Request
45 {
46 private:
47         std::string regex;
48
49 public:
50         Regex* result;
51
52         RegexFactoryRequest(Module* Me, Module* Target, const std::string& rx) : Request(Me, Target, "REGEX"), regex(rx), result(NULL)
53         {
54         }
55
56         const std::string& GetRegex() const
57         {
58                 return regex;
59         }
60
61         Regex* Create()
62         {
63                 Send();
64                 return this->result;
65         }
66 };
67
68 class RegexNameRequest : public Request
69 {
70 public:
71         RegexNameRequest(Module* Me, Module* Target) : Request(Me, Target, "REGEX-NAME")
72         {
73         }
74 };
75
76 #endif