]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/modules/regex.h
Merge branch 'insp20' into master.
[user/henk/code/inspircd.git] / include / modules / regex.h
index 875f942bcbd27b0fcbb9d0c312d0fd24a2b7f6ed..5ef00cdd043806e178878c9f7fe47010db70eb76 100644 (file)
 class Regex : public classbase
 {
 protected:
-       std::string regex_string; // The raw uncompiled regex string.
+       /** The uncompiled regex string. */
+       std::string regex_string;
 
        // Constructor may as well be protected, as this class is abstract.
-       Regex(const std::string& rx) : regex_string(rx)
-       {
-       }
+       Regex(const std::string& rx) : regex_string(rx) { }
 
 public:
 
-       virtual ~Regex()
-       {
-       }
+       virtual ~Regex() { }
 
        virtual bool Matches(const std::string& text) = 0;
 
@@ -49,7 +46,17 @@ public:
 class RegexFactory : public DataProvider
 {
  public:
-       RegexFactory(Module* Creator, const std::string& Name) : DataProvider(Creator, Name) {}
+       RegexFactory(Module* Creator, const std::string& Name) : DataProvider(Creator, Name) { }
 
        virtual Regex* Create(const std::string& expr) = 0;
 };
+
+class RegexException : public ModuleException
+{
+ public:
+        RegexException(const std::string& regex, const std::string& error)
+                : ModuleException("Error in regex '" + regex + "': " + error) { }
+
+        RegexException(const std::string& regex, const std::string& error, int offset)
+                : ModuleException("Error in regex '" + regex + "' at offset " + ConvToStr(offset) + ": " + error) { }
+};