]> git.tdb.fi Git - libs/core.git/blob - source/strings/regmatch.cpp
Have get_user_data_dir return a proper location on Android
[libs/core.git] / source / strings / regmatch.cpp
1 #include <stdexcept>
2 #include "regmatch.h"
3
4 using namespace std;
5
6 namespace Msp {
7
8 RegMatch::RegMatch(const string &str, const GroupArray &g):
9         groups(g)
10 {
11         for(GroupArray::iterator i=groups.begin(); i!=groups.end(); ++i)
12                 if(i->match)
13                 {
14                         i->length = i->end-i->begin;
15                         i->str = str.substr(i->begin, i->length);
16                 }
17 }
18
19 const RegMatch::Group &RegMatch::group(unsigned i) const
20 {
21         if(i>=groups.size())
22                 throw out_of_range("RegMatch::group");
23         return groups[i];
24 }
25
26 } // namespace Msp