includefile(include/header)

COMMENT(manpage, section, releasedate, archive, short name)
manpage(FBB::Table)(3bobcat)(_CurYrs_)(libbobcat-dev__CurVers_)
                    (Table-formatter)

manpagename(FBB::Table)(Generates row- or column-wise filled tables)

manpagesynopsis()
    bf(#include <bobcat/table>)nl()
    Linking option: tt(-lbobcat)

manpagedescription()

    bf(FBB::Table) objects can be used to create tables. Tables are filled
either column- or row-wise. Many of the table's characteristics may be
fine-tuned using a separate bf(FBB::TableSupport) object (cf.
bf(tablesupport)(3bobcat)). When no bf(FBB::TableSupport) object is used, a
plain table, filled row-wise or column-wise, is constructed which can be
inserted into a bf(std::ostream).

    Tables defined by tt(Table) consist of rows and a fixed number of
columns. The number of columns is specified at construction time, the number
of rows also depends on the number of inserted elements. Columns and rows are
addressed using indices (starting at 0). Before the leftmost column, between
the columns and beyond the last column em(separators) are defined. By default
these separators are empty, but each separator may be given a (fixed) width or
content. The separator before column tt(col) is addressed as separator
tt(col), the rightmost separator is addressed as separator tt(nColummns).

Rows can also be separated from each other using separators. These separating
rows are empty by default. The row-separator before row tt(row) is addressed
as row-separator tt(row). The row-separator following the final row is
addressed as row-separator tt(nRows), where tt(nRows) is the value returned by
the tt(nRows) member function.

Non-default (i.e., non-empty) separators are defined using
tt(FBB::TableSupport) objects (cf. bf(tablesupport)(3bobcat)).

    tt(Table) objects look a lot like tt(ostream) objects, using a simple way
to define new elements: each new insertion defines another table element, and
it is difficult to end a row before it has received its tt(nColumn) number of
elements. tt(Table)'s sister-class, tt(TableBuf), is a tt(std::streambuf) type
of class, offering additional control through the use of a wrapping
tt(ostream) class object.

includefile(include/namespace)

manpagesection(INHERITS FROM)

    bf(std::ostringstream) - tt(Table) inherits from bf(std::ostringstream),
allowing insertions into a bf(Table) object. Each separate insertion adds
another element to the bf(Table) object.

    bf(FBB::TableBase) - This class implements common elements of the table
implementation. The tt(TableBase) class is not intended to be used by itself,
and no separate man-page is provided. Facilities provided by tt(Table)
which were inherited from tt(TableBase) are described in this man-page.

manpagesection(ENUMERATIONS)
    The following enumerations are defined by the class bf(FBB::Table):
    bf(enum FillDirection)nl()
    This enumeration defines two values:
    itemization(
    itb(ROWWISE)
       When this value is specified at construction time, elements are added
        row-wise to the table. I.e., the second element inserted into the
        tt(Table) will be found in the second column of the first row;
    itb(COLUMNWISE)
       When this value is specified at construction time, elements are added
        column-wise to the table. I.e., the second element is found in
        the second row of the first column.
    )

    bf(enum WidthType)nl()
    This enumeration defines two values:
    itemization(
    itb(COLUMNWIDTH)
       Specify this value when the columns may have variable widths. In this
        case each column will be as wide as its widest element. This is the
        default tt(WidthType) used by tt(Table) objects.
    itb(EQUALWIDTH)
       Specify this value when all of the table's columns must have equal
        widths (i.e., equal to the width of the widest table element),
    )

manpagesection(CONSTRUCTORS)
    itemization(
    itb(Table(size_t nColumns, Table::FillDirection direction,
            Table::WidthType widthType = Table::COLUMNWIDTH))
       The table's number of columns, the fill directions and the column
        width-type must be provided.  The number of rows is implied by the
        combination of this parameter and the number of elements that is
        actually inserted into the tt(Table) object.  The tt(direction)
        parameter specifies the way new elements are added to the tt(Table)
        object: row-wise or column-wise. Finally, the tt(widthType) parameter
        is used to specify the way the width of the table's columns is
        determined. Each column either defines its own width or all columns
        have equal widths.
    itb(Table(TableSupport &tableSupport, size_t nColumns,
            Table::FillDirection direction,
            Table::WidthType widthType = Table::COLUMNWIDTH))
       This constructor operates identically to the previous constructor, but
        expects an additional reference to a tt(TableSupport) object. A
        tt(TableSupport) object offers additional formatting features used by
        the table defining elements like horizontal lines between rows,
        additional separators, etc, etc. The tt(TableSupport) object is passed
        as a non-const reference as the tt(Table) object must be able to
        manipulate its data. See bf(tablesuppport)(3bobcat) for more
        information about tt(TableSupport).
    )

    Copy and move constructors (and assignment operators) are not available.

manpagesection(OVERLOADED OPERATORS)

    itemization(
    itb(std::ostream &operator<<(std::ostream &str, Table &table))
       This operator inserts a tt(Table) into a tt(std::ostream) object.  This
        operator requires a non-const table as it may have to complete the
        table by adding empty elements (i.e., empty strings) to obtain a
        completely filled rectangular table;
    itb(Table &operator<<(Table &obj, Align const &align))
       This operator changes the default alignment of either a column or an
        element. It is a wrapper around the member tt(setAlign) (see below
        for its description). By default, all elements are right-aligned (see
        also bf(align)(3bobcat));
    itb(Table &operator<<(Table &obj, Type const &item))
       This operator is defined as a function template: tt(Type) is a template
        type parameter instantiated to a type for which tt(std::ostringstream)
        insertions are possible.  It inserts the value/object tt(item) into
        the tt(Table)'s tt(std::ostringstream) base class object as the
        table's next element.
    )

manpagesection(MEMBER FUNCTIONS)
    itemization(
    itb(Table &append(std::string const &text
                 char const *sep = " \t", bool addEmpty = false))
       Fields in tt(text) separated by one of the characters in tt(sep) are
        added as elements to the tt(Table) object. Empty fields are ignored
        unless the parameter tt(addEmpty) is tt(true);
    itb(void clear())
       The content of the table is erased;
    itb(void clearStr())
       The content of its tt(std::ostringstream) base class buffer is erased;
    itb(Table &CHAR(d)ef())
       After inserting elements into a tt(Table) object its number of elements
        may or may not be an integral multiple of the number of columns
        specified at construction time. To `complete' a tt(Table) object to a
        rectangular object, for which all column widths and alignments have
        been determined tt(def) can be called. It is automatically
        called by tt(operator<<(ostream, Table)). In other situations it may
        be called explicitly to force the insertion of another row in a table
        using tt(ROWWISE) insertions. With tt(COLUMNWISE) insertions its
        working is complex, since new elements added to a tt(COLUMNWISE)
        filled table will reshuffle its elements over the table's columns;
    itb(void fill(InputIterator begin, InputIterator end))
       This member is defined as a member template; tt(InputIterator) is a
        template type parameter representing any input iterator. It can also
        be, e.g., a pointer to an insertable type. The iterators must point to
        data elements which can be inserted into an tt(std::ostream). The
        range of values implied by the member's iterator pair are inserted
        into the table as new elements;
    itb(void push_back(std::string const &element))
       New elements can be added to the table using tt(push_back). It could
        e.g., be called from a tt(back_inserter) adaptor);
    itb(size_t nRows())
       The table's current number of rows is returned. It is initialized to 0,
        and after that updated when tt(def) has been called;
    itb(Table &setAlign(Align const &align))
       The alignment type of either a column or an element of the tt(Table)
        object is defined using tt(setAlign). The standard alignments
        tt(std::left, std::right) and tt(std::internal) may be specified, but
        in addition the alignment tt(FBB::center) may be used if elements
        should be centered into their column. A construction like 
       verb(tab << Align(2, FBB::center))
       requests centering of all elements in the table's column having index
        value 2 (i.e., the table's 3rd column), whereas a construction like
       verb(tab << Align(2, 3, FBB::center))
       requests centering of element [2][3]. It is the responsibility of the
        programmer to ensure that such elements exist. By default, all
        elements are right-aligned.
    )

manpagesection(MANPULATORS)
    itemization(
    itb(Table &CHAR(d)ef(Table &table))
       This manipulator can be inserted into a table to call the table's
        tt(def) member.
    )

manpagesection(EXAMPLE)

    verbinclude(../../table/driver/driver.cc)

manpagefiles()
    em(bobcat/table) - defines the class interface;nl()

manpageseealso()
    bf(bobcat)(7), bf(align)(3bobcat), bf(csvtable)(3bobcat),
    bf(manipulator)(3bobcat), bf(tablebuf)(3bobcat), bf(tablelines)(3bobcat),
    bf(tablesupport)(3bobcat)

manpagebugs()
    Note that tt(CHAR(d)ef()) will reshuffle elements over the table's
columns when new elements are added to the table subsequent to calling
tt(CHAR(d)ef())

includefile(include/trailer)
