The main class performing highlighting of an input file generating an output file.
More...
#include <sourcehighlight.h>
Collaboration diagram for srchilite::SourceHighlight:
Public Member Functions
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...
Only check the validity of the language definition file.
More...
Only check the validity of the out language definition file.
More...
Prints the language elements corresponding to the language definition file.
More...
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)
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 setRangeSeparator (const std::string &sep)
void setTabSpaces (unsigned int i)
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
Sets the specified buffered output to all the formatters.
More...
Private Attributes
the output language file name
Path for several configuration files.
More...
the background color
the style file
the css style file
the style defaults file
the prefix for all the output lines
the separator for ranges
the title for the output document (defaults to the source file name)
the input lang for the output document
the value for the css
the file name of the header
the file name of the footer
the file extension for output files
the directory for output files
the formatter manager
the preformatter
all the formatters that are created
for loading language definitions
the generator for line numbers
the generator of the start and end of the output document
the generator of the start and end of the output document when NOT generating an entire document
The listener for highlight events.
the possible
LineRanges (to check which lines should be printed)
the possible
RegexRanges (to check which lines should be printed)
Whether to optmize output (e.g., adiacent text parts belonging to the same element will be buffered and generated as a single text part)
whether to generate line numbers
whether to generate line numbers with references
the prefix for the line number anchors
the line number padding char (default '0')
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)
whether to generate an entire document (default false)
whether to generate the program version in the output file (default=true)
whether we can use stdout for generating the output (default true)
whether to open output files in binary mode (default false)
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
-
outputLang the 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
-
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
-
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
-
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.
- Parameters
-
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)
- Parameters
-
langFile
os where to print the highlight state
- Exceptions
-
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
os where to print the highlight state
- Exceptions
-
void srchilite::SourceHighlight::updateBufferedOutput
(
BufferedOutput *
output )
private
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:
- /home/bettini/work/source-highlight/src-highlite/lib/srchilite/sourcehighlight.h
- /home/bettini/work/source-highlight/src-highlite/lib/srchilite/sourcehighlight.cpp