00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef LINERANGES_H_
00010 #define LINERANGES_H_
00011
00012 #include <set>
00013 #include <string>
00014
00015 namespace srchilite {
00016
00018 enum RangeError {
00019 NO_ERROR = 0, INVALID_RANGE_NUMBER
00020 };
00021
00023 enum RangeResult {
00024 NOT_IN_RANGE = 0, CONTEXT_RANGE, IN_RANGE
00025 };
00026
00038 class LineRanges {
00039 public:
00040 LineRanges(unsigned int contextLines = 0);
00041 ~LineRanges();
00042
00043 typedef int RangeElemType;
00044 typedef std::pair<RangeElemType, RangeElemType> RangeType;
00045
00046 typedef std::set<RangeType> LineRangeSet;
00047
00061 RangeError addRange(const std::string &first);
00062
00063 const LineRangeSet &getLineRangeSet() const {
00064 return lineRangeSet;
00065 }
00066
00072 void reset() {
00073 searchFromTheStart = true;
00074 }
00075
00083 RangeResult isInRange(const RangeElemType e);
00084
00085 void setContextLines(unsigned int context) {
00086 contextLines = context;
00087 }
00088
00089 private:
00090 LineRangeSet lineRangeSet;
00091
00095 bool searchFromTheStart;
00096
00100 LineRangeSet::const_iterator currentRange;
00101
00106 int contextLines;
00107 };
00108
00109 }
00110
00111 #endif