Source-highlight Library
Public Member Functions | Private Attributes | List of all members
srchilite::HighlightRule Class Referenceabstract

Base class for highlight rules. More...

#include <highlightrule.h>

Inheritance diagram for srchilite::HighlightRule:
Inheritance graph
[legend]
Collaboration diagram for srchilite::HighlightRule:
Collaboration graph
[legend]

Public Member Functions

  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) More...
 
virtual bool  tryToMatch (const std::string &s, HighlightToken &token, const MatchingParameters &params)
  Try to match this rule against the passed string (implemented by calling the pure virtual function tryToMatch below). More...
 
virtual bool  tryToMatch (std::string::const_iterator start, std::string::const_iterator end, HighlightToken &token, const MatchingParameters &params)=0
  Try to match this rule against the passed string. More...
 
virtual const std::string  toString () const =0
 
virtual void  replaceReferences (const ReplacementList &rep)=0
  Performs replacement of references in this rule. More...
 
virtual HighlightRuleclone ()=0
 
const HighlightStatePtr  getNextState () const
 
void  setNextState (HighlightStatePtr _nextState)
 
void  addElem (const std::string &name)
  Adds an element name to the list of this rule. More...
 
const ElemListgetElemList () const
 
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
 
std::string  additionalInfo
  additional information about this rule
 
int  exitLevel
  how many state must we exit if we match this rule: 0: none, -1: all, otherwise the number of states to exit
 
bool  nested
  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 HighlightRule* srchilite::HighlightRule::clone ( )
pure virtual
Returns
a copy of this rule.

Implemented in srchilite::RegexHighlightRule.

virtual void srchilite::HighlightRule::replaceReferences ( const ReplacementListrep )
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,
HighlightTokentoken,
const MatchingParametersparams 
)
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,
HighlightTokentoken,
const MatchingParametersparams 
)
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

AltStyle によって変換されたページ (->オリジナル) /