FBB::Table(3bobcat)

πŸŽ€ FBB::Table β€” the bobcat manual page, section 3 πŸŽ€

okay bestie sit down, hydrate, because we're doing tables today and I need you to be SO locked in πŸ’– This is the FBB::Table(3bobcat) page, part 1, and it's giving serious main-character Unix energy. Let's go.


✨ NAME ✨

FBB::Table β€” generates row- or column-wise filled tables πŸ¦‹


✨ SYNOPSIS ✨

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

✨ DESCRIPTION ✨

okay so, FBB::Table objects make tables. That's it, that's the vibe πŸ‘‘ Tables get filled either column-wise or row-wise, your choice. And you can fine-tune basically every little characteristic using a separate FBB::TableSupport object (cf. tablesupport(3bobcat)). And if you don't bother with a FBB::TableSupport object at all? You get a plain table, filled row-wise or column-wise, that you can insert straight into a std::ostream. No notes. ✨

Tables defined by Table consist of rows and a fixed number of columns. The number of columns gets specified at construction time. The number of rows? That also depends on how many elements you actually insert. Columns and rows are addressed using indices β€” and those start at 0, bestie, not 1 πŸ™ˆ

Separators are defined before the leftmost column, between the columns, and beyond the last column. By default these separators are empty (sad, boring, empty), but each separator may be given a (fixed) width or content. The separator before column col is addressed as separator col, and the rightmost separator is addressed as separator nColummns. 🫢

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

Non-default (i.e., non-empty) separators get defined using FBB::TableSupport objects (cf. tablesupport(3bobcat)). Not me using the plain-object constructor and getting zero separators… couldn't be me πŸ’€

Table objects look a lot like ostream objects, and they use a super simple way to define new elements: each new insertion defines another table element. The catch? It's genuinely difficult to end a row before it has received its nColumn number of elements. That's just the rules πŸ’…

Table's sister class, TableBuf, is a std::streambuf type of class, and it offers additional control through the use of a wrapping ostream class object. Sister supremacy, we love to see it 🌸


✨ NAMESPACE ✨

FBB

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


✨ INHERITS FROM ✨

  • std::ostringstream β€” Table inherits from std::ostringstream, which is lowkey the whole reason you can insert into a Table object. Each separate insertion adds another element to the Table object. πŸŽ€
  • FBB::TableBase β€” this class implements common elements of the table implementation. Heads up: the TableBase class is not intended to be used by itself, and no separate man-page is provided for it. Facilities provided by Table which were inherited from TableBase are described in this man-page. iykyk πŸ’œ

✨ ENUMERATIONS ✨

The following enumerations are defined by the class FBB::Table:

enum FillDirection

This enumeration defines two values:

  • ROWWISE β€” specify this value at construction time and elements get added row-wise to the table. I.e., the second element inserted into the Table will be found in the second column of the first row. ✨
  • COLUMNWISE β€” specify this value at construction time and elements get added column-wise to the table. I.e., the second element is found in the second row of the first column. πŸ¦‹

enum WidthType

This enumeration defines two values:

  • 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 WidthType used by Table objects. πŸ‘‘
  • 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). 🌈

✨ CONSTRUCTORS ✨

  • 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 Table object. The direction parameter specifies the way new elements are added to the Table object: row-wise or column-wise. Finally, the 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. πŸ’…
  • 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 TableSupport object. A TableSupport object offers additional formatting features used by the table defining elements like horizontal lines between rows, additional separators, etc, etc. The TableSupport object is passed as a non-const reference, because the Table object must be able to manipulate its data. See tablesuppport(3bobcat) for more information about TableSupport. 🫢

Copy and move constructors (and assignment operators) are not available. πŸ™ˆ


✨ OVERLOADED OPERATORS ✨

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

✨ MEMBER FUNCTIONS ✨

  • Table &append(std::string const &text char const *sep = " \t", bool addEmpty = false) β€” fields in text separated by one of the characters in sep are added as elements to the Table object. Empty fields are ignored β€” unless the addEmpty parameter is true. πŸŽ€
  • void clear() β€” the content of the table is erased. poof πŸ’€
  • void clearStr() β€” the content of its std::ostringstream base class buffer is erased.
  • Table &def() β€” after inserting elements into a 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 Table object to a rectangular object, for which all column widths and alignments have been determined, def can be called. It is automatically called by operator<<(ostream, Table). In other situations it may be called explicitly to force the insertion of another row in a table using ROWWISE insertions. With COLUMNWISE insertions its working is complex, since new elements added to a COLUMNWISE filled table will reshuffle its elements over the table's columns. πŸ‘€
  • void fill(InputIterator begin, InputIterator end) β€” this member is defined as a member template; 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 std::ostream. The range of values implied by the member's iterator pair are inserted into the table as new elements. 🌈
  • void push_back(std::string const &element) β€” new elements can be added to the table using push_back. It could, e.g., be called from a back_inserter adaptor. πŸ¦‹
  • size_t nRows() β€” the table's current number of rows is returned. It is initialized to 0, and after that updated when def has been called. ✨
  • Table &setAlign(Align const &align) β€” the alignment type of either a column or an element of the Table object is defined using setAlign. The standard alignments std::left, std::right and std::internal may be specified, but in addition the alignment FBB::center may be used if elements should be centered into their column. A construction like
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

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. ) β€” yes, the original page leaves a lil orphan ) there, and honestly? iconic, we're keeping her. πŸ’…


πŸ’… MANPULATORS πŸ’…

(yes bestie, that's genuinely how the section is spelled in the original page, and we are NOT fixing her, she's doing great)
  • Table &def(Table &table) β€” this manipulator can be inserted into a table to call the table's def member. 😌

✨ EXAMPLE ✨

#include <iostream>

#include <bobcat/table>
#include <bobcat/tablelines>

using namespace std;
using namespace FBB;

int main(int argc, char **argv)
{
    TableLines tablelines;
                                // width/separators of cols 0, 1 and 2
    tablelines << 0 << " | " << " | ";

                                // hline over cols 1 and 2 of row 1
    tablelines << TableLines::HLine(1, 1, 3);

    Table tab(tablelines, 3, Table::ROWWISE, Table::EQUALWIDTH);
    // or: Table tab(tablelines, 3, Table::ROWWISE);

    tab << Align(0, std::left);     // set column non-default alignment
    tab.fill(argv + 1, argv + argc);// fill range of values

    cout << tab << ’\n’;            // complete the table and insert

    tab << "hello" << "" << "wo";   // add additional elements.
    if (tab.nRows() > 2)
        tab << Align(2, 2, center); // set the layout of a specific element

    cout << tab << ’\n’;
}

like?? she's beauty, she's grace, she's filling argv into a table 😭🫢


✨ FILES ✨

  • bobcat/table β€” defines the class interface; πŸŽ€

✨ SEE ALSO ✨

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


✨ BUGS ✨

Note that def() will reshuffle elements over the table's columns when new elements are added to the table subsequent to calling def(). Not a drill, bestie β€” she will literally move your stuff around. πŸ’€

okay and that's part 1, but we are SO not done here β€” part 2 is coming and it has more of the goods, so stay seated, keep your -lbobcat linked, and hydrate πŸ’–βœ¨

🌈 BOBCAT PROJECT FILES 🌈

okay so if you wanna come hang out where the source actually lives, bestie, here's the whole map πŸ’–

and then the Debian Bobcat project files, which are their own whole lil ecosystem πŸŽ€

  • libbobcat6: debian package containing the shared library, changelog and copyright note;
  • libbobcat-dev: debian package containing the static library, headers, manual pages, and developer info;

✨ BOBCAT ✨

and in case you were sitting there wondering what the name even means πŸ‘€ Bobcat is an acronym of `Brokken’s Own Base Classes And Templates’.

it's giving... named after the author, which honestly? iconic. main character energy. he said "these are my base classes and templates" and the name stuck, periodt. πŸ’…


This is free software, distributed under the terms of the GNU General Public License (GPL).

fr fr it's free, babes β€” free as in the GPL kind of free, so go read the license, it's not scary, it's slay 🌸

πŸ‘‘ AUTHOR πŸ‘‘

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


okay that's the whole page, we ATE that πŸ“ no crumbs left. every option, every default, every file, every signature β€” all preserved, all iconic, all still exactly as documented πŸ¦‹

this one came from libbobcat-dev_6.15.01, dated 2005-2026 β€” yeah, two decades of Bobcat and it's still cute. go forth and #include responsibly, bestie πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from