7 #ifndef SOURCEHIGHLIGHTER_H_
8 #define SOURCEHIGHLIGHTER_H_
13 #include <boost/shared_ptr.hpp>
15 #include "highlightstate.h"
16 #include "eventgenerator.h"
20 class FormatterManager;
21 struct HighlightToken;
22 struct FormatterParams;
23 class HighlightEventListener;
24 struct HighlightEvent;
26 typedef std::stack<HighlightStatePtr> HighlightStateStack;
27 typedef boost::shared_ptr<HighlightStateStack> HighlightStateStackPtr;
114 void format(
const std::string &elem,
const std::string &s);
140 currentHighlightState = state;
143 HighlightStateStackPtr getStateStack() {
147 void setStateStack(HighlightStateStackPtr state) {
160 const FormatterManager *getFormatterManager()
const {
164 void setFormatterManager(
const FormatterManager *_formatterManager) {
165 formatterManager = _formatterManager;
168 bool getOptimize()
const {
172 void setOptimize(
bool b =
true) {
176 void setFormatterParams(FormatterParams *p) {
180 bool isSuspended()
const {
184 void setSuspended(
bool b =
true) {
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