Provided by: libbobcat-dev_4.08.02-2build1_amd64
FBB::TableSupport - Defines protocols for Table-support classes
#include <bobcat/tableSupport> Linking option: -lbobcat
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.
FBB All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.
The enum ColumnType defines the following values (see also the description of the struct HLine, below): o SKIP: a section of a row-separating line should remain empty. This value is normally not used by applications; o USE: a section of a row-separating line should be used (e.g., by writing a (horizontal) line); o LEFT_FULL: a (horizontal) line should be written over the total width of the separator to the left of a series of columns o RIGHT_FULL: a (horizontal) line should be written over the total width of the separator to the right of a series of columns; o 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; o 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.
o 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: o HLine(size_t row, size_t begin, size_t end): o 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.
o 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) o 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).
The default, copy and move constructors are available.
o 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. o 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. o 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
o 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. o 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. o 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. o 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. o 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. o 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. o std::vector<Align> const &align() const: A reference to a vector of Align objects, defining the alignments and widths of the table’s columns is returned. o const_iterator begin(size_t row) const: An iterator returning information about the first column element when displaying the horizontal separator preceding line row is returned. To obtain the information about the separator beyond the last row nRows() should be used as its argument. The `column elements’ of the table are its separators and data columns. Dereferencing the returned const_iterator provides access to a Field struct defining the type and width of a column element. Dereferencing the iterator returned by begin provides information about the leftmost column separator. By incrementing the iterator all subsequent column elements are visited. The iterator’s value becomes undefined once it reaches the value returned by end (see below). o size_t colWidth(size_t col) const: The width of the indicated column is returned. o const_iterator end(size_t row) const: An iterator indicating the end of the iterator range starting at begin(row) is returned. o size_t nColumns() const: The number of columns of the table is returned. o size_t nRows() const: The number of rows of the table is returned. o std::ostream &out() const: A reference to the stream into which the table is inserted is returned. o std::vector<std::string> const &sep(): A reference to the separators that are defined for the table’s columns is returned. Element col refers to the separator to the left of the table column col, element nColumns() refers to the separator to the right of the rightmost table column. o size_t sepWidth(size_t col) const: The width of the indicated separator is returned. Element col refers to the separator to the left of the table column col, element nColumns() refers to the separator to the right of the rightmost table column.
VIRTUAL MEMBER FUNCTIONS
The following member functions can be overridden by derived classes to redefine the way horizontal and vertical separators are displayed. o 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. o 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). o 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. o 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.
See the example in the table(3bobcat) man-page.
bobcat/tableSupport - defines the class interface
bobcat(7), align(3bobcat), table(3bobcat), tablebuf(3bobcat), tablelines(3bobcat)
o bobcat_4.08.02-x.dsc: detached signature; o bobcat_4.08.02-x.tar.gz: source archive; o bobcat_4.08.02-x_i386.changes: change log; o libbobcat1_4.08.02-x_*.deb: debian package holding the libraries; o libbobcat1-dev_4.08.02-x_*.deb: debian package holding the libraries, headers and manual pages; o http://sourceforge.net/projects/bobcat: public archive location;
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).
Frank B. Brokken (firstname.lastname@example.org).