]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/extra/m_regex.h
cffb94cbd2ded43d8ece04fb07e9abf2f10ab50e
[user/henk/code/inspircd.git] / src / modules / extra / m_regex.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *          the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #ifndef _REGEX_H
15 #define _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
39 class RegexFactoryRequest : public Request
40 {
41 private:
42         std::string regex;
43         
44 public:
45         Regex* result;
46
47         RegexFactoryRequest(Module* Me, Module* Target, const std::string& rx) : Request(Me, Target, "REGEX"), regex(rx)
48         {
49         }
50
51         const std::string& GetRegex() const
52         {
53                 return regex;
54         }
55
56         Regex* Create()
57         {
58                 Send();
59                 return this->result;
60         }
61 };
62
63 class RegexNameRequest : public Request
64 {
65 public:
66         RegexNameRequest(Module* Me, Module* Target) : Request(Me, Target, "REGEX-NAME")
67         {
68         }
69 };
70
71 #endif