]> git.tdb.fi Git - libs/core.git/blobdiff - source/strings/regex.h
Mark overridden virtual functions as such
[libs/core.git] / source / strings / regex.h
index 5b809ab3c363415382a66bbbcf855140a47c5329..bef5231e4b8a3cc3e1337da11ad682c94b9653db 100644 (file)
@@ -1,11 +1,23 @@
 #ifndef MSP_STRINGS_REGEX_H_
 #define MSP_STRINGS_REGEX_H_
 
+#include <stdexcept>
 #include <string>
 #include "regmatch.h"
 
 namespace Msp {
 
+class bad_regex: public std::logic_error
+{
+public:
+       bad_regex(const std::string &, const std::string &, const std::string::const_iterator &);
+       ~bad_regex() throw() override = default;
+
+private:
+       std::string make_where(const std::string &, const std::string::const_iterator &);
+};
+
+
 /**
 This class provides regular expression matching.  It supports a subset of
 POSIX.2 extended regex syntax.  Character classes, equivalence classes and
@@ -91,11 +103,11 @@ private:
        struct RunContext
        {
                Code::const_iterator citer;
-               RegMatch::GroupArray groups;
+               std::vector<RegMatch::Group> groups;
        };
 
        Code code;
-       unsigned n_groups;
+       unsigned n_groups = 0;
 
 public:
        /** Constructs a new Regex object from a string representation. */
@@ -108,7 +120,7 @@ private:
 
        Code parse_atom(const std::string &, std::string::const_iterator &i, unsigned &);
        Code parse_brackets(const std::string &, std::string::const_iterator &);
-       bool parse_repeat(std::string::const_iterator &, Count &, Count &);
+       bool parse_repeat(const std::string &, std::string::const_iterator &, Count &, Count &);
 
 public:
        /** Matches the regex against a string.  Refer to RegMatch documentation for
@@ -116,7 +128,7 @@ public:
        RegMatch match(const std::string &str) const;
 
 private:
-       bool run(const std::string &, const std::string::const_iterator &, RegMatch::GroupArray &) const;
+       bool run(const std::string &, const std::string::const_iterator &, std::vector<RegMatch::Group> &) const;
        bool group_compare(const RegMatch::Group &, const RegMatch::Group &) const;
 
 public: