tablesupport.3bobcat

Langue: en

Version: 318155 (ubuntu - 07/07/09)

Section: 3 (Bibliothèques de fonctions)

NAME

FBB::TableSupport - Defines protocol for Table-support classes

SYNOPSIS

#include <bobcat/tableSupport>
Linking option: -lbobcat

DESCRIPTION

This class is designed as a (non-pure) base class for objects handling some of the functionality of FBB::Table objects. By overriding its virtual functions users have control over the way the actual layout of tables is defined. By default the virtual members of this class implement plain, blank-space delimited table elements.

When this is not appropriate, a class should be derived from FBB::TableSupport overriding those members that violate the programmer's current intentions. Then, an object of this derived class may be presented to one of the FBB::Table constructors, resulting in modifications of the default procedures used to disaplay separators between table elements.

NAMESPACE

FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.

INHERITS FROM

-

PUBLIC TYPE

The type HLine is a struct having the following fields:

 
     size_t d_row;
     size_t d_begin;
     size_t d_end;
         
 
Furthermore, it has a constructor that is defined as follows:
o
HLine(size_t row, size_t begin, size_t end):
This constructor may be used to initialize the struct's values. Objects of type TableSupport::HLine may be inserted into a TableSupport object to indicate what section(s) of a horizontal separator of a table-row should be displayed or skipped (see below at the Type-type description).

PROTECTED TYPES

The following types may be used by classes derived from TableSupport:

o
BeginEnd:
This type represents a std::pair<size_t, size_t>, representing the first column offset for which a horizontal separator should be shown (first) and the first column offset beyond the last column offset to show a separator for. E.g, BeginEnd(2, 5) indicates that a separator should be shown from column 2 until column 4.
o
const_iterator:
The TableSupport::const_iterator is an input-iterator returning pointers to Element structs for all column separators and elements in a table. The first element represents the separator immediately preceding the elements in the table's leftmost column, the last element represents the separator immediately succeeding the elements in the table's rightmost column.
o
Element:
An Element is a struct having two fields: a Type type and a size_t width. The width field defines the size of a column(-separator), type defines its type.
o
Type:
This type has two values: SKIP and USE. The values indicate that a certain part of a row may be left blank or should be using a separator when a horizontal line (hline()) is written.
o
SizeBeginEndMap:
This type represents a std::map<size_t, std::vector<BeginEnd> >. Its key represents a row-separator (0 being the separator above row 0, nRows being the separator beyond the last row). Subsequent BeginEnd elements in its vector values should represent increasing and non overlapping sections of a table .

CONSTRUCTORS

The default constructor and standard copy constructor are available.

OVERLOADED OPERATORS

o
TableSupport &operator<<(TableSupport &support, size_t width):
This operator defines a blank column-separator of width characters. The argument width may be zero, in which case no visible separator is inserted into the table (thus, it can be used to reach the next separator position). The first separator inserted refers to the separator to the left of the table's leftmost column. Subsequent separators separate subsequent columns. At most nColumns + 1 separators can be inserted. Any additional separator that is inserted is ignored.
o
TableSupport &operator<<(TableSupport &support, std::string const &sep):
This operator defines a textual separator. The string may be empty, in which case no visible separator is inserted into the table (thus, it can be used to reach the next separator position). The first separator inserted refers to the separator to the left of the table's leftmost column. Subsequent separators separate subsequent columns. At most nColumns + 1 separators can be inserted. Any additional separator that is inserted is ignored.
o
TableSupport &operator<<(TableSupport &support, HLine const &hsep):
This operator defines a section of a horizontal separator of a specified row which should be displayed. Subsequent insertions of HLine elements referring to the same row should refer to increasing and non overlapping sections of a table. E.g., if support is a TableSupport object, the following insertions indicate that columns 2 until 3 and 5 until 6 of row 7 should have a visible horizontal separator:
 
     support << HLine(7, 2, 4) << HLine(7, 5, 7);
         
 
The overloaded assignment operator is available.

NON_VIRTUAL MEMBER FUNCTIONS

o
void setParam(std::ostream &ostr, size_t nRows, size_t nColumns, std::vector<Align> const &align):
This member function defines the TableSupport object's essential parameters:
ostr is a reference to the std::ostream into which the table will be inserted;
nRows specifies the number of rows used by the table;
nColumns specifies the number of columns if the table;
align is a reference to a constant vector of (column) alignment specifications. This member should normally not be used by the programmer. It is called with appropriate values by FBB::Table objects.
o
size_t width() const:
Returns the width of the table.

VIRTUAL MEMBER FUNCTIONS

The following member functions may be overridden in derived classes. There default implementations are given together with their prototypes, below:

o
virtual void hline(size_t row) const:
This member is called just before the indicated row (offset, not number) is inserted into the std::ostream. Its intended task is to write a (partial) horizontal line either before the first row (row == 0) or between two rows of the table. By default it performs no actions.
o
virtual void hline() const:
This member is called when the table's last line has been inserted into the std::ostream. Its intended task is to write a (partial) horizontal line at the end of the table. By default it calls hline(nRows).
o
virtual void vline(size_t col) const:
This member is called just before the indicated column element (offset, not number) is inserted into the std::ostream. Its intended task is to write a separator either before the first element of a row (col == 0) or between two subsequent elements in the table's rows. By default it inserts separator[col] if if is available. If that separator is not available, no action is performed.
o
virtual void vline() const:
This member is called when the last element of a row has been inserted into the ostr stream. Its intended task is to write a line separator, terminating a line of the table. By default it inserts a new-line (\n) character.

PROTECTED MEMBER FUNCTIONS

The following members are available to classes derived from TableSupport objects, e.g, to be used in overridden hline() or vline() members.

o
std::vector<Align> const &align() const:
This member returns a reference to a vector of Align objects, defining the alignments and widths of the table's columns.
o
const_iterator begin(size_t row) const:
This member returns an iterator returning information about fields to display or ignore in the horizontal separator preceding line row. To obtain the information beyond the last row specify nRows as its argument.
o
size_t colWidth(size_t col) const:
This member returns the width of the indicated column;
o
const_iterator end(size_t row) const:
This member returns an iterator which refers to the location beyond the table's rightmost separator.
o
SizeBeginEndMap const &hlineMap() const:
This member returns a reference to the information defining the visible separatorsections of the table.
o
size_t nColumns() const:
This member returns the number of columns of the table.
o
size_t nRows() const:
This member returns the number of rows of the table.
o
std::ostream &out() const:
This member returns a reference to the stream into which the table is inserted.
o
std::vector<std::string> const &sep():
This member returns a reference to the separators that are defined for the table's columns. Element 0 refers to the separator to the left of the leftmost table column, element nColumns refers to the separator to the right of the rightmost table column.
o
size_t sepWidth(size_t col) const:
This member returns the width of the indicated separator. Index value 0 refers to the separator before the table's leftmost column, index value nColumns() refers to the separator to the right of the table's rightmost column.

EXAMPLE

See the example in the table(3bobcat) man-page.

FILES

bobcat/tableSupport - defines the class interface

SEE ALSO

bobcat(7), align(3bobcat), table(3bobcat)

BUGS

None Reported.

DISTRIBUTION FILES

o
bobcat_2.00.1-x.dsc: detached signature;
o
bobcat_2.00.1-x.tar.gz: source archive;
o
bobcat_2.00.1-x_i386.changes: change log;
o
libbobcat1_2.00.1-x_i386.deb: debian package holding the libraries;
o
libbobcat1-dev_2.00.1-x_i386.deb: debian package holding the libraries, headers and manual pages;
o
http://sourceforge.net/projects/bobcat: public archive location;

BOBCAT

Bobcat is an acronym of `Brokken's Own Base Classes And Templates'. This is free software, distributed under the terms of the GNU General Public License (GPL).

AUTHOR

Frank B. Brokken (f.b.brokken@rug.nl).