]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix various small issues.
authorPeter Powell <petpow@saberuk.com>
Tue, 27 Aug 2013 06:54:16 +0000 (07:54 +0100)
committerPeter Powell <petpow@saberuk.com>
Tue, 27 Aug 2013 11:20:03 +0000 (12:20 +0100)
- Add CXX11_OVERRIDE to *Regex::Matches and *RegexFactory::Create.
- Fix documentation comment on regex_string.
- Fix various code duplication/layout issues.

include/modules/regex.h
src/modules/extra/m_regex_pcre.cpp
src/modules/extra/m_regex_posix.cpp
src/modules/extra/m_regex_re2.cpp
src/modules/extra/m_regex_stdlib.cpp
src/modules/extra/m_regex_tre.cpp
src/modules/m_regex_glob.cpp

index e278df502134d7581f6965c5e688e7ddb5e4812b..0bced4e2b0986697c2acc6560c4d2380a7a50526 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,7 @@ 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;
 };
index 01cf4717824c3267a07bd4413f8d0f61fd8abb6f..91c2d1404d20a33c1c69cd1c5049f3eca1b7d004 100644 (file)
@@ -51,14 +51,9 @@ class PCRERegex : public Regex
                pcre_free(regex);
        }
 
-       bool Matches(const std::string& text)
+       bool Matches(const std::string& text) CXX11_OVERRIDE
        {
-               if (pcre_exec(regex, NULL, text.c_str(), text.length(), 0, 0, NULL, 0) > -1)
-               {
-                       // Bang. :D
-                       return true;
-               }
-               return false;
+               return (pcre_exec(regex, NULL, text.c_str(), text.length(), 0, 0, NULL, 0) >= 0);
        }
 };
 
@@ -66,7 +61,7 @@ class PCREFactory : public RegexFactory
 {
  public:
        PCREFactory(Module* m) : RegexFactory(m, "regex/pcre") {}
-       Regex* Create(const std::string& expr)
+       Regex* Create(const std::string& expr) CXX11_OVERRIDE
        {
                return new PCRERegex(expr);
        }
index 6c52a935b6724cb65738e6f05c77d86b2762cff8..935cdbf92907edf2c6ac2d8017e9d6317df47454 100644 (file)
@@ -54,14 +54,9 @@ class POSIXRegex : public Regex
                regfree(&regbuf);
        }
 
-       bool Matches(const std::string& text)
+       bool Matches(const std::string& text) CXX11_OVERRIDE
        {
-               if (regexec(&regbuf, text.c_str(), 0, NULL, 0) == 0)
-               {
-                       // Bang. :D
-                       return true;
-               }
-               return false;
+               return (regexec(&regbuf, text.c_str(), 0, NULL, 0) == 0);
        }
 };
 
@@ -70,7 +65,7 @@ class PosixFactory : public RegexFactory
  public:
        bool extended;
        PosixFactory(Module* m) : RegexFactory(m, "regex/posix") {}
-       Regex* Create(const std::string& expr)
+       Regex* Create(const std::string& expr) CXX11_OVERRIDE
        {
                return new POSIXRegex(expr, extended);
        }
index b97b7ec0fb37b6ebe4ff3825a888597223b7350d..2525b70abba9f2c98a4d0bc0944066682717b111 100644 (file)
@@ -43,7 +43,7 @@ class RE2Regex : public Regex
                }
        }
 
-       bool Matches(const std::string& text)
+       bool Matches(const std::string& text) CXX11_OVERRIDE
        {
                return RE2::FullMatch(text, regexcl);
        }
@@ -53,7 +53,7 @@ class RE2Factory : public RegexFactory
 {
  public:
        RE2Factory(Module* m) : RegexFactory(m, "regex/re2") { }
-       Regex* Create(const std::string& expr)
+       Regex* Create(const std::string& expr) CXX11_OVERRIDE
        {
                return new RE2Regex(expr);
        }
index 2fa1ae0906d057dbc5910f3fc8e6c0d6022990d2..5ec358d58fffb5da8517476450a30c6254cafd8a 100644 (file)
@@ -38,7 +38,7 @@ class StdRegex : public Regex
                }
        }
 
-       bool Matches(const std::string& text)
+       bool Matches(const std::string& text) CXX11_OVERRIDE
        {
                return std::regex_search(text, regexcl);
        }
@@ -49,7 +49,7 @@ class StdRegexFactory : public RegexFactory
  public:
        std::regex::flag_type regextype;
        StdRegexFactory(Module* m) : RegexFactory(m, "regex/stdregex") {}
-       Regex* Create(const std::string& expr)
+       Regex* Create(const std::string& expr) CXX11_OVERRIDE
        {
                return new StdRegex(expr, regextype);
        }
index c845ab37414991d44e909a67bd734772b65879c9..92f2ad9900d93db92ead68be161c48128a3c92d7 100644 (file)
@@ -57,14 +57,9 @@ public:
                regfree(&regbuf);
        }
 
-       bool Matches(const std::string& text)
+       bool Matches(const std::string& text)  CXX11_OVERRIDE
        {
-               if (regexec(&regbuf, text.c_str(), 0, NULL, 0) == 0)
-               {
-                       // Bang. :D
-                       return true;
-               }
-               return false;
+               return (regexec(&regbuf, text.c_str(), 0, NULL, 0) == 0);
        }
 };
 
@@ -72,7 +67,7 @@ class TREFactory : public RegexFactory
 {
  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);
        }
index 887b1cd796dc09c8d3cda56268ff9f6cc055e492..eb7cf4ece5d383032ee0d9d4d8cf996014305fbc 100644 (file)
@@ -28,7 +28,7 @@ public:
        {
        }
 
-       bool Matches(const std::string& text)
+       bool Matches(const std::string& text) CXX11_OVERRIDE
        {
                return InspIRCd::Match(text, this->regex_string);
        }
@@ -37,7 +37,7 @@ public:
 class GlobFactory : public RegexFactory
 {
  public:
-       Regex* Create(const std::string& expr)
+       Regex* Create(const std::string& expr) CXX11_OVERRIDE
        {
                return new GlobRegex(expr);
        }