2008-09-05 17:37:02 +00:00
|
|
|
/* +------------------------------------+
|
|
|
|
* | Inspire Internet Relay Chat Daemon |
|
|
|
|
* +------------------------------------+
|
|
|
|
*
|
2009-01-02 18:16:05 +00:00
|
|
|
* InspIRCd: (C) 2002-2009 InspIRCd Development Team
|
2008-09-05 17:37:02 +00:00
|
|
|
* See: http://www.inspircd.org/wiki/index.php/Credits
|
|
|
|
*
|
|
|
|
* This program is free but copyrighted software; see
|
|
|
|
* the file COPYING for details.
|
|
|
|
*
|
|
|
|
* ---------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2008-09-05 19:33:49 +00:00
|
|
|
#ifndef _M_REGEX_H
|
|
|
|
#define _M_REGEX_H
|
2008-09-05 17:37:02 +00:00
|
|
|
|
|
|
|
#include "inspircd.h"
|
|
|
|
|
|
|
|
class Regex : public classbase
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
std::string regex_string; // The raw uncompiled regex string.
|
|
|
|
InspIRCd* ServerInstance;
|
|
|
|
|
|
|
|
// Constructor may as well be protected, as this class is abstract.
|
|
|
|
Regex(const std::string& rx, InspIRCd* Me) : regex_string(rx), ServerInstance(Me)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
virtual ~Regex()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool Matches(const std::string& text) = 0;
|
2008-09-05 18:58:55 +00:00
|
|
|
|
|
|
|
const std::string& GetRegexString() const
|
|
|
|
{
|
|
|
|
return regex_string;
|
|
|
|
}
|
2008-09-05 17:37:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class RegexFactoryRequest : public Request
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::string regex;
|
2008-09-05 18:53:07 +00:00
|
|
|
|
2008-09-05 17:37:02 +00:00
|
|
|
public:
|
2008-09-05 18:53:07 +00:00
|
|
|
Regex* result;
|
|
|
|
|
2008-09-06 03:52:34 +00:00
|
|
|
RegexFactoryRequest(Module* Me, Module* Target, const std::string& rx) : Request(Me, Target, "REGEX"), regex(rx), result(NULL)
|
2008-09-05 17:37:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& GetRegex() const
|
|
|
|
{
|
|
|
|
return regex;
|
|
|
|
}
|
2008-09-05 18:53:07 +00:00
|
|
|
|
|
|
|
Regex* Create()
|
|
|
|
{
|
|
|
|
Send();
|
|
|
|
return this->result;
|
|
|
|
}
|
2008-09-05 17:37:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class RegexNameRequest : public Request
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RegexNameRequest(Module* Me, Module* Target) : Request(Me, Target, "REGEX-NAME")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|