Source-highlight Library
regexranges.h
1 /*
2  * regexranges.h
3  *
4  * Created on: Apr 11, 2009
5  * Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2008
6  * Copyright: See COPYING file that comes with this distribution
7  */
8 
9 #ifndef REGEXRANGES_H_
10 #define REGEXRANGES_H_
11 
12 #include <string>
13 #include <list>
14 #include <boost/regex.hpp>
15 
16 namespace srchilite {
17 
22 class RegexRanges {
23 public:
24  RegexRanges();
25  ~RegexRanges();
26 
27  typedef std::list<boost::regex> RegexRangesType;
28 
36  bool addRegexRange(const std::string &s);
37 
41  void clear() {
42  ranges.clear();
43  }
44 
51  const boost::regex *matches(const std::string &line);
52 
57  bool isInRange(const std::string &line);
58 
64  void reset() {
65  currentRegex = 0;
66  }
67 
68 private:
70  RegexRangesType ranges;
71 
79  const boost::regex *currentRegex;
80 };
81 
82 }
83 
84 #endif /* REGEXRANGES_H_ */
bool isInRange(const std::string &line)
Definition: regexranges.cpp:47
Stores possible separators implemented as regular expressions and provides functionalities to search ...
Definition: regexranges.h:22
bool addRegexRange(const std::string &s)
Adds a regular expression range, specified by the passed string.
Definition: regexranges.cpp:26
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13
RegexRangesType ranges
the actual collection of regular expressions for ranges
Definition: regexranges.h:70
void clear()
Removes all the added expressions.
Definition: regexranges.h:41
void reset()
The next isInRange search will start from the first element of the list.
Definition: regexranges.h:64
const boost::regex * currentRegex
if set, it represents the matched regular expression up to now.
Definition: regexranges.h:79
const boost::regex * matches(const std::string &line)
Checks whether one of the stored regular expression can be found in the passed string line...
Definition: regexranges.cpp:36