2012-04-19 20:58:29 +02:00
|
|
|
/*
|
|
|
|
* InspIRCd -- Internet Relay Chat Daemon
|
2008-09-05 17:37:02 +00:00
|
|
|
*
|
2012-04-19 20:58:29 +02:00
|
|
|
* Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
|
|
|
|
* Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
|
2008-09-05 17:37:02 +00:00
|
|
|
*
|
2012-04-19 20:58:29 +02:00
|
|
|
* This file is part of InspIRCd. InspIRCd is free software: you can
|
|
|
|
* redistribute it and/or modify it under the terms of the GNU General Public
|
|
|
|
* License as published by the Free Software Foundation, version 2.
|
2008-09-05 17:37:02 +00:00
|
|
|
*
|
2012-04-19 20:58:29 +02:00
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-09-05 17:37:02 +00:00
|
|
|
*/
|
|
|
|
|
2012-04-19 20:58:29 +02:00
|
|
|
|
2012-04-14 18:03:25 -07: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.
|
|
|
|
|
|
|
|
// Constructor may as well be protected, as this class is abstract.
|
2009-09-26 14:13:13 +00:00
|
|
|
Regex(const std::string& rx) : regex_string(rx)
|
2008-09-05 17:37:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2009-11-16 17:59:06 +00:00
|
|
|
class RegexFactory : public DataProvider
|
2008-09-05 17:37:02 +00:00
|
|
|
{
|
2009-11-16 17:59:06 +00:00
|
|
|
public:
|
|
|
|
RegexFactory(Module* Creator, const std::string& Name) : DataProvider(Creator, Name) {}
|
2009-02-14 21:14:36 +00:00
|
|
|
|
2009-11-16 17:59:06 +00:00
|
|
|
virtual Regex* Create(const std::string& expr) = 0;
|
2008-09-05 17:37:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|