YGP::TableWriter Class Reference

Baseclass to write tabular information. More...

List of all members.

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


Detailed Description

Baseclass to write tabular information.

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.


Constructor & Destructor Documentation

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.

Parameters:
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
Note:
All passed values must be preserved during the life-time of the object. This is especially important for the format parameter! Make sure to not pass a temporary object!

YGP::TableWriter::~TableWriter (  )  [virtual]

Destructor.


Member Function Documentation

std::string YGP::TableWriter::changeHTMLSpecialChars ( const std::string &  value  )  [static]

Changes the HTML special characters quote ("), ampersand (&), apostrophe ('), less (<) and greater (>) to HTML-values.

Parameters:
value String to change
Returns:
std::string Changed string

std::string YGP::TableWriter::changeHTMLSpecialFileChars ( const std::string &  value  )  [static]

Changes the blank in filenames to 20.

Parameters:
value String to change
Returns:
std::string Changed string

std::string YGP::TableWriter::changeLaTeXSpecialChars ( const std::string &  value  )  [static]

Changes the LaTeX special characters quote ("), ampersand (&), apostrophe ('), less (<) and greater (>) to HTML-values.

Parameters:
value String to change
Returns:
std::string Changed string

std::string YGP::TableWriter::changeQuotedSpecialChars ( const std::string &  value  )  [static]

Changes the LaTeX special characters quote ("), ampersand (&), apostrophe ('), less (<) and greater (>) to HTML-values.

Parameters:
value String to change
Returns:
std::string Changed string

unsigned int YGP::TableWriter::columns (  )  const [protected]

Counts the number of columns.

Returns:
unsigned int Number of columns

std::string YGP::TableWriter::getNextNode (  )  [protected]

Returns the next token; special characters are expanded.

Returns:
std::string Next (expanded) token

std::string YGP::TableWriter::getSubstitute ( char  ctrl,
bool  extend = false 
) const [protected, virtual]

Returns the substitute for a control character.

Parameters:
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.

Parameters:
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.

Parameters:
Stream where to put the output

void YGP::TableWriter::printHeaderTail ( std::ostream &  out  )  const [virtual]

Prints something at the end of the table-header.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
out Stream where to put the output
title Title information; the columns must be seperated by an (|)


Member Data Documentation

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.


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

YGP Version 0.9.31 - Generated on Wed Nov 18 11:25:28 2009 by doxygen 1.5.8