7 #ifndef HIGHLIGHTSTATE_H_
8 #define HIGHLIGHTSTATE_H_
13 #include <boost/shared_ptr.hpp>
18 struct HighlightToken;
52 const unsigned int id;
88 void addRule(HighlightRulePtr rule);
97 HighlightRulePtr
replaceRule(RuleList::size_type index,
98 HighlightRulePtr rule);
100 unsigned int getId()
const {
103 const RuleList &getRuleList()
const {
107 const std::string &getDefaultElement()
const {
110 void setDefaultElement(
const std::string &e) {
122 bool findBestMatch(
const std::string &s, HighlightToken &token,
123 const MatchingParameters ¶ms)
const;
135 std::string::const_iterator end, HighlightToken &token,
136 const MatchingParameters ¶ms)
const;
146 static bool betterThan(
const HighlightToken &t1,
const HighlightToken &t2);
157 bool getNeedsReferenceReplacement()
const {
161 void setNeedsReferenceReplacement(
bool b =
true) {
162 needsReferenceReplacement = b;
165 HighlightStatePtr getOriginalState()
const {
169 void setOriginalState(HighlightStatePtr orig) {
170 originalState = orig;
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...
static unsigned int global_id
the global counter to assign unique state ids
Definition: highlightstate.h:49
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
Structure for passing parameters to the matching algorithm, for instance, "not beginning of line"...
Definition: matchingparameters.h:16
Represents a state during the highlighting (e.g., comment state, string state, etc.)
Definition: highlightstate.h:47
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13
RuleList ruleList
the list of rules of this state
Definition: highlightstate.h:60
boost::shared_ptr< HighlightRule > HighlightRulePtr
Shared pointer for HighlightRule.
Definition: highlightstate.h:19
HighlightRulePtr replaceRule(RuleList::size_type index, HighlightRulePtr rule)
Substitutes the rule at the specified position.
std::deque< HighlightRulePtr > RuleList
List of rules.
Definition: highlightstate.h:32
HighlightStatePtr originalState
In case this state is a copy of another state, in this field we store the original state...
Definition: highlightstate.h:69
boost::shared_ptr< HighlightState > HighlightStatePtr
the reference to an HighlightState
Definition: highlightstate.h:38
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
bool needsReferenceReplacement
whether one of the contained rules has dynamic references to be replaced
Definition: highlightstate.h:63
HighlightState(const std::string &e="normal")
const unsigned int id
the identifier of the state
Definition: highlightstate.h:52
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...
void addRule(HighlightRulePtr rule)
Adss a rule to this state.
void replaceReferences(const ReplacementList &rep)
Performs replacement of references in the rules of this state.