Public Member Functions | |
TableWriter (const std::string &format, const char *startRow="", const char *endRow="", const char *sepColumn=" ", const char *startTab="", const char *endTab="", const char *sepTab=" ", const char *rowStartHdr=NULL, const char *rowEndHdr=NULL, const char *sepHdrCol=NULL, const char *defColumns=NULL) | |
virtual | ~TableWriter () |
void | printStart (std::ostream &out, const std::string &title) const |
void | printEnd (std::ostream &out) const |
virtual void | printHeaderLead (std::ostream &out) const |
virtual void | printHeaderTail (std::ostream &out) const |
Static Public Member Functions | |
static std::string | changeQuotedSpecialChars (const std::string &val) |
static std::string | changeHTMLSpecialChars (const std::string &val) |
static std::string | changeHTMLSpecialFileChars (const std::string &val) |
static std::string | changeLaTeXSpecialChars (const std::string &val) |
Protected Member Functions | |
unsigned int | columns () const |
std::string | getNextNode () |
virtual std::string | getSubstitute (char ctrl, bool extend=false) const |
Static Protected Member Functions | |
static void | printLaTeXHeaderLead (std::ostream &out, unsigned int columns) |
static void | printLaTeXHeaderLead (std::ostream &out, const char *columns) |
Protected Attributes | |
const char * | rowStart |
const char * | rowEnd |
const char * | colSeparator |
const char * | tabStart |
const char * | tabEnd |
const char * | tabHeader |
const char * | rowHdrStart |
const char * | rowHdrEnd |
const char * | colHdrSeparator |
const char * | colDefinitions |
The format of the table is specified at construction time as a string of column values, separated by the pipe symbol (|).
Within those column-values a substitution can be performed (to be implemented by derived classes) by x (simple substitution) or *x (extended substitution) control sequences (the default action is to simply remove those characters).
The difference between simple and extended substitution depends on the implementing classes; e.g. a class could decide to substitute d with a date and *d with date and time.
The whole table can have a leading header (similar specified as a list of values, separated by the pipe symbol (|)).
It is possible to iterate over the columns with the getNextNode, which returns exactly that: The next column, in which control sequences have already been substituted.
There are some defines to declare table-writers for popular SGMLs. To write a table in HTML, declare a TableWrite like this:
YGP::TableWriter htmlWriter ("<Your format>", TBLW_HTML_PARAMS);
Similar macros exists for XML, LaTeX, Text and QuotedText writers.
YGP::TableWriter::TableWriter | ( | const std::string & | format, | |
const char * | startRow = "" , |
|||
const char * | endRow = "" , |
|||
const char * | sepColumn = " " , |
|||
const char * | startTab = "" , |
|||
const char * | endTab = "" , |
|||
const char * | sepTab = " " , |
|||
const char * | startRowHdr = NULL , |
|||
const char * | endRowHdr = NULL , |
|||
const char * | sepHdrCol = NULL , |
|||
const char * | defColumns = NULL | |||
) |
Constructor.
format | Format how to display entries (Don't pass a temporary object!) | |
startRow | String starting rows | |
endRow | String terminating rows | |
sepColumn | String separating columns | |
startTab | String starting table | |
endTab | String terminating table | |
sepTab | String separating the tableheader from the tablebody | |
startRowHdr | String starting header of the table | |
endRowHdr | String terminating header of the table | |
sepHdrCol | String terminating columns of the header of the table | |
defColumns | Definition of the columns |
YGP::TableWriter::~TableWriter | ( | ) | [virtual] |
Destructor.
std::string YGP::TableWriter::changeHTMLSpecialChars | ( | const std::string & | value | ) | [static] |
Changes the HTML special characters quote ("), ampersand (&), apostrophe ('), less (<) and greater (>) to HTML-values.
value | String to change |
std::string YGP::TableWriter::changeHTMLSpecialFileChars | ( | const std::string & | value | ) | [static] |
Changes the blank in filenames to 20.
value | String to change |
std::string YGP::TableWriter::changeLaTeXSpecialChars | ( | const std::string & | value | ) | [static] |
Changes the LaTeX special characters quote ("), ampersand (&), apostrophe ('), less (<) and greater (>) to HTML-values.
value | String to change |
std::string YGP::TableWriter::changeQuotedSpecialChars | ( | const std::string & | value | ) | [static] |
Changes the LaTeX special characters quote ("), ampersand (&), apostrophe ('), less (<) and greater (>) to HTML-values.
value | String to change |
unsigned int YGP::TableWriter::columns | ( | ) | const [protected] |
Counts the number of columns.
std::string YGP::TableWriter::getNextNode | ( | ) | [protected] |
Returns the next token; special characters are expanded.
std::string YGP::TableWriter::getSubstitute | ( | char | ctrl, | |
bool | extend = false | |||
) | const [protected, virtual] |
Returns the substitute for a control character.
ctrl | Control character | |
Flag,if | special formatting of substitute is wanted |
void YGP::TableWriter::printEnd | ( | std::ostream & | out | ) | const |
Prints the end of a generic table.
out | Stream where to put the output |
void YGP::TableWriter::printHeaderLead | ( | std::ostream & | out | ) | const [virtual] |
Prints something at the start of the table-header.
Stream | where to put the output |
void YGP::TableWriter::printHeaderTail | ( | std::ostream & | out | ) | const [virtual] |
Prints something at the end of the table-header.
Stream | where to put the output |
void YGP::TableWriter::printLaTeXHeaderLead | ( | std::ostream & | out, | |
const char * | columns | |||
) | [static, protected] |
Prints the columns at the start of a LaTeX table.
out | Stream where to put the output | |
columns | String describing the columns |
void YGP::TableWriter::printLaTeXHeaderLead | ( | std::ostream & | out, | |
unsigned int | columns | |||
) | [static, protected] |
Prints the columns at the start of a LaTeX table.
out | Stream where to put the output | |
columns | Number of columns |
void YGP::TableWriter::printStart | ( | std::ostream & | out, | |
const std::string & | title | |||
) | const |
Prints the start of a generic table.
out | Stream where to put the output | |
title | Title information; the columns must be seperated by an (|) |
const char* YGP::TableWriter::colDefinitions [protected] |
Text to define the columns.
const char* YGP::TableWriter::colHdrSeparator [protected] |
Text separting the columns of the header.
const char* YGP::TableWriter::colSeparator [protected] |
Text separting the columns of the table.
const char* YGP::TableWriter::rowEnd [protected] |
Text to end a row.
const char* YGP::TableWriter::rowHdrEnd [protected] |
Text to end a row in the header.
const char* YGP::TableWriter::rowHdrStart [protected] |
Text to start a row in the header.
const char* YGP::TableWriter::rowStart [protected] |
Text for starting a row.
const char* YGP::TableWriter::tabEnd [protected] |
Text ending the table.
const char* YGP::TableWriter::tabHeader [protected] |
Text starting the heaer of the table.
const char* YGP::TableWriter::tabStart [protected] |
Text starting the table.