Inheritance diagram for highlight::CodeGenerator:
Public Member Functions | |
ParseError | generateFile (const string &inFileName, const string &outFileName) |
string | generateString (const string &input, const string &title="") |
const char * | generateCString (const string &input, const string &title="") |
bool | styleFound () |
virtual bool | initStyle (const string &stylePath) |
bool | formattingDisabled () |
bool | formattingIsPossible () |
LoadResult | initLanguage (const string &langDefPath) |
LanguageDefinition & | getLanguage () |
void | setPrintLineNumbers (bool flag, unsigned int startCnt=0) |
bool | getPrintLineNumbers () |
void | setPrintZeroes (bool flag) |
bool | getPrintZeroes () |
void | setFragmentCode (bool flag) |
void | setLineNumberWidth (int w) |
int | getLineNumberWidth () |
bool | getFragmentCode () |
const string & | getStyleName () |
void | setBaseFont (const string &s) |
const string | getBaseFont () const |
void | setBaseFontSize (const string &s) |
const string & | getBaseFontSize () |
void | setPreformatting (WrapMode lineWrappingStyle, unsigned int lineLength, int numberSpaces) |
void | setIncludeStyle (bool flag) |
void | setSpecialOptions (bool htmlAttachAnchors, bool htmlOrderedList, bool latexReplQuotes, bool latexDisableShorthands, bool xslFopCompatible, const string &rtfPageSize) |
bool | printExternalStyle (const string &outFile) |
virtual bool | printIndexFile (const vector< string > &fileList, const string &outPath) |
bool | initIndentationScheme (const string &indentSchemePath) |
void | setStyleInputPath (const string &path) |
void | setStyleOutputPath (const string &path) |
void | setEncoding (const string &encodingName) |
const string & | getStyleInputPath () |
const string & | getStyleOutputPath () |
Static Public Member Functions | |
static CodeGenerator * | getInstance (OutputType type) |
static void | deleteInstance () |
Protected Member Functions | |
CodeGenerator (highlight::OutputType type) | |
virtual string | maskCharacter (unsigned char c)=0 |
string | maskString (const string &s) |
State | getState (const string &s, unsigned int searchPos) |
virtual void | insertLineNumber (bool insertNewLine=true) |
virtual string | getFooter ()=0 |
virtual void | printBody ()=0 |
virtual string | getHeader (const string &title)=0 |
unsigned int | getLineNumber () |
void | processRootState () |
virtual string | getNewLine () |
unsigned int | getStyleID (State s, unsigned int kwClassID=0) |
unsigned int | getLineIndex () |
void | flushWs () |
string | readUserStyleDef () |
virtual string | getStyleDefinition () |
bool | encodingDefined () |
Protected Attributes | |
vector< string > | styleTagOpen |
vector< string > | styleTagClose |
DocumentStyle | docStyle |
LanguageDefinition | langInfo |
string | newLineTag |
string | spacer |
istream * | in |
ostream * | out |
string | maskWsBegin |
string | maskWsEnd |
string | styleCommentOpen |
string | styleCommentClose |
string | encoding |
bool | maskWs |
bool | excludeWs |
bool | fragmentOutput |
bool | showLineNumbers |
bool | lineNumberFillZeroes |
string | baseFont |
string | baseFontSize |
string | line |
unsigned int | lineNumber |
unsigned int | lineNumberOffset |
State | currentState |
unsigned int | currentKeywordClass |
string | wsBuffer |
bool | includeStyleDef |
The virtual class provides source code parsing functionality, based on information stored in language definitions.
The derived classes have to define the output format.
Codegenerator is a singleton class.
CodeGenerator * highlight::CodeGenerator::getInstance | ( | OutputType | type | ) | [static] |
Get appropriate Codegenerator instance
type | Output file type (HTML, XHTML, RTF, LATEX, TEX, XSLFO, ANSI) |
void highlight::CodeGenerator::deleteInstance | ( | ) | [static] |
Deletes the singleton CodeGenerator instance. Call this method if getInstance was already called, or if you want to free the momory after usage.
ParseError highlight::CodeGenerator::generateFile | ( | const string & | inFileName, | |
const string & | outFileName | |||
) |
Generates output file
inFileName | Path of input file (if empty use stdin) | |
outFileName | Path of output file (if empty use stdout) |
string highlight::CodeGenerator::generateString | ( | const string & | input, | |
const string & | title = "" | |||
) |
Generates output string
input | input code | |
title | document title |
const char * highlight::CodeGenerator::generateCString | ( | const string & | input, | |
const string & | title = "" | |||
) |
Generates output string (added to make SWIG integration easier)
input | input code | |
title | document title |
bool highlight::CodeGenerator::styleFound | ( | ) |
bool highlight::CodeGenerator::initStyle | ( | const string & | stylePath | ) | [virtual] |
Define colour style information
stylePath | Path of style description file |
Reimplemented in highlight::XslFoGenerator.
bool highlight::CodeGenerator::formattingDisabled | ( | ) |
bool highlight::CodeGenerator::formattingIsPossible | ( | ) |
LoadResult highlight::CodeGenerator::initLanguage | ( | const string & | langDefPath | ) |
langDefPath | Absolute path to language definition |
LanguageDefinition & highlight::CodeGenerator::getLanguage | ( | ) |
void highlight::CodeGenerator::setPrintLineNumbers | ( | bool | flag, | |
unsigned int | startCnt = 0 | |||
) |
tell parser to output line numbers
flag | true if line numbers should be printed | |
startCnt | line number starting count |
bool highlight::CodeGenerator::getPrintLineNumbers | ( | ) |
void highlight::CodeGenerator::setPrintZeroes | ( | bool | flag | ) |
tell parser to output line numbers filled with zeroes
flag | true if zeroes should be printed |
bool highlight::CodeGenerator::getPrintZeroes | ( | ) |
void highlight::CodeGenerator::setFragmentCode | ( | bool | flag | ) |
tell parser to omit document header and footer
flag | true if output should be fragmented |
void highlight::CodeGenerator::setLineNumberWidth | ( | int | w | ) |
define line number width
w | width |
int highlight::CodeGenerator::getLineNumberWidth | ( | ) |
bool highlight::CodeGenerator::getFragmentCode | ( | ) |
const string & highlight::CodeGenerator::getStyleName | ( | ) |
void highlight::CodeGenerator::setBaseFont | ( | const string & | s | ) |
tell parser to use this font as base font
s | the font name, e.g. "Courier New" |
const string highlight::CodeGenerator::getBaseFont | ( | ) | const |
void highlight::CodeGenerator::setBaseFontSize | ( | const string & | s | ) |
tell parser to use this size as base font size
s | the font size, e.g. "12" |
const string & highlight::CodeGenerator::getBaseFontSize | ( | ) |
void highlight::CodeGenerator::setPreformatting | ( | WrapMode | lineWrappingStyle, | |
unsigned int | lineLength, | |||
int | numberSpaces | |||
) |
tell parser the wrapping mode
lineWrappingStyle | wrapping style | |
lineLength | max line length | |
numberSpaces | number of spaces which replace a tab |
void highlight::CodeGenerator::setIncludeStyle | ( | bool | flag | ) |
tell parser the include style definition in output
flag | true if style should be included |
void highlight::CodeGenerator::setSpecialOptions | ( | bool | htmlAttachAnchors, | |
bool | htmlOrderedList, | |||
bool | latexReplQuotes, | |||
bool | latexDisableShorthands, | |||
bool | xslFopCompatible, | |||
const string & | rtfPageSize | |||
) |
define output format specific options
htmlAttachAnchors | set true if anchors should be added to line numbers | |
htmlOrderedList | set true if line numbers should be replaced by ordered list | |
latexReplQuotes | set true if quotes should be replaced by | |
latexDisableShorthands | set true if Babel shorthands should be disabled | |
xslFopCompatible | set true if XSL output should be compatible with Apache FOP | |
rtfPageSize | RTF page size (a3, a4, a5, b4, b5, b6, letter, legal) |
bool highlight::CodeGenerator::printExternalStyle | ( | const string & | outFile | ) |
Print style definitions to external file
outFile | Path of external style definition |
Reimplemented in highlight::HtmlGenerator.
bool highlight::CodeGenerator::printIndexFile | ( | const vector< string > & | fileList, | |
const string & | outPath | |||
) | [virtual] |
Print index file with all input file names
fileList | List of output file names | |
outPath | Output path |
Reimplemented in highlight::HtmlGenerator.
bool highlight::CodeGenerator::initIndentationScheme | ( | const string & | indentSchemePath | ) |
initialize source code indentation
indentSchemePath | Path of indentation scheme |
void highlight::CodeGenerator::setStyleInputPath | ( | const string & | path | ) |
Set style input path
path | path to style input file |
void highlight::CodeGenerator::setStyleOutputPath | ( | const string & | path | ) |
Set style output path
path | path to style output file |
void highlight::CodeGenerator::setEncoding | ( | const string & | encodingName | ) |
Set encloding
encodingName | encoding name |
const string & highlight::CodeGenerator::getStyleInputPath | ( | ) |
const string & highlight::CodeGenerator::getStyleOutputPath | ( | ) |
virtual string highlight::CodeGenerator::maskCharacter | ( | unsigned char | c | ) | [protected, pure virtual] |
c | Character to be masked |
string highlight::CodeGenerator::maskString | ( | const string & | s | ) | [protected] |
s | string |
State highlight::CodeGenerator::getState | ( | const string & | s, | |
unsigned int | searchPos | |||
) | [protected] |
s | Symbol string | |
searchPos | Position where search starts |
void highlight::CodeGenerator::insertLineNumber | ( | bool | insertNewLine = true |
) | [protected, virtual] |
Insert line number at the beginning of current output line
Reimplemented in highlight::HtmlGenerator.
virtual string highlight::CodeGenerator::getFooter | ( | ) | [protected, pure virtual] |
Prints document footer
Implemented in highlight::AnsiGenerator, highlight::HtmlGenerator, highlight::LatexGenerator, highlight::TexGenerator, highlight::XmlGenerator, and highlight::XslFoGenerator.
virtual void highlight::CodeGenerator::printBody | ( | ) | [protected, pure virtual] |
Prints document body
Implemented in highlight::AnsiGenerator, highlight::HtmlGenerator, highlight::LatexGenerator, highlight::TexGenerator, highlight::XmlGenerator, and highlight::XslFoGenerator.
virtual string highlight::CodeGenerator::getHeader | ( | const string & | title | ) | [protected, pure virtual] |
prints document header
title | Title of the document |
Implemented in highlight::AnsiGenerator, highlight::HtmlGenerator, highlight::LatexGenerator, highlight::TexGenerator, highlight::XmlGenerator, and highlight::XslFoGenerator.
unsigned int highlight::CodeGenerator::getLineNumber | ( | ) | [protected] |
Get current line number
void highlight::CodeGenerator::processRootState | ( | ) | [protected] |
Processes origin state
string highlight::CodeGenerator::getNewLine | ( | ) | [protected, virtual] |
unsigned int highlight::CodeGenerator::getStyleID | ( | State | s, | |
unsigned int | kwClassID = 0 | |||
) | [protected] |
s | current state | |
kwClassID | keyword class (has to be set when s=KEYWORD) |
unsigned int highlight::CodeGenerator::getLineIndex | ( | ) | [protected] |
void highlight::CodeGenerator::flushWs | ( | ) | [protected] |
print all remaining white space
string highlight::CodeGenerator::readUserStyleDef | ( | ) | [protected] |
virtual string highlight::CodeGenerator::getStyleDefinition | ( | ) | [inline, protected, virtual] |
bool highlight::CodeGenerator::encodingDefined | ( | ) | [inline, protected] |
vector<string> highlight::CodeGenerator::styleTagOpen [protected] |
Tag Delimiters for every colour style
DocumentStyle highlight::CodeGenerator::docStyle [protected] |
Description of document colour style
LanguageDefinition highlight::CodeGenerator::langInfo [protected] |
Language definition
string highlight::CodeGenerator::newLineTag [protected] |
Tag for inserting line feeds
string highlight::CodeGenerator::spacer [protected] |
String that represents a white space in output
istream* highlight::CodeGenerator::in [protected] |
file input
ostream* highlight::CodeGenerator::out [protected] |
file output
string highlight::CodeGenerator::maskWsBegin [protected] |
Tags which enclose white space indentation blocks
string highlight::CodeGenerator::styleCommentOpen [protected] |
Style comment delimiters
string highlight::CodeGenerator::encoding [protected] |
Encoding name
bool highlight::CodeGenerator::maskWs [protected] |
Test if maskWsBegin and maskWsEnd should be applied
bool highlight::CodeGenerator::excludeWs [protected] |
Test if whitespace sould always be separated from enclosing tokens
bool highlight::CodeGenerator::fragmentOutput [protected] |
Test if header and footer should be omitted
bool highlight::CodeGenerator::showLineNumbers [protected] |
Test if line numbers should be printed
bool highlight::CodeGenerator::lineNumberFillZeroes [protected] |
Test if leading spyce of line number should be filled with zeroes
string highlight::CodeGenerator::baseFont [protected] |
The base font to use
string highlight::CodeGenerator::baseFontSize [protected] |
The base font size to use
string highlight::CodeGenerator::line [protected] |
Current line of input file
unsigned int highlight::CodeGenerator::lineNumber [protected] |
Current line number
State highlight::CodeGenerator::currentState [protected] |
Current state
unsigned int highlight::CodeGenerator::currentKeywordClass [protected] |
keyword class id, used to apply the corresponding keyword style
string highlight::CodeGenerator::wsBuffer [protected] |
contains white space, which will be printed after a closing tag
bool highlight::CodeGenerator::includeStyleDef [protected] |
Flag to test if style definition should be included in output document