-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptparser.cpp
More file actions
41 lines (38 loc) · 968 Bytes
/
optparser.cpp
File metadata and controls
41 lines (38 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "optparser.h"
using namespace std;
match_results<const char*> OPTPARSER::g_walk_step(const string& regexString, optlist &args)
{
if(args.empty())
{
return(match_results<const char*>());
}
#ifndef NDEBUG
std::cerr << "Regex will be \'"<<regexString<<"\'\n";
#endif
regex blowarg(regexString);
auto i=args.end();
do
{
--i;
#ifndef NDEBUG
std::cerr << "\tParsing an argument \'"<<*i<<'\'';
#endif
match_results<const char*> matches;
if(regex_search(*i,matches,blowarg))
{
#ifndef NDEBUG
std::cerr << " matches to regex.\n";
#endif
args.erase(i);
return(matches);
}
else
{
#ifndef NDEBUG
std::cerr << " not matches to regex.\n";
#endif
}
}
while(i!=args.begin());
return(match_results<const char*>());
}