/* $CompileFlags: pkgconfincludes("tre","tre/regex.h","") */
/* $LinkerFlags: pkgconflibs("tre","/libtre.so","-ltre") rpath("pkg-config --libs tre") */
-/* $ModDep: modules/regex.h */
-
-class TRERegexException : public ModuleException
-{
- public:
- TRERegexException(const std::string& rx, const std::string& error)
- : ModuleException("Error in regex " + rx + ": " + error)
- {
- }
-};
class TRERegex : public Regex
{
error = errbuf;
delete[] errbuf;
regfree(®buf);
- throw TRERegexException(rx, error);
+ throw RegexException(rx, error);
}
}
regfree(®buf);
}
- bool Matches(const std::string& text)
+ bool Matches(const std::string& text) CXX11_OVERRIDE
{
- if (regexec(®buf, text.c_str(), 0, NULL, 0) == 0)
- {
- // Bang. :D
- return true;
- }
- return false;
+ return (regexec(®buf, text.c_str(), 0, NULL, 0) == 0);
}
};
{
public:
TREFactory(Module* m) : RegexFactory(m, "regex/tre") {}
- Regex* Create(const std::string& expr)
+ Regex* Create(const std::string& expr) CXX11_OVERRIDE
{
return new TRERegex(expr);
}
public:
ModuleRegexTRE() : trf(this)
{
- ServerInstance->Modules->AddService(trf);
}
Version GetVersion() CXX11_OVERRIDE