
Public Member Functions | |
| bool | initTheme (const string &themePath) |
| bool | initIndentationScheme (const string &indentScheme) |
| bool | initTagInformation (const string &ctagsPath) |
| LoadResult | loadLanguage (const string &langDefPath) |
| ParseError | generateFile (const string &inFileName, const string &outFileName) |
| string | generateString (const string &input) |
| string | generateStringFromFile (const string &inFileName) |
| bool | printExternalStyle (const string &outFile) |
| virtual bool | printIndexFile (const vector< string > &fileList, const string &outPath) |
| void | setPreformatting (WrapMode lineWrappingStyle, unsigned int lineLength, int numberSpaces) |
| bool | styleFound () |
| bool | formattingDisabled () |
| bool | formattingIsPossible () |
| LoadResult | initLanguage (const string &langDefPath) |
| const LanguageDefinition & | getLanguage () |
| void | setPrintLineNumbers (bool flag, unsigned int startCnt=1) |
| bool | getPrintLineNumbers () |
| void | setPrintZeroes (bool flag) |
| bool | getPrintZeroes () |
| void | setFragmentCode (bool flag) |
| bool | getFragmentCode () |
| void | setLineNumberWidth (int w) |
| int | getLineNumberWidth () |
| void | setValidateInput (bool flag) |
| bool | getValidateInput () |
| const string & | getStyleName () |
| void | setBaseFont (const string &s) |
| const string | getBaseFont () const |
| void | setBaseFontSize (const string &s) |
| const string | getBaseFontSize () |
| void | setIncludeStyle (bool flag) |
| void | disableTrailingNL (bool flag) |
| void | setStyleInputPath (const string &path) |
| void | setStyleOutputPath (const string &path) |
| void | setEncoding (const string &encodingName) |
| const string & | getStyleInputPath () |
| const string & | getStyleOutputPath () |
| void | setTitle (const string &title) |
| string | getTitle () |
| void | setMaxInputLineCnt (unsigned int cnt) |
| bool | hasWhiteBGColour () |
| void | setKeyWordCase (StringTools::KeywordCase keyCase) |
| void | addMarkedLine (int lineNo, string &helpTxt) |
| void | setEOLDelimiter (char delim) |
| void | setStartingNestedLang (const string &langName) |
| virtual void | setHTMLAttachAnchors (bool) |
| virtual void | setHTMLOrderedList (bool) |
| virtual void | setHTMLInlineCSS (bool) |
| virtual void | setHTMLEnclosePreTag (bool) |
| virtual void | setHTMLAnchorPrefix (const string &) |
| virtual void | setHTMLClassName (const string &) |
| virtual void | setLATEXReplaceQuotes (bool) |
| virtual void | setLATEXNoShorthands (bool) |
| virtual void | setLATEXPrettySymbols (bool) |
| virtual void | setRTFPageSize (const string &) |
| virtual void | setRTFCharStyles (bool) |
| virtual void | setSVGSize (const string &, const string &) |
Static Public Member Functions | |
| static CodeGenerator * | getInstance (OutputType type) |
| static void | deleteInstance (CodeGenerator *inst) |
Protected Member Functions | |
| CodeGenerator (highlight::OutputType type) | |
| virtual string | maskCharacter (unsigned char c)=0 |
| void | maskString (ostream &ss, const string &s) |
| State | getState (const string &s, unsigned int searchPos) |
| 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 > | openTags |
| list of format delimiters (open new format descriptions) | |
| vector< string > | closeTags |
| list of format delimiters (close format descriptions) | |
| DocumentStyle | docStyle |
| LanguageDefinition | langInfo |
| CTagsReader | metaInfo |
| string | newLineTag |
| string | spacer |
| istream * | in |
| ostream * | out |
| string | maskWsBegin |
| open whitespace mask | |
| string | maskWsEnd |
| close whitespace mask | |
| string | styleCommentOpen |
| open comment delimiter | |
| string | styleCommentClose |
| close comment delimiter | |
| string | embedBlockOpen |
| open block delimiter to highlight embedded code | |
| string | embedBlockClose |
| close block delimiter | |
| string | encoding |
| string | docTitle |
| string | inFile |
| input file name | |
| string | outFile |
| output file name | |
| bool | maskWs |
| bool | excludeWs |
| bool | fragmentOutput |
| bool | showLineNumbers |
| bool | lineNumberFillZeroes |
| bool | printNewLines |
| string | baseFont |
| string | baseFontSize |
| string | line |
| unsigned int | lineNumber |
| int | lineNumberOffset |
| State | currentState |
| unsigned int | currentKeywordClass |
| string | wsBuffer |
| bool | includeStyleDef |
| map< int, string > | markLines |
| PreFormatter | preFormatter |
Static Protected Attributes | |
| static const unsigned int | NUMBER_BUILTIN_STATES = 10 |
| number of token states (without keyword group IDs) | |
| static const string | STY_NAME_STD = "std" |
| static const string | STY_NAME_STR = "str" |
| static const string | STY_NAME_NUM = "num" |
| static const string | STY_NAME_SLC = "slc" |
| static const string | STY_NAME_COM = "com" |
| static const string | STY_NAME_ESC = "esc" |
| static const string | STY_NAME_DIR = "dir" |
| static const string | STY_NAME_DST = "dstr" |
| static const string | STY_NAME_LIN = "line" |
| static const string | STY_NAME_SYM = "sym" |
The virtual class provides source code parsing functionality, based on information stored in language definitions.
The derived classes have to define the output format.
The colour information is stored in a DocumentStyle instance.
Codegenerator is a singleton class.
Use getInstance for a singleton class instance. Then call the init* methods and loadLanguage to initialize the parser. Init methods have to be called first. Call generate* methods to get results.
| highlight::CodeGenerator::CodeGenerator | ( | highlight::OutputType | type | ) | [protected] |
| type | Output type |
| void highlight::CodeGenerator::addMarkedLine | ( | int | lineNo, | |
| string & | helpTxt | |||
| ) |
| lineNo | number of line that should be marked | |
| helpTxt | additional help text |
References markLines.
| static void highlight::CodeGenerator::deleteInstance | ( | CodeGenerator * | inst | ) | [inline, static] |
Delete CodeGenerator instance (this is intended for SWIG integration only, in normal C++ code the result of getInstance() should be saved in an auto_ptr)
| CodeGenerator* | CodeGenerator instance |
| void highlight::CodeGenerator::disableTrailingNL | ( | bool | flag | ) |
tell parser to omit trailing newline character
| flag | true if no trailing newline should be printed |
| bool highlight::CodeGenerator::encodingDefined | ( | ) | [inline, protected] |
References StringTools::change_case(), and encoding.
Referenced by highlight::HtmlGenerator::getHeaderStart().
| void highlight::CodeGenerator::flushWs | ( | ) | [protected] |
| bool highlight::CodeGenerator::formattingDisabled | ( | ) |
| bool highlight::CodeGenerator::formattingIsPossible | ( | ) |
| ParseError highlight::CodeGenerator::generateFile | ( | const string & | inFileName, | |
| const string & | outFileName | |||
| ) |
Generate output file from input file
| inFileName | Path of input file (if empty use stdin) | |
| outFileName | Path of output file (if empty use stdout) |
References docStyle, highlight::DocumentStyle::found(), fragmentOutput, in, inFile, out, and outFile.
| string highlight::CodeGenerator::generateString | ( | const string & | input | ) |
Generate output string from input string
| input | input code string |
References docStyle, highlight::DocumentStyle::found(), fragmentOutput, in, and out.
| string highlight::CodeGenerator::generateStringFromFile | ( | const string & | inFileName | ) |
Generate output string from input file
| inFileName | file path |
References docStyle, highlight::DocumentStyle::found(), fragmentOutput, in, inFile, and out.
| const string highlight::CodeGenerator::getBaseFont | ( | ) | const |
References baseFont.
Referenced by highlight::HtmlGenerator::getStyleDefinition().
| const string highlight::CodeGenerator::getBaseFontSize | ( | ) |
References baseFontSize, docStyle, and highlight::DocumentStyle::getFontSize().
Referenced by highlight::HtmlGenerator::getStyleDefinition(), and highlight::BBCodeGenerator::printBody().
| bool highlight::CodeGenerator::getFragmentCode | ( | ) |
| CodeGenerator * highlight::CodeGenerator::getInstance | ( | OutputType | type | ) | [static] |
Get appropriate Codegenerator instance (should be used with auto_ptr)
| type | Output file type (HTML, XHTML, RTF, LATEX, TEX, ANSI, XTERM256) |
Referenced by HLCmdLineApp::run().
| const LanguageDefinition & highlight::CodeGenerator::getLanguage | ( | ) |
| unsigned int highlight::CodeGenerator::getLineIndex | ( | ) | [protected] |
| unsigned int highlight::CodeGenerator::getLineNumber | ( | ) | [protected] |
| int highlight::CodeGenerator::getLineNumberWidth | ( | ) |
| string highlight::CodeGenerator::getNewLine | ( | ) | [protected, virtual] |
References newLineTag, and printNewLines.
Referenced by processRootState().
| bool highlight::CodeGenerator::getPrintLineNumbers | ( | ) |
| bool highlight::CodeGenerator::getPrintZeroes | ( | ) |
| State highlight::CodeGenerator::getState | ( | const string & | s, | |
| unsigned int | searchPos | |||
| ) | [protected] |
| s | Symbol string | |
| searchPos | Position where search starts |
| virtual string highlight::CodeGenerator::getStyleDefinition | ( | ) | [inline, protected, virtual] |
Reimplemented in highlight::HtmlGenerator.
Referenced by printExternalStyle().
| 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) |
References NUMBER_BUILTIN_STATES.
| const string & highlight::CodeGenerator::getStyleInputPath | ( | ) |
| const string & highlight::CodeGenerator::getStyleName | ( | ) |
| const string & highlight::CodeGenerator::getStyleOutputPath | ( | ) |
| string highlight::CodeGenerator::getTitle | ( | ) |
| bool highlight::CodeGenerator::getValidateInput | ( | ) |
| bool highlight::CodeGenerator::hasWhiteBGColour | ( | ) |
References docStyle, and highlight::DocumentStyle::getBgColour().
| bool highlight::CodeGenerator::initIndentationScheme | ( | const string & | indentScheme | ) |
initialize source code indentation and reformatting scheme; needs to be called before using a generate* method
| indentScheme | Name of indentation scheme |
| LoadResult highlight::CodeGenerator::initLanguage | ( | const string & | langDefPath | ) | [inline] |
| langDefPath | Absolute path to language definition; use loadLanguage instead |
References loadLanguage().
| bool highlight::CodeGenerator::initTagInformation | ( | const string & | ctagsPath | ) |
Load ctags meta information; needs to be called before using a generate* method
| ctagsPath | Path of tags file |
References metaInfo.
| bool highlight::CodeGenerator::initTheme | ( | const string & | themePath | ) |
Define colour theme information; needs to be called before using a generate* method. Call this method before loadLanguage().
| themePath | Path of style description file |
References docStyle, and highlight::DocumentStyle::load().
| LoadResult highlight::CodeGenerator::loadLanguage | ( | const string & | langDefPath | ) |
| langDefPath | Absolute path to language definition, may be used multiple times for a generator instance |
References closeTags, highlight::LanguageDefinition::enableReformatting(), highlight::LanguageDefinition::getFailedRegex(), highlight::LanguageDefinition::getKeywordClasses(), langInfo, highlight::LanguageDefinition::load(), highlight::LanguageDefinition::needsReload(), NUMBER_BUILTIN_STATES, and openTags.
Referenced by initLanguage().
| virtual string highlight::CodeGenerator::maskCharacter | ( | unsigned char | c | ) | [protected, pure virtual] |
| c | Character to be masked |
Referenced by maskString().
| void highlight::CodeGenerator::maskString | ( | ostream & | ss, | |
| const string & | s | |||
| ) | [protected] |
| ss | destination stream | |
| s | string |
References maskCharacter().
Referenced by processRootState().
| bool highlight::CodeGenerator::printExternalStyle | ( | const string & | outFile | ) |
Print style definitions to external file or stdout
| outFile | Path of external style definition; print to stdout if empty |
Reimplemented in highlight::HtmlGenerator.
References getStyleDefinition(), highlight::LanguageDefinition::highlightingEnabled(), includeStyleDef, langInfo, readUserStyleDef(), styleCommentClose, and styleCommentOpen.
| 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.
| void highlight::CodeGenerator::processRootState | ( | ) | [protected] |
Processes origin state
References highlight::LanguageDefinition::allowExtEscSeq(), flushWs(), getNewLine(), highlight::LanguageDefinition::getNewPath(), highlight::LanguageDefinition::highlightingDisabled(), in, langInfo, lineNumber, maskString(), out, and printNewLines.
Referenced by highlight::BBCodeGenerator::printBody(), and highlight::AnsiGenerator::printBody().
| string highlight::CodeGenerator::readUserStyleDef | ( | ) | [protected] |
Reimplemented in highlight::HtmlGenerator.
References styleCommentClose, and styleCommentOpen.
Referenced by printExternalStyle().
| void highlight::CodeGenerator::setBaseFont | ( | const string & | s | ) |
| void highlight::CodeGenerator::setBaseFontSize | ( | const string & | s | ) |
| void highlight::CodeGenerator::setEncoding | ( | const string & | encodingName | ) |
Set encoding (output encoding must match input file)
| encodingName | encoding name |
References encoding.
| void highlight::CodeGenerator::setEOLDelimiter | ( | char | delim | ) |
| delim | End of line delimiter (default: NL) |
| void highlight::CodeGenerator::setFragmentCode | ( | bool | flag | ) |
omit document header and footer
| flag | true if output should be fragmented |
References fragmentOutput.
| virtual void highlight::CodeGenerator::setHTMLAnchorPrefix | ( | const string & | ) | [inline, virtual] |
set HTML output anchor prefix
Reimplemented in highlight::HtmlGenerator.
| virtual void highlight::CodeGenerator::setHTMLAttachAnchors | ( | bool | ) | [inline, virtual] |
set HTML output anchor flag
Reimplemented in highlight::HtmlGenerator.
| virtual void highlight::CodeGenerator::setHTMLClassName | ( | const string & | ) | [inline, virtual] |
set HTML output class name
Reimplemented in highlight::HtmlGenerator.
| virtual void highlight::CodeGenerator::setHTMLEnclosePreTag | ( | bool | ) | [inline, virtual] |
set HTML output enclose pre tag flag
Reimplemented in highlight::HtmlGenerator.
| virtual void highlight::CodeGenerator::setHTMLInlineCSS | ( | bool | ) | [inline, virtual] |
set HTML output inline CSS flag
Reimplemented in highlight::HtmlGenerator.
| virtual void highlight::CodeGenerator::setHTMLOrderedList | ( | bool | ) | [inline, virtual] |
set HTML output ordered list flag
Reimplemented in highlight::HtmlGenerator.
| void highlight::CodeGenerator::setIncludeStyle | ( | bool | flag | ) |
tell parser the include style definition in output
| flag | true if style should be included |
References includeStyleDef.
| void highlight::CodeGenerator::setKeyWordCase | ( | StringTools::KeywordCase | keyCase | ) |
| keyCase | Keyword case |
| virtual void highlight::CodeGenerator::setLATEXNoShorthands | ( | bool | ) | [inline, virtual] |
set LaTeX no Babel shorthands flag
Reimplemented in highlight::LatexGenerator.
| virtual void highlight::CodeGenerator::setLATEXPrettySymbols | ( | bool | ) | [inline, virtual] |
set LaTeX pretty Symbols flag
Reimplemented in highlight::LatexGenerator.
| virtual void highlight::CodeGenerator::setLATEXReplaceQuotes | ( | bool | ) | [inline, virtual] |
set LaTeX replace quotes flag
Reimplemented in highlight::LatexGenerator.
| void highlight::CodeGenerator::setLineNumberWidth | ( | int | w | ) |
define line number width
| w | width |
| void highlight::CodeGenerator::setMaxInputLineCnt | ( | unsigned int | cnt | ) |
| cnt | maximum number of input lines to be processed |
| void highlight::CodeGenerator::setPreformatting | ( | WrapMode | lineWrappingStyle, | |
| unsigned int | lineLength, | |||
| int | numberSpaces | |||
| ) |
define the preformatting parameters. Preformatting takes place before the optional astyle reformatting and indenting is performed (defined by initIndentationScheme)
| lineWrappingStyle | wrapping style (WRAP_DISABLED, WRAP_SIMPLE, WRAP_DEFAULT) | |
| lineLength | max line length | |
| numberSpaces | number of spaces which replace a tab |
References preFormatter, highlight::PreFormatter::setNumberSpaces(), highlight::PreFormatter::setReplaceTabs(), highlight::PreFormatter::setWrap(), highlight::PreFormatter::setWrapIndentBraces(), and highlight::PreFormatter::setWrapLineLength().
| void highlight::CodeGenerator::setPrintLineNumbers | ( | bool | flag, | |
| unsigned int | startCnt = 1 | |||
| ) |
output line numbers
| flag | true if line numbers should be printed | |
| startCnt | line number starting count |
References lineNumberOffset, and showLineNumbers.
| void highlight::CodeGenerator::setPrintZeroes | ( | bool | flag | ) |
output line numbers filled with zeroes
| flag | true if zeroes should be printed |
References lineNumberFillZeroes.
| virtual void highlight::CodeGenerator::setRTFCharStyles | ( | bool | ) | [inline, virtual] |
set RTF output character styles flag
Reimplemented in highlight::RtfGenerator.
| virtual void highlight::CodeGenerator::setRTFPageSize | ( | const string & | ) | [inline, virtual] |
set RTF page size
Reimplemented in highlight::RtfGenerator.
| void highlight::CodeGenerator::setStartingNestedLang | ( | const string & | langName | ) |
Define the name of a nested langage which is located at the beginning of input. The opening embedded delimiter is missing, but the closing delimiter must exist.
| langName | name of nested language |
| 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 |
| virtual void highlight::CodeGenerator::setSVGSize | ( | const string & | , | |
| const string & | ||||
| ) | [inline, virtual] |
set SVG page size
Reimplemented in highlight::SVGGenerator.
| void highlight::CodeGenerator::setTitle | ( | const string & | title | ) |
| void highlight::CodeGenerator::setValidateInput | ( | bool | flag | ) |
check if input is binary or text
| flag | true if input should be checked |
| bool highlight::CodeGenerator::styleFound | ( | ) |
References docStyle, and highlight::DocumentStyle::found().
string highlight::CodeGenerator::baseFont [protected] |
The base font to use
Referenced by getBaseFont(), and setBaseFont().
string highlight::CodeGenerator::baseFontSize [protected] |
The base font size to use
Referenced by getBaseFontSize(), and setBaseFontSize().
unsigned int highlight::CodeGenerator::currentKeywordClass [protected] |
keyword class id, used to apply the corresponding keyword style
State highlight::CodeGenerator::currentState [protected] |
Current state
DocumentStyle highlight::CodeGenerator::docStyle [protected] |
Description of document colour style
Referenced by generateFile(), generateString(), generateStringFromFile(), getBaseFontSize(), highlight::HtmlGenerator::getStyleDefinition(), hasWhiteBGColour(), initTheme(), and styleFound().
string highlight::CodeGenerator::docTitle [protected] |
document title
Referenced by getTitle(), and setTitle().
string highlight::CodeGenerator::encoding [protected] |
Encoding name
Referenced by encodingDefined(), highlight::HtmlGenerator::getHeaderStart(), and setEncoding().
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
Referenced by generateFile(), generateString(), generateStringFromFile(), getFragmentCode(), and setFragmentCode().
istream* highlight::CodeGenerator::in [protected] |
file input
Referenced by generateFile(), generateString(), generateStringFromFile(), and processRootState().
bool highlight::CodeGenerator::includeStyleDef [protected] |
Flag to test if style definition should be included in output document
Referenced by printExternalStyle(), and setIncludeStyle().
LanguageDefinition highlight::CodeGenerator::langInfo [protected] |
Language definition
Referenced by getLanguage(), loadLanguage(), printExternalStyle(), and processRootState().
string highlight::CodeGenerator::line [protected] |
Current line of input file
unsigned int highlight::CodeGenerator::lineNumber [protected] |
Current line number
Referenced by getLineNumber(), and processRootState().
bool highlight::CodeGenerator::lineNumberFillZeroes [protected] |
Test if leading spyce of line number should be filled with zeroes
Referenced by getPrintZeroes(), and setPrintZeroes().
int highlight::CodeGenerator::lineNumberOffset [protected] |
output line number count start
Referenced by setPrintLineNumbers().
map<int, string> highlight::CodeGenerator::markLines [protected] |
map which saves all lines that should be highlghted
Referenced by addMarkedLine().
bool highlight::CodeGenerator::maskWs [protected] |
Test if maskWsBegin and maskWsEnd should be applied
CTagsReader highlight::CodeGenerator::metaInfo [protected] |
CTags meta information
Referenced by initTagInformation().
string highlight::CodeGenerator::newLineTag [protected] |
Tag for inserting line feeds
Referenced by getNewLine().
ostream* highlight::CodeGenerator::out [protected] |
file output
Referenced by flushWs(), generateFile(), generateString(), generateStringFromFile(), highlight::BBCodeGenerator::printBody(), and processRootState().
PreFormatter highlight::CodeGenerator::preFormatter [protected] |
Class for line wrapping and tab replacement
Referenced by setPreformatting().
bool highlight::CodeGenerator::printNewLines [protected] |
Flag to test if newlines should be printed
Referenced by getNewLine(), and processRootState().
bool highlight::CodeGenerator::showLineNumbers [protected] |
Test if line numbers should be printed
Referenced by getPrintLineNumbers(), and setPrintLineNumbers().
string highlight::CodeGenerator::spacer [protected] |
String that represents a white space in output
string highlight::CodeGenerator::wsBuffer [protected] |
contains white space, which will be printed after a closing tag
Referenced by flushWs().
1.5.7.1