The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

m_regex.h

Go to the documentation of this file.
00001 /*       +------------------------------------+
00002  *       | Inspire Internet Relay Chat Daemon |
00003  *       +------------------------------------+
00004  *
00005  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
00006  * See: http://www.inspircd.org/wiki/index.php/Credits
00007  *
00008  * This program is free but copyrighted software; see
00009  *          the file COPYING for details.
00010  *
00011  * ---------------------------------------------------
00012  */
00013 
00014 #ifndef _M_REGEX_H
00015 #define _M_REGEX_H
00016 
00017 #include "inspircd.h"
00018 
00019 class Regex : public classbase
00020 {
00021 protected:
00022         std::string regex_string; // The raw uncompiled regex string.
00023         InspIRCd* ServerInstance;
00024 
00025         // Constructor may as well be protected, as this class is abstract.
00026         Regex(const std::string& rx, InspIRCd* Me) : regex_string(rx), ServerInstance(Me)
00027         {
00028         }
00029 
00030 public:
00031 
00032         virtual ~Regex()
00033         {
00034         }
00035 
00036         virtual bool Matches(const std::string& text) = 0;
00037 
00038         const std::string& GetRegexString() const
00039         {
00040                 return regex_string;
00041         }
00042 };
00043 
00044 class RegexFactoryRequest : public Request
00045 {
00046 private:
00047         std::string regex;
00048         
00049 public:
00050         Regex* result;
00051 
00052         RegexFactoryRequest(Module* Me, Module* Target, const std::string& rx) : Request(Me, Target, "REGEX"), regex(rx), result(NULL)
00053         {
00054         }
00055 
00056         const std::string& GetRegex() const
00057         {
00058                 return regex;
00059         }
00060 
00061         Regex* Create()
00062         {
00063                 Send();
00064                 return this->result;
00065         }
00066 };
00067 
00068 class RegexNameRequest : public Request
00069 {
00070 public:
00071         RegexNameRequest(Module* Me, Module* Target) : Request(Me, Target, "REGEX-NAME")
00072         {
00073         }
00074 };
00075 
00076 #endif