7#ifndef HIGHLIGHTSTATE_H_
8#define HIGHLIGHTSTATE_H_
13#include <boost/shared_ptr.hpp>
19struct MatchingParameters;
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) {
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) {
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.
Definition: highlightstate.cpp:32
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
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.
Definition: highlightstate.cpp:36
void replaceReferences(const ReplacementList &rep)
Performs replacement of references in the rules of this state.
Definition: highlightstate.cpp:94
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
static unsigned int global_id
the global counter to assign unique state ids
Definition: highlightstate.h:49
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...
Definition: highlightstate.cpp:43
HighlightState(const std::string &e="normal")
Definition: highlightstate.cpp:20
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...
Definition: highlightstate.cpp:89
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13
boost::shared_ptr< HighlightRule > HighlightRulePtr
Shared pointer for HighlightRule.
Definition: highlightstate.h:19
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:38