Sourcehighlight Library

Functionalities for detecting whether a line is in one of the stored line ranges (or in the context of a range). More...
#include <lineranges.h>
Public Types  
typedef int  RangeElemType 
typedef std::pair < RangeElemType, RangeElemType >  RangeType 
typedef std::set< RangeType >  LineRangeSet 
Public Member Functions  
LineRanges (unsigned int contextLines=0)  
RangeError  addRange (const std::string &range) 
Adds a range to the set. More...  
const LineRangeSet &  getLineRangeSet () const 
void  reset () 
The next isInRange search will start from the first element of the set. More...  
RangeResult  isInRange (const RangeElemType e) 
Checks whether the passed element is in a range of this set. More...  
void  setContextLines (unsigned int context) 
Private Attributes  
LineRangeSet  lineRangeSet 
bool  searchFromTheStart 
whether to perform the search from the first element of the set  
LineRangeSet::const_iterator  currentRange 
The current range for performing the search of isInRange.  
int  contextLines 
The number of lines making the context (i.e., the number of lines that are not part of a range but are in the specified line number context)  
Functionalities for detecting whether a line is in one of the stored line ranges (or in the context of a range).
This also performs some optimization: ranges are stored in a set in ascending order; if we have ranges, e.g., 120, 5070, 100200, and we check whether 23 is in range, we first check if it's in 120, then, since it's not there, we check whether it's in 5070; it is not, and since the range is 5070 it makes no sense searching for it in other ranges. The next search will start from range 5070, since we assume that line numbers are always increasing.
RangeError srchilite::LineRanges::addRange  (  const std::string &  range  ) 
Adds a range to the set.
The argument can be:
range  the string representing the range. 
RangeResult srchilite::LineRanges::isInRange  (  const RangeElemType  e  ) 
Checks whether the passed element is in a range of this set.
If it's not in the range it might be in the surrounding context.
e 

inline 
The next isInRange search will start from the first element of the set.
This should be called before searching for lines of a file, that we started to process.