7#ifndef HIGHLIGHTSTATE_H_
8#define HIGHLIGHTSTATE_H_
13#include <boost/shared_ptr.hpp>
52 const unsigned int id;
100 unsigned int getId()
const {
103 const RuleList &getRuleList()
const {
107 const std::string &getDefaultElement()
const {
110 void setDefaultElement(
const std::string &e) {
157 bool getNeedsReferenceReplacement()
const {
161 void setNeedsReferenceReplacement(
bool b =
true) {
Base class for highlight rules.
Definition highlightrule.h:27
Represents a state during the highlighting (e.g., comment state, string state, etc....
Definition highlightstate.h:47
void addRule(HighlightRulePtr rule)
Adss a rule to this state.
bool findBestMatch(std::string::const_iterator start, std::string::const_iterator end, HighlightToken &token, const MatchingParameters ¶ms) const
Tries to find the rule that matches best (and first): the first rule with the smallest prefix and lon...
const unsigned int id
the identifier of the state
Definition highlightstate.h:52
RuleList ruleList
the list of rules of this state
Definition highlightstate.h:60
static bool betterThan(const HighlightToken &t1, const HighlightToken &t2)
Whether t1 is better than t2: t1 has a non-longer prefix and a longer matching string (this makes sen...
bool needsReferenceReplacement
whether one of the contained rules has dynamic references to be replaced
Definition highlightstate.h:63
HighlightStatePtr originalState
In case this state is a copy of another state, in this field we store the original state.
Definition highlightstate.h:69
HighlightRulePtr replaceRule(RuleList::size_type index, HighlightRulePtr rule)
Substitutes the rule at the specified position.
void replaceReferences(const ReplacementList &rep)
Performs replacement of references in the rules of this state.
std::string defaultElement
the name of the element for strings when no rule matches (default: "normal") for states this should a...
Definition highlightstate.h:57
HighlightState(const HighlightState ©)
Copies all the elements of the highlight state, except for the id: a new id will be used.
static unsigned int global_id
the global counter to assign unique state ids
Definition highlightstate.h:49
HighlightState(const std::string &e="normal")
bool findBestMatch(const std::string &s, HighlightToken &token, const MatchingParameters ¶ms) const
Tries to find the rule that matches best (and first): the first rule with the smallest prefix and lon...
C++ class: doctemplate.h.
Definition bufferedoutput.cpp:13
boost::shared_ptr< HighlightRule > HighlightRulePtr
Shared pointer for HighlightRule.
Definition highlightstate.h:29
std::vector< std::string > ReplacementList
the values for replacing references (it should contain 9 possibly empty elements, because 9 is usuall...
Definition highlightstate.h:36
std::deque< HighlightRulePtr > RuleList
List of rules.
Definition highlightstate.h:32
boost::shared_ptr< HighlightState > HighlightStatePtr
the reference to an HighlightState
Definition highlightstate.h:41
Token containing information for performing the highlight.
Definition highlighttoken.h:33
Structure for passing parameters to the matching algorithm, for instance, "not beginning of line",...
Definition matchingparameters.h:16