]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_regex.h
969c4920bc1e328ed29b21b5e71f3b972154a7fc
[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
24         // Constructor may as well be protected, as this class is abstract.
25         Regex(const std::string& rx) : regex_string(rx)
26         {
27         }
28
29 public:
30
31         virtual ~Regex()
32         {
33         }
34
35         virtual bool Matches(const std::string& text) = 0;
36
37         const std::string& GetRegexString() const
38         {
39                 return regex_string;
40         }
41 };
42
43 class RegexFactoryRequest : public Request
44 {
45 private:
46         std::string regex;
47
48 public:
49         Regex* result;
50
51         RegexFactoryRequest(Module* Me, Module* Target, const std::string& rx) : Request(Me, Target, "REGEX"), regex(rx), result(NULL)
52         {
53         }
54
55         const std::string& GetRegex() const
56         {
57                 return regex;
58         }
59
60         Regex* Create()
61         {
62                 Send();
63                 return this->result;
64         }
65 };
66
67 class RegexNameRequest : public Request
68 {
69 public:
70         std::string result;
71         RegexNameRequest(Module* Me, Module* Target) : Request(Me, Target, "REGEX-NAME")
72         {
73                 Send(); 
74         }
75 };
76
77 #endif