Source-highlight Library
|
The main class performing highlighting of an input file generating an output file. More...
#include <sourcehighlight.h>
Public Member Functions | |
SourceHighlight (const std::string &outputLang="html.outlang") | |
void | initialize () |
performs initialization of fields, if not already initialized. More... | |
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 definition. More... | |
void | highlight (std::istream &input, std::ostream &output, const std::string &inputLang, const std::string &inputFileName="") |
Highlights the contents of the input stream into the output stream, using the specified inputLang definition. More... | |
void | checkLangDef (const std::string &langFile) |
Only check the validity of the language definition file. More... | |
void | checkOutLangDef (const std::string &langFile) |
Only check the validity of the out language definition file. More... | |
void | printHighlightState (const std::string &langFile, std::ostream &os) |
Prints the HighlightState corresponding to the language definition file. More... | |
void | printLangElems (const std::string &langFile, std::ostream &os) |
Prints the language elements corresponding to the language definition file. More... | |
const std::string | createOutputFileName (const std::string &inputFile) |
Given the input file name creates an output file name. More... | |
void | setDataDir (const std::string &_datadir) |
void | setStyleFile (const std::string &_styleFile) |
void | setStyleCssFile (const std::string &_styleFile) |
void | setStyleDefaultFile (const std::string &_styleDefaultFile) |
void | setTitle (const std::string &_title) |
void | setInputLang (const std::string &_inputLang) |
void | setCss (const std::string &_css) |
void | setHeaderFileName (const std::string &h) |
void | setFooterFileName (const std::string &f) |
void | setOutputDir (const std::string &_outputDir) |
const TextStyleFormatterCollection & | getFormatterCollection () const |
void | setOptimize (bool b=true) |
void | setGenerateLineNumbers (bool b=true) |
void | setGenerateLineNumberRefs (bool b=true) |
void | setLineNumberPad (char c) |
void | setLineNumberAnchorPrefix (const std::string &_prefix) |
void | setLineNumberDigits (unsigned int d) |
void | setGenerateEntireDoc (bool b=true) |
void | setGenerateVersion (bool b=true) |
void | setCanUseStdOut (bool b=true) |
void | setBinaryOutput (bool b=true) |
void | setHighlightEventListener (HighlightEventListener *l) |
void | setRangeSeparator (const std::string &sep) |
DocGenerator * | getDocGenerator () const |
DocGenerator * | getNoDocGenerator () const |
LineRanges * | getLineRanges () const |
void | setLineRanges (LineRanges *lr) |
RegexRanges * | getRegexRanges () const |
void | setRegexRanges (RegexRanges *rr) |
void | setCTagsManager (CTagsManager *m) |
void | setTabSpaces (unsigned int i) |
const std::string & | getOutputFileExtension () const |
Returns the file extension for the output file as specified in the output format definition file (initialize must have been called). More... | |
Private Member Functions | |
void | updateBufferedOutput (BufferedOutput *output) |
Sets the specified buffered output to all the formatters. More... | |
Private Attributes | |
std::string | outputLang |
the output language file name | |
std::string | dataDir |
Path for several configuration files. More... | |
std::string | backgroundColor |
the background color | |
std::string | styleFile |
the style file | |
std::string | styleCssFile |
the css style file | |
std::string | styleDefaultFile |
the style defaults file | |
std::string | linePrefix |
the prefix for all the output lines | |
std::string | rangeSeparator |
the separator for ranges | |
std::string | title |
the title for the output document (defaults to the source file name) | |
std::string | inputLang |
the input lang for the output document | |
std::string | css |
the value for the css | |
std::string | headerFileName |
the file name of the header | |
std::string | footerFileName |
the file name of the footer | |
std::string | outputFileExtension |
the file extension for output files | |
std::string | outputFileDir |
the directory for output files | |
FormatterManager * | formatterManager |
the formatter manager | |
PreFormatter * | preFormatter |
the preformatter | |
TextStyleFormatterCollection | formatterCollection |
all the formatters that are created | |
LangDefManager * | langDefManager |
for loading language definitions | |
LineNumGenerator * | lineNumGenerator |
the generator for line numbers | |
DocGenerator * | docGenerator |
the generator of the start and end of the output document | |
DocGenerator * | noDocGenerator |
the generator of the start and end of the output document when NOT generating an entire document | |
HighlightEventListener * | highlightEventListener |
The listener for highlight events. | |
CTagsManager * | ctagsManager |
the CTagsManager for creating CTagsFormatters | |
CTagsFormatter * | ctagsFormatter |
the CTagsFormatter for formatting references and anchors | |
LineRanges * | lineRanges |
the possible LineRanges (to check which lines should be printed) | |
RegexRanges * | regexRanges |
the possible RegexRanges (to check which lines should be printed) | |
bool | optimize |
Whether to optmize output (e.g., adiacent text parts belonging to the same element will be buffered and generated as a single text part) | |
bool | generateLineNumbers |
whether to generate line numbers | |
bool | generateLineNumberRefs |
whether to generate line numbers with references | |
std::string | lineNumberAnchorPrefix |
the prefix for the line number anchors | |
char | lineNumberPad |
the line number padding char (default '0') | |
unsigned int | lineNumberDigits |
the number of digits for line numbers (if not specified this is computed automatically according to the lines in the input, if the input is a file name, otherwise it is set to a default value of 5) | |
bool | generateEntireDoc |
whether to generate an entire document (default false) | |
bool | generateVersion |
whether to generate the program version in the output file (default=true) | |
bool | canUseStdOut |
whether we can use stdout for generating the output (default true) | |
bool | binaryOutput |
whether to open output files in binary mode (default false) | |
unsigned int | tabSpaces |
If greater than 0 it means that tabs will be replaced by tabSpaces blank characters. | |
The main class performing highlighting of an input file generating an output file.
srchilite::SourceHighlight::SourceHighlight | ( | const std::string & | outputLang = "html.outlang" | ) |
outputLang | the output lang file (default: html.outlang) |
void srchilite::SourceHighlight::checkLangDef | ( | const std::string & | langFile | ) |
Only check the validity of the language definition file.
If the language definition is valid it simply returns, otherwise, it throws an exception (with the details of the problems found)
langFile |
HighlightBuilderException |
void srchilite::SourceHighlight::checkOutLangDef | ( | const std::string & | langFile | ) |
Only check the validity of the out language definition file.
If the language definition is valid it simply returns, otherwise, it throws an exception (with the details of the problems found)
langFile |
ParserException |
const string srchilite::SourceHighlight::createOutputFileName | ( | const std::string & | inputFile | ) |
Given the input file name creates an output file name.
|
inline |
Returns the file extension for the output file as specified in the output format definition file (initialize must have been called).
void srchilite::SourceHighlight::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 definition.
input | the input file name, if empty stdin will be used |
output | the output file name, if empty (or equal to STDOUT) the stdout will be used |
inputLang | the language definition file |
void srchilite::SourceHighlight::highlight | ( | std::istream & | input, |
std::ostream & | output, | ||
const std::string & | inputLang, | ||
const std::string & | inputFileName = "" |
||
) |
Highlights the contents of the input stream into the output stream, using the specified inputLang definition.
input | the input stream |
output | the output stream |
inputLang | the language definition file |
inputFileName | the input file name |
void srchilite::SourceHighlight::initialize | ( | ) |
performs initialization of fields, if not already initialized.
There's no need to call it directly, since the highlight functions always check initialization.
void srchilite::SourceHighlight::printHighlightState | ( | const std::string & | langFile, |
std::ostream & | os | ||
) |
Prints the HighlightState corresponding to the language definition file.
If the language definition is valid it simply prints the state and returns, otherwise, it throws an exception (with the details of the problems found)
langFile | |
os | where to print the highlight state |
HighlightBuilderException |
void srchilite::SourceHighlight::printLangElems | ( | const std::string & | langFile, |
std::ostream & | os | ||
) |
Prints the language elements corresponding to the language definition file.
If the language definition is valid it simply prints the state and returns, otherwise, it throws an exception (with the details of the problems found)
langFile | |
os | where to print the highlight state |
HighlightBuilderException |
|
private |
Sets the specified buffered output to all the formatters.
output |
|
private |
Path for several configuration files.
By default it contains the absolute data dir corresponding to the installation path, e.g., "$prefix/share/source-highlight"