Source-highlight Library
srchilite::SourceHighlight Class Reference

The main class performing highlighting of an input file generating an output file. More...

#include <sourcehighlight.h>

Collaboration diagram for srchilite::SourceHighlight:

List of all members.

Public Member Functions

 SourceHighlight (const std::string &outputLang="html.outlang")
void initialize ()
 performs initialization of fields, if not already initialized.
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.
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.
void checkLangDef (const std::string &langFile)
 Only check the validity of the language definition file.
void checkOutLangDef (const std::string &langFile)
 Only check the validity of the out language definition file.
void printHighlightState (const std::string &langFile, std::ostream &os)
 Prints the HighlightState corresponding to the language definition file.
void printLangElems (const std::string &langFile, std::ostream &os)
 Prints the language elements corresponding to the language definition file.
const std::string createOutputFileName (const std::string &inputFile)
 Given the input file name creates an output file name.
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)
DocGeneratorgetDocGenerator () const
DocGeneratorgetNoDocGenerator () const
LineRangesgetLineRanges () const
void setLineRanges (LineRanges *lr)
RegexRangesgetRegexRanges () 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).

Private Member Functions

void updateBufferedOutput (BufferedOutput *output)
 Sets the specified buffered output to all the formatters.

Private Attributes

std::string outputLang
 the output language file name
std::string dataDir
 Path for several configuration files.
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
FormatterManagerformatterManager
 the formatter manager
PreFormatterpreFormatter
 the preformatter
TextStyleFormatterCollection formatterCollection
 all the formatters that are created
LangDefManagerlangDefManager
 for loading language definitions
LineNumGeneratorlineNumGenerator
 the generator for line numbers
DocGeneratordocGenerator
 the generator of the start and end of the output document
DocGeneratornoDocGenerator
 the generator of the start and end of the output document when NOT generating an entire document
HighlightEventListenerhighlightEventListener
 The listener for highlight events.
CTagsManagerctagsManager
 the CTagsManager for creating CTagsFormatters
CTagsFormatterctagsFormatter
 the CTagsFormatter for formatting references and anchors
LineRangeslineRanges
 the possible LineRanges (to check which lines should be printed)
RegexRangesregexRanges
 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.

Detailed Description

The main class performing highlighting of an input file generating an output file.


Constructor & Destructor Documentation

srchilite::SourceHighlight::SourceHighlight ( const std::string &  outputLang = "html.outlang")
Parameters:
outputLangthe output lang file (default: html.outlang)

Member Function Documentation

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)

Parameters:
langFile
Exceptions:
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)

Parameters:
langFile
Exceptions:
ParserException
const string srchilite::SourceHighlight::createOutputFileName ( const std::string &  inputFile)

Given the input file name creates an output file name.

Returns:
the output file name
const std::string& srchilite::SourceHighlight::getOutputFileExtension ( ) const [inline]

Returns the file extension for the output file as specified in the output format definition file (initialize must have been called).

Returns:
the output file extension
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.

Parameters:
inputthe input file name, if empty stdin will be used
outputthe output file name, if empty (or equal to STDOUT) the stdout will be used
inputLangthe 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.

Parameters:
inputthe input stream
outputthe output stream
inputLangthe language definition file
inputFileNamethe input file name

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)

Parameters:
langFile
oswhere to print the highlight state
Exceptions:
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)

Parameters:
langFile
oswhere to print the highlight state
Exceptions:
HighlightBuilderException

Sets the specified buffered output to all the formatters.

Parameters:
output

Member Data Documentation

std::string srchilite::SourceHighlight::dataDir [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"


The documentation for this class was generated from the following files: