7 #ifndef SOURCEHIGHLIGHT_H_
8 #define SOURCEHIGHLIGHT_H_
14 #include "textstyleformattercollection.h"
18 class FormatterManager;
22 class LineNumGenerator;
25 class HighlightEventListener;
198 void highlight(
const std::string &input,
const std::string &output,
199 const std::string &inputLang);
210 highlight(std::istream &input, std::ostream &output,
211 const std::string &inputLang,
212 const std::string &inputFileName =
"");
250 void printLangElems(
const std::string &langFile, std::ostream &os);
259 void setDataDir(
const std::string &_datadir) {
263 void setStyleFile(
const std::string &_styleFile) {
264 styleFile = _styleFile;
267 void setStyleCssFile(
const std::string &_styleFile) {
268 styleCssFile = _styleFile;
271 void setStyleDefaultFile(
const std::string &_styleDefaultFile) {
272 styleDefaultFile = _styleDefaultFile;
275 void setTitle(
const std::string &_title) {
279 void setInputLang(
const std::string &_inputLang) {
280 inputLang = _inputLang;
283 void setCss(
const std::string &_css) {
287 void setHeaderFileName(
const std::string &h) {
291 void setFooterFileName(
const std::string &f) {
295 void setOutputDir(
const std::string &_outputDir) {
296 outputFileDir = _outputDir;
303 void setOptimize(
bool b =
true) {
307 void setGenerateLineNumbers(
bool b =
true) {
308 generateLineNumbers = b;
311 void setGenerateLineNumberRefs(
bool b =
true) {
312 generateLineNumberRefs = b;
315 void setLineNumberPad(
char c) {
319 void setLineNumberAnchorPrefix(
const std::string &_prefix) {
320 lineNumberAnchorPrefix = _prefix;
323 void setLineNumberDigits(
unsigned int d) {
324 lineNumberDigits = d;
327 void setGenerateEntireDoc(
bool b =
true) {
328 generateEntireDoc = b;
331 void setGenerateVersion(
bool b =
true) {
335 void setCanUseStdOut(
bool b =
true) {
339 void setBinaryOutput(
bool b =
true) {
343 void setHighlightEventListener(HighlightEventListener *l) {
344 highlightEventListener = l;
347 void setRangeSeparator(
const std::string &sep) {
348 rangeSeparator = sep;
351 DocGenerator *getDocGenerator()
const {
355 DocGenerator *getNoDocGenerator()
const {
359 LineRanges *getLineRanges()
const {
363 void setLineRanges(LineRanges *lr) {
367 RegexRanges *getRegexRanges()
const {
371 void setRegexRanges(RegexRanges *rr) {
375 void setCTagsManager(CTagsManager *m) {
379 void setTabSpaces(
unsigned int i) {
Given a DocTemplate it generates the start of the document and the end, using variables such as title...
Definition: docgenerator.h:40
std::string rangeSeparator
the separator for ranges
Definition: sourcehighlight.h:62
std::string linePrefix
the prefix for all the output lines
Definition: sourcehighlight.h:59
bool generateEntireDoc
whether to generate an entire document (default false)
Definition: sourcehighlight.h:154
void highlight(const std::string &input, const std::string &output, const std::string &inputLang)
Highlights the contents of the input file into the output file, using the specified inputLang definit...
Definition: sourcehighlight.cpp:182
std::string styleDefaultFile
the style defaults file
Definition: sourcehighlight.h:56
std::string lineNumberAnchorPrefix
the prefix for the line number anchors
Definition: sourcehighlight.h:141
LineNumGenerator * lineNumGenerator
the generator for line numbers
Definition: sourcehighlight.h:98
std::string css
the value for the css
Definition: sourcehighlight.h:71
LangDefManager * langDefManager
for loading language definitions
Definition: sourcehighlight.h:95
Stores possible separators implemented as regular expressions and provides functionalities to search ...
Definition: regexranges.h:22
char lineNumberPad
the line number padding char (default '0')
Definition: sourcehighlight.h:144
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13
Generates line numbers in the output.
Definition: linenumgenerator.h:19
DocGenerator * docGenerator
the generator of the start and end of the output document
Definition: sourcehighlight.h:103
std::string styleCssFile
the css style file
Definition: sourcehighlight.h:53
bool optimize
Whether to optmize output (e.g., adiacent text parts belonging to the same element will be buffered a...
Definition: sourcehighlight.h:132
PreFormatter * preFormatter
the preformatter
Definition: sourcehighlight.h:89
std::string styleFile
the style file
Definition: sourcehighlight.h:50
LineRanges * lineRanges
the possible LineRanges (to check which lines should be printed)
Definition: sourcehighlight.h:123
Handles langdef language definition files.
Definition: langdefmanager.h:25
const std::string & getOutputFileExtension() const
Returns the file extension for the output file as specified in the output format definition file (ini...
Definition: sourcehighlight.h:388
void printHighlightState(const std::string &langFile, std::ostream &os)
Prints the HighlightState corresponding to the language definition file.
Definition: sourcehighlight.cpp:376
const std::string createOutputFileName(const std::string &inputFile)
Given the input file name creates an output file name.
Definition: sourcehighlight.cpp:281
std::string footerFileName
the file name of the footer
Definition: sourcehighlight.h:77
std::string title
the title for the output document (defaults to the source file name)
Definition: sourcehighlight.h:65
void initialize()
performs initialization of fields, if not already initialized.
Definition: sourcehighlight.cpp:82
bool canUseStdOut
whether we can use stdout for generating the output (default true)
Definition: sourcehighlight.h:160
bool binaryOutput
whether to open output files in binary mode (default false)
Definition: sourcehighlight.h:163
FormatterManager * formatterManager
the formatter manager
Definition: sourcehighlight.h:86
Functionalities for detecting whether a line is in one of the stored line ranges (or in the context o...
Definition: lineranges.h:38
std::string headerFileName
the file name of the header
Definition: sourcehighlight.h:74
SourceHighlight(const std::string &outputLang="html.outlang")
Definition: sourcehighlight.cpp:46
DocGenerator * noDocGenerator
the generator of the start and end of the output document when NOT generating an entire document ...
Definition: sourcehighlight.h:109
void printLangElems(const std::string &langFile, std::ostream &os)
Prints the language elements corresponding to the language definition file.
Definition: sourcehighlight.cpp:384
std::string inputLang
the input lang for the output document
Definition: sourcehighlight.h:68
std::string outputFileExtension
the file extension for output files
Definition: sourcehighlight.h:80
The main class for writing into the output.
Definition: bufferedoutput.h:28
bool generateLineNumberRefs
whether to generate line numbers with references
Definition: sourcehighlight.h:138
TextStyleFormatterCollection formatterCollection
all the formatters that are created
Definition: sourcehighlight.h:92
bool generateLineNumbers
whether to generate line numbers
Definition: sourcehighlight.h:135
std::string backgroundColor
the background color
Definition: sourcehighlight.h:47
RegexRanges * regexRanges
the possible RegexRanges (to check which lines should be printed)
Definition: sourcehighlight.h:126
void updateBufferedOutput(BufferedOutput *output)
Sets the specified buffered output to all the formatters.
Definition: sourcehighlight.cpp:394
unsigned int tabSpaces
If greater than 0 it means that tabs will be replaced by tabSpaces blank characters.
Definition: sourcehighlight.h:169
std::string outputFileDir
the directory for output files
Definition: sourcehighlight.h:83
std::list< TextStyleFormatter * > TextStyleFormatterCollection
Collection of TextStyleFormatter objects.
Definition: textstyleformattercollection.h:8
std::string dataDir
Path for several configuration files.
Definition: sourcehighlight.h:44
void checkOutLangDef(const std::string &langFile)
Only check the validity of the out language definition file.
Definition: sourcehighlight.cpp:368
CTagsFormatter * ctagsFormatter
the CTagsFormatter for formatting references and anchors
Definition: sourcehighlight.h:120
The main class performing highlighting of an input file generating an output file.
Definition: sourcehighlight.h:35
unsigned int lineNumberDigits
the number of digits for line numbers (if not specified this is computed automatically according to t...
Definition: sourcehighlight.h:151
Base class for listeners of HighlightEvent.
Definition: highlighteventlistener.h:17
bool generateVersion
whether to generate the program version in the output file (default=true)
Definition: sourcehighlight.h:157
std::string outputLang
the output language file name
Definition: sourcehighlight.h:37
CTagsManager * ctagsManager
the CTagsManager for creating CTagsFormatters
Definition: sourcehighlight.h:117
HighlightEventListener * highlightEventListener
The listener for highlight events.
Definition: sourcehighlight.h:114
void checkLangDef(const std::string &langFile)
Only check the validity of the language definition file.
Definition: sourcehighlight.cpp:360