1 //
2 // Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2004-2008
3 //
4 // Copyright: See COPYING file that comes with this distribution
5 //
6
7 #ifndef HIGHLIGHTSTATE_H_
8 #define HIGHLIGHTSTATE_H_
9
10 #include <deque>
11 #include <vector>
12 #include <string>
13 #include <boost/shared_ptr.hpp>
14
16
17 class HighlightRule;
18 struct HighlightToken;
20
30
33
37
39
42
50
52 const unsigned int id;
53
58
61
64
70
71 public:
83
88 void addRule(HighlightRulePtr rule);
89
97 HighlightRulePtr
replaceRule(RuleList::size_type index,
98 HighlightRulePtr rule);
99
100 unsigned int getId() const {
102 }
103 const RuleList &getRuleList() const {
105 }
106
107 const std::string &getDefaultElement() const {
109 }
110 void setDefaultElement(const std::string &e) {
111 defaultElement = e;
112 }
113
122 bool findBestMatch(
const std::string &s, HighlightToken &token,
123 const MatchingParameters ¶ms) const;
124
135 std::string::const_iterator end, HighlightToken &token,
136 const MatchingParameters ¶ms) const;
137
146 static bool betterThan(
const HighlightToken &t1,
const HighlightToken &t2);
147
156
157 bool getNeedsReferenceReplacement() const {
159 }
160
161 void setNeedsReferenceReplacement(bool b = true) {
162 needsReferenceReplacement = b;
163 }
164
165 HighlightStatePtr getOriginalState() const {
167 }
168
169 void setOriginalState(HighlightStatePtr orig) {
170 originalState = orig;
171 }
172
173 };
174
175 }
176
177 #endif /*HIGHLIGHTSTATE_H_*/
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.