8 #ifndef BOOSTER_REGEX_MATCH_H 9 #define BOOSTER_REGEX_MATCH_H 24 template<
typename Iterator>
25 class sub_match :
public std::pair<Iterator,Iterator> {
27 typedef Iterator iterator;
28 typedef typename std::iterator_traits<Iterator>::value_type value_type;
29 typedef typename std::iterator_traits<Iterator>::difference_type difference_type;
35 typedef std::pair<Iterator,Iterator> pair_type;
49 return std::distance(pair_type::first,pair_type::second);
64 string_type
str()
const 67 return string_type(pair_type::first,pair_type::second);
77 return str().compare(other.
str());
82 int compare(string_type
const &other)
const 84 return str().compare(other);
91 return str().compare(s);
109 template<
typename Iterator>
131 if(n < 0 || n >=
int(offsets_.size()))
133 if(offsets_[n].first == -1)
138 std::advance(r.first,offsets_[n].first);
139 std::advance(r.second,offsets_[n].second);
148 return offsets_.size();
161 std::advance(r.first,offsets_.back().second);
162 r.
matched = r.first != r.second;
172 if(offsets_.empty() || offsets_[0].first == 0)
177 std::advance(r.second,offsets_[0].first);
183 void assign(Iterator begin,Iterator end,std::vector<std::pair<int,int> > &offsets)
187 offsets_.swap(offsets);
193 Iterator begin_,end_;
194 std::vector<std::pair<int,int> > offsets_;
204 template<
typename Regex>
205 bool regex_match(
char const *begin,
char const *end,cmatch &m, Regex
const &r,
int flags = 0)
207 std::vector<std::pair<int,int> > map;
208 bool res = r.match(begin,end,map,flags);
209 if(!res)
return false;
210 m.assign(begin,end,map);
218 template<
typename Regex>
219 bool regex_match(std::string
const &s,smatch &m, Regex
const &r,
int flags = 0)
221 std::vector<std::pair<int,int> > map;
222 bool res = r.match(s.c_str(),s.c_str()+s.size(),map,flags);
223 if(!res)
return false;
224 m.assign(s.begin(),s.end(),map);
232 template<
typename Regex>
233 bool regex_match(
char const *s,cmatch &m, Regex
const &r,
int flags = 0)
235 std::vector<std::pair<int,int> > map;
237 char const *end = begin+strlen(begin);
238 bool res = r.match(begin,end,map,flags);
239 if(!res)
return false;
240 m.assign(begin,end,map);
248 template<
typename Regex>
249 bool regex_search(
char const *begin,
char const *end,cmatch &m, Regex
const &r,
int flags = 0)
251 std::vector<std::pair<int,int> > map;
252 bool res = r.search(begin,end,map,flags);
253 if(!res)
return false;
254 m.assign(begin,end,map);
262 template<
typename Regex>
263 bool regex_search(std::string
const &s,smatch &m, Regex
const &r,
int flags = 0)
265 std::vector<std::pair<int,int> > map;
266 bool res = r.search(s.c_str(),s.c_str()+s.size(),map,flags);
267 if(!res)
return false;
268 m.assign(s.begin(),s.end(),map);
277 template<
typename Regex>
278 bool regex_search(
char const *s,cmatch &m, Regex
const &r,
int flags = 0)
280 std::vector<std::pair<int,int> > map;
282 char const *end = begin+strlen(begin);
283 bool res = r.search(begin,end,map,flags);
284 if(!res)
return false;
285 m.assign(begin,end,map);
292 template<
typename Regex>
293 bool regex_match(
char const *begin,
char const *end, Regex
const &r,
int flags = 0)
295 return r.match(begin,end,flags);
301 template<
typename Regex>
302 bool regex_match(std::string
const &s, Regex
const &r,
int flags = 0)
304 return r.match(s.c_str(),s.c_str()+s.size(),flags);
310 template<
typename Regex>
313 return r.match(s,s+strlen(s),flags);
319 template<
typename Regex>
320 bool regex_search(
char const *begin,
char const *end, Regex
const &r,
int flags = 0)
322 return r.search(begin,end,flags);
328 template<
typename Regex>
331 return r.search(s.c_str(),s.c_str()+s.size(),flags);
337 template<
typename Regex>
340 return r.search(s,s+strlen(s),flags);
345 template<
typename Iterator>
347 template<
typename Iterator>
349 template<
typename Iterator>
351 template<
typename Iterator>
353 template<
typename Iterator>
355 template<
typename Iterator>
359 template<
typename Iterator>
364 template<
typename Iterator>
370 template<
typename Iterator>
375 template<
typename Iterator>
381 template<
typename Iterator>
386 template<
typename Iterator>
394 template<
typename Iterator>
400 template<
typename Iterator>
407 template<
typename Iterator>
414 template<
typename Iterator>
421 template<
typename Iterator>
428 template<
typename Iterator>
436 template<
typename Iterator>
438 typename std::iterator_traits<Iterator>::value_type
const *l,
441 template<
typename Iterator>
443 typename std::iterator_traits<Iterator>::value_type
const *l,
448 template<
typename Iterator>
450 typename std::iterator_traits<Iterator>::value_type
const *l,
453 template<
typename Iterator>
455 typename std::iterator_traits<Iterator>::value_type
const *l,
459 template<
typename Iterator>
461 typename std::iterator_traits<Iterator>::value_type
const *l,
464 template<
typename Iterator>
466 typename std::iterator_traits<Iterator>::value_type
const *l,
473 template<
typename Iterator>
476 typename std::iterator_traits<Iterator>::value_type
const *r
479 template<
typename Iterator>
482 typename std::iterator_traits<Iterator>::value_type
const *r
486 template<
typename Iterator>
489 typename std::iterator_traits<Iterator>::value_type
const *r
493 template<
typename Iterator>
496 typename std::iterator_traits<Iterator>::value_type
const *r
500 template<
typename Iterator>
503 typename std::iterator_traits<Iterator>::value_type
const *r
507 template<
typename Iterator>
510 typename std::iterator_traits<Iterator>::value_type
const *r
516 template<
typename Iterator>
519 {
return l.
str() + r.
str(); }
521 template<
typename Iterator>
524 {
return l.
str() + r; }
526 template<
typename Iterator>
529 {
return l + r.
str(); }
531 template<
typename Iterator>
534 {
return l.
str() + r; }
536 template<
typename Iterator>
539 {
return l + r.
str(); }
sub_match()
Definition: regex_match.h:96
The object that hold the result of matching a regular expression against the text using regex_match a...
Definition: regex_match.h:110
value_type prefix()
Definition: regex_match.h:169
bool regex_search(char const *begin, char const *end, cmatch &m, Regex const &r, int flags=0)
Definition: regex_match.h:249
value_type operator[](int n) const
Definition: regex_match.h:128
int compare(string_type const &other) const
Definition: regex_match.h:82
match_results()
Definition: regex_match.h:115
bool matched
Definition: regex_match.h:41
std::basic_string< value_type > string_type
Definition: regex_match.h:34
bool regex_match(char const *begin, char const *end, cmatch &m, Regex const &r, int flags=0)
Definition: regex_match.h:205
sub_match< Iterator > value_type
Definition: regex_match.h:123
This class represents a single captures subexpression.
Definition: regex_match.h:25
int compare(sub_match const &other) const
Definition: regex_match.h:75
int compare(value_type const *s) const
Definition: regex_match.h:89
size_t size() const
Definition: regex_match.h:146
difference_type length() const
Definition: regex_match.h:46
Booster library namespace. The library that implements Boost Like API in ABI backward compatible way...
Definition: application.h:23
value_type suffix()
Definition: regex_match.h:154
string_type str() const
Definition: regex_match.h:64