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 SOURCEHIGHLIGHTER_H_
8 #define SOURCEHIGHLIGHTER_H_
9
10 #include <string>
11 #include <stack>
12 #include <sstream>
13 #include <boost/shared_ptr.hpp>
14
15 #include "highlightstate.h"
16 #include "eventgenerator.h"
17
19
20 class FormatterManager;
21 struct HighlightToken;
22 struct FormatterParams;
23 class HighlightEventListener;
24 struct HighlightEvent;
25
26 typedef std::stack<HighlightStatePtr> HighlightStateStack;
27 typedef boost::shared_ptr<HighlightStateStack> HighlightStateStackPtr;
28
44 HighlightEvent> {
47
50
53
56
62
69
74
79
84
90
96
101
108
114 void format(
const std::string &elem,
const std::string &s);
115
121
122 public:
128
134
137 }
138
140 currentHighlightState = state;
141 }
142
143 HighlightStateStackPtr getStateStack() {
145 }
146
147 void setStateStack(HighlightStateStackPtr state) {
148 stateStack = state;
149 }
150
155
158 }
159
160 const FormatterManager *getFormatterManager() const {
162 }
163
164 void setFormatterManager(const FormatterManager *_formatterManager) {
165 formatterManager = _formatterManager;
166 }
167
168 bool getOptimize() const {
170 }
171
172 void setOptimize(bool b = true) {
173 optimize = b;
174 }
175
176 void setFormatterParams(FormatterParams *p) {
177 formatterParams = p;
178 }
179
180 bool isSuspended() const {
182 }
183
184 void setSuspended(bool b = true) {
185 suspended = b;
186 }
187 };
188
189 }
190
191 #endif /*SOURCEHIGHLIGHTER_H_*/
HighlightStatePtr mainHighlightState
the main (and initial) highlight state
Definition: sourcehighlighter.h:46
HighlightStateStackPtr stateStack
the stack for the highlight states
Definition: sourcehighlighter.h:52
void clearStateStack()
Clears the statck of states.
Definition: sourcehighlighter.cpp:177
void enterState(HighlightStatePtr state)
Enters a new state (using the stack)
Definition: sourcehighlighter.cpp:154
void exitAll()
Exits all states in the stack (and thus go back to the initial main state)
Definition: sourcehighlighter.cpp:172
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13
std::string currentElement
The current element being formatted (used for optmization and buffering)
Definition: sourcehighlighter.h:78
void highlightParagraph(const std::string ¶graph)
Highlights a paragraph (a line actually)
Definition: sourcehighlighter.cpp:51
HighlightStatePtr currentHighlightState
the current highlight state
Definition: sourcehighlighter.h:49
FormatterParams * formatterParams
Additional parameters for the formatters.
Definition: sourcehighlighter.h:73
bool suspended
Whether formatting is currently suspended.
Definition: sourcehighlighter.h:68
The main class performing the highlighting of a single line.
Definition: sourcehighlighter.h:43
const FormatterManager * formatterManager
the formatter manager, used to format element strings
Definition: sourcehighlighter.h:55
bool optimize
Whether to optimize output (e.g., adjacent text parts belonging to the same element will be buffered ...
Definition: sourcehighlighter.h:61
SourceHighlighter(HighlightStatePtr mainState)
Definition: sourcehighlighter.cpp:41
boost::shared_ptr< HighlightState > HighlightStatePtr
the reference to an HighlightState
Definition: highlightstate.h:38
void flush()
Makes sure to flush the possible buffer of the current element (e.g., during optimizations) ...
Definition: sourcehighlighter.cpp:211
Token containing information for performing the highlight.
Definition: highlighttoken.h:33
HighlightStatePtr getNextState(const HighlightToken &token)
Computes the (possible) next state for the given rule (if required, also performs reference replaceme...
Definition: sourcehighlighter.cpp:128
std::ostringstream currentElementBuffer
The buffer for the text for the current element.
Definition: sourcehighlighter.h:83
A generic event generator, for listeners of type EventListener and events of type EventType...
Definition: eventgenerator.h:18
void format(const std::string &elem, const std::string &s)
Formats the given string as the specified element.
Definition: sourcehighlighter.cpp:182
void exitState(int level)
Exits level states (-1 means exit all states)
Definition: sourcehighlighter.cpp:163