2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013 Peter Powell <petpow@saberuk.com>
5 * Copyright (C) 2012 ChrisTX <chris@rev-crew.info>
7 * This file is part of InspIRCd. InspIRCd is free software: you can
8 * redistribute it and/or modify it under the terms of the GNU General Public
9 * License as published by the Free Software Foundation, version 2.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 /// $CompilerFlags: find_compiler_flags("re2" "")
21 /// $LinkerFlags: find_linker_flags("re2" "-lre2")
23 /// $PackageInfo: require_system("darwin") pkg-config re2
24 /// $PackageInfo: require_system("ubuntu" "15.10") libre2-dev pkg-config
28 #include "modules/regex.h"
30 // Fix warnings about the use of `long long` on C++03 and
33 # pragma clang diagnostic ignored "-Wc++11-long-long"
34 #elif defined __GNUC__
35 # pragma GCC diagnostic ignored "-Wlong-long"
36 # pragma GCC diagnostic ignored "-Wshadow"
41 class RE2Regex : public Regex
46 RE2Regex(const std::string& rx) : Regex(rx), regexcl(rx, RE2::Quiet)
50 throw RegexException(rx, regexcl.error());
54 bool Matches(const std::string& text) CXX11_OVERRIDE
56 return RE2::FullMatch(text, regexcl);
60 class RE2Factory : public RegexFactory
63 RE2Factory(Module* m) : RegexFactory(m, "regex/re2") { }
64 Regex* Create(const std::string& expr) CXX11_OVERRIDE
66 return new RE2Regex(expr);
70 class ModuleRegexRE2 : public Module
75 ModuleRegexRE2() : ref(this)
79 Version GetVersion() CXX11_OVERRIDE
81 return Version("Regex Provider Module for RE2", VF_VENDOR);
85 MODULE_INIT(ModuleRegexRE2)