Base class for highlight rules.
More...
#include <highlightrule.h>
Inheritance diagram for srchilite::HighlightRule:
Collaboration diagram for srchilite::HighlightRule:
Public Member Functions
Creates a rule for the given element (Although each rule can concern more than one program element, we provide only this convenience constructor with only one name: if the rule concerns more than one element one can use addElem method)
More...
Try to match this rule against the passed string (implemented by calling the pure virtual function tryToMatch below).
More...
Try to match this rule against the passed string.
More...
virtual const std::string toString () const =0
Performs replacement of references in this rule.
More...
void
addElem (const std::string &name)
Adds an element name to the list of this rule.
More...
int getExitLevel () const
void setExitLevel (int l)
bool isNested () const
void setNested (bool n)
bool getNeedsReferenceReplacement () const
void setNeedsReferenceReplacement (bool b=true)
bool getHasSubexpressions () const
void setHasSubexpressions (bool b=true)
std::string getAdditionalInfo () const
void setAdditionalInfo (const std::string &info)
Private Attributes
the list of program elements detected by this rule
if set, it represents the state to enter if this rule matches this class does not delete nextState
additional information about this rule
how many state must we exit if we match this rule: 0: none, -1: all, otherwise the number of states to exit
tells that if this rule matches we must enter the same state once again
whether this rule has dynamic references to be replaced
whether this rule can match subexpressions
Detailed Description
Base class for highlight rules.
This abstracts from the actual implementation for matching.
Constructor & Destructor Documentation
srchilite::HighlightRule::HighlightRule
(
const std::string &
name )
Creates a rule for the given element (Although each rule can concern more than one program element, we provide only this convenience constructor with only one name: if the rule concerns more than one element one can use addElem method)
- Parameters
-
name the element name of this rule
Member Function Documentation
void srchilite::HighlightRule::addElem
(
const std::string &
name )
Adds an element name to the list of this rule.
- Parameters
-
name the name to add
virtual void srchilite::HighlightRule::replaceReferences
(
const
ReplacementList &
rep )
pure virtual
Performs replacement of references in this rule.
- Parameters
-
the list of values for the replacement; the first element is the value for replacing the first dynamic back reference, and so on. (it should contain 9 possibly empty elements)
Implemented in srchilite::RegexHighlightRule.
bool srchilite::HighlightRule::tryToMatch
(
const std::string &
s,
)
virtual
Try to match this rule against the passed string (implemented by calling the pure virtual function tryToMatch below).
The passed token is assumed to be reset (i.e., no existing matching information is stored in it when passing it to this method).
- Parameters
-
s the string for trying to match the rule
token where results will be inserted, if the rule matched
params additional arguments for the matching
- Returns
- the result of this matching
virtual bool srchilite::HighlightRule::tryToMatch
(
std::string::const_iterator
start,
std::string::const_iterator
end,
)
pure virtual
Try to match this rule against the passed string.
- Parameters
-
start the beginning of the string for trying to match the rule
end the beginning of the string for trying to match the rule
token where results will be inserted, if the rule matched
params additional arguments for the matching
- Returns
- the result of this matching
Implemented in srchilite::RegexHighlightRule.
The documentation for this class was generated from the following files:
- /home/bettini/work/source-highlight/src-highlite/lib/srchilite/highlightrule.h
- /home/bettini/work/source-highlight/src-highlite/lib/srchilite/highlightrule.cpp