FBB::TableSupport(3bobcat)
Table Support Base class
(libbobcat-dev_4.08.03-x.tar.gz)
2005-2018
NAME
FBB::TableSupport - Defines protocols 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 and FBB::TableBuf 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
do not separate the columns of the table from each other
The Bobcat library offers the specialized class TableLines extending the
basic facilities of TableSupport by allowing rows to be separated from
each other by (partial) horizontal lines (see the tablelines(3bobcat)
man-page for a description).
When more specialized handling is required a class should be derived from
FBB::TableSupport overriding those members that violate the programmer's
current intentions. An object of this derived class may be presented to a
FBB::Table or FBB::TableBuf constructor, to activate the special
handling.
NAMESPACE
FBB
All constructors, members, operators and manipulators, mentioned in this
man-page, are defined in the namespace FBB.
INHERITS FROM
-
ENUMERATION
The enum ColumnType defines the following values (see also the
description of the struct HLine, below):
- SKIP:
a section of a row-separating line should remain empty. This
value is normally not used by applications;
- USE:
a section of a row-separating line should be used (e.g., by
writing a (horizontal) line);
- LEFT_FULL:
a (horizontal) line should be written over the total width
of the separator to the left of a series of columns
- RIGHT_FULL:
a (horizontal) line should be written over the total width
of the separator to the right of a series of columns;
- LEFT_MID:
a (horizontal) line should be written over the right-half
part of the width of the separator to the left of a series of
columns; the left-hand part remains blank;
- RIGHT_MID:
a (horizontal) line should be written over the left-half
part of the width of the separator to the right of a series of
columns; the right-hand part remains blank;
The value SKIP should always be used by itself; remaining values of
the enum may be combined using the binary or (|) operator.
PUBLIC TYPE
- struct HLine:
This struct has the following fields:
size_t d_row;
size_t d_begin;
size_t d_end;
size_t d_type;
It offers two constructors:
- HLine(size_t row, size_t begin, size_t end):
- HLine(ColumnType type, size_t row, size_t begin, size_t end):
Objects of type TableSupport::HLine may be inserted into a
TableSupport object to indicate section(s) of a horizontal separator
between table rows that should be displayed or skipped. E.g., to specify that
a separator should be written in row 1 between columns 2 up to (not including)
5, extending the separator to the left by half the width of the separator
between columns 1 and 2 and to the right by the full width of the separator
between columns 4 and 5 the following HLine object should be inserted into
the TableSupport ts object:
ts << HLine(LEFT_MID | RIGHT_FULL, 1, 2, 5);
Multiple HLine objects may be inserted into a TableSupport object,
their ordering is irrelevant. When column ranges overlap then their
ColumTypes are merged.
PROTECTED TYPES
- const_iterator:
This type is defined in the class's protected
section. TableSupport::const_iterator is an input-iterator returning
pointers to struct Field (see below) objects for table columns and column
separators (see below at the begin and end members)
- struct Field:
This type has two data members: width and type, representing,
respectively, the width and ColumnType of a column or
separating column. Although column types can be combined when inserting them
using HLine objects, type values of Field objects returned by
TableSupport members only contain single values (like SKIP or
LEFT_MID).
CONSTRUCTORS
The default, copy and move constructors are available.
OVERLOADED OPERATORS
- TableSupport &operator<<(TableSupport &support, size_t width):
This operator defines a column-separator of width space
characters. The argument width may be zero, in which case no visible
separator is used. 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 sensibly be inserted.
Additional separators are ignored when a table is inserted into an
ostream.
- TableSupport &operator<<(TableSupport &support,
std::string const &sep):
This operator defines a separator as a piece of text. The string may
be empty, in which case no visible separator is inserted into the table. The
first separator inserted refers to the separator to the left of the table's
leftmost column. Subsequent separators separate subsequent columns. Textual
and numeric separator may be intermixed. At most nColumns + 1 separators
can sensibly be inserted. Additional separators are ignored when a table is
inserted into an ostream.
- TableSupport &operator<<(TableSupport &support, HLine const &hsep):
This operator defines how a section of a horizontal separator of a
specified row should be displayed (see the description of ColumnType in
the ENUMERATION section).
The overloaded copy and move assignment operators are available.
PUBLIC MEMBER FUNCTIONS
- void hline(size_t row) const:
When inserting a table into a std::ostream Table and
TableBuf objects call this member just before the indicated row (offset)
is inserted into a std::ostream. It calls v_hline, passing it row.
- void hline() const:
When inserting a table into a std::ostream Table and
TableBuf objects call this member just after inserting the table's final
row. It calls v_hline without arguments.
- void setParam(std::ostream &ostr, size_t nRows, size_t nColumns,
std::vector<Align> const &align):
This member provides the TableSupport object with values that are
essential for its proper functioning. It is called from the Table and
TableBuf's def member or manipulator. A TableSupport object can
be used before that to specify widths and types of separators, though. This
member's parameters are initialized by the Table and TableBuf class
objects as follows:
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.
- void vline(size_t col) const:
When inserting the data elements of the rows of a table into a
std::ostream Table and TableBuf objects call this member just
before inserting the data elements of column col. Its intended task is to
write a column separator just before the data elements themselves. It calls
v_vline passing it its col parameter.
- virtual void vline() const:
When inserting a table into a std::ostream Table and
TableBuf objects call this member after inserting the data elements of the
rows of the table. It is called at the end of each row. It calls v_vline
without arguments.
- size_t width() const:
Returns the total width of the table.
PROTECTED MEMBER FUNCTIONS
The following members are available to classes derived from
TableSupport. Except for sep and sepWidth their values are only
defined after setParam has been called. This latter function is called
from the def member or manipulator of Table or TableBuf objects.
VIRTUAL MEMBER FUNCTIONS
The following member functions can be overridden by derived classes to
redefine the way horizontal and vertical separators are displayed.
- virtual void v_hline(size_t row) const:
This member is called from hline(size_t row), receiving its row
parameter. Its task is to write a horizonal separator for row row. By
default nothing is inserted. It may do so by iterating over the range defined
by the begin and end members, deciding what to do on the basis of the
Field objects referred to by the iterators.
- virtual void v_hline() const:
This member is called from hline(). Its intended task is to write
a (partial) horizontal line beyond the table's last line of data elements. By
default it calls hline(nRows).
- virtual void v_vline(size_t col) const:
This member is called from vline(size_t col), receiving its
col parameter. Its task is to write a separator before data column
col. By default it inserts separator[col] if if is available. If that
separator is not defined, no action is performed.
- virtual void v_vline() const:
This member is called from vline(). Its intended task is to write
a column separator, terminating a line of the table. By default it inserts a
new-line (\n) character.
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),
tablebuf(3bobcat), tablelines(3bobcat)
BUGS
None Reported.
DISTRIBUTION FILES
- bobcat_4.08.03-x.dsc: detached signature;
- bobcat_4.08.03-x.tar.gz: source archive;
- bobcat_4.08.03-x_i386.changes: change log;
- libbobcat1_4.08.03-x_*.deb: debian package holding the
libraries;
- libbobcat1-dev_4.08.03-x_*.deb: debian package holding the
libraries, headers and manual pages;
- http://sourceforge.net/projects/bobcat: public archive location;
BOBCAT
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.
COPYRIGHT
This is free software, distributed under the terms of the
GNU General Public License (GPL).
AUTHOR
Frank B. Brokken (f.b.brokken@rug.nl).