]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/extra/m_regex.h
Framework for central regex module, and a bare-bone implementation based on InspIRCd...
[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         RegexFactoryRequest(Module* Me, Module* Target, const std::string& rx) : Request(Me, Target, "REGEX"), regex(rx)
46         {
47         }
48
49         const std::string& GetRegex() const
50         {
51                 return regex;
52         }
53 };
54
55 class RegexNameRequest : public Request
56 {
57 public:
58         RegexNameRequest(Module* Me, Module* Target) : Request(Me, Target, "REGEX-NAME")
59         {
60         }
61 };
62
63 #endif