]> git.tdb.fi Git - libs/core.git/blobdiff - source/strings/regmatch.cpp
Use C++11 features with containers
[libs/core.git] / source / strings / regmatch.cpp
index 61bed84d459f01f4343f75362a5b488ec1bd0334..0e702b5e9568c5a3e5a2dd9a3fc6b49dce1d402a 100644 (file)
@@ -1,25 +1,25 @@
-#include <msp/core/except.h>
+#include <stdexcept>
 #include "regmatch.h"
 
 using namespace std;
 
 namespace Msp {
 
-RegMatch::RegMatch(const string &str, const GroupArray &g):
-       groups(g)
+RegMatch::RegMatch(const string &str, const vector<Group> &grps):
+       groups(grps)
 {
-       for(GroupArray::iterator i=groups.begin(); i!=groups.end(); ++i)
-               if(i->match)
+       for(Group &g: groups)
+               if(g.match)
                {
-                       i->length = i->end-i->begin;
-                       i->str = str.substr(i->begin, i->length);
+                       g.length = g.end-g.begin;
+                       g.str = str.substr(g.begin, g.length);
                }
 }
 
 const RegMatch::Group &RegMatch::group(unsigned i) const
 {
        if(i>=groups.size())
-               throw InvalidParameterValue("Group index out of range");
+               throw out_of_range("RegMatch::group");
        return groups[i];
 }