FBB::Table(3bobcat)
π FBB::Table(3bobcat) β Construct text tables π
okay bestie, gather round, because we're about to make tables and it's gonna be so cute π
β¨ NAME β¨
FBB::Table β Generates row- or column-wise filled tables from information inserted into a std::ostream π¦
β¨ SYNOPSIS β¨
#include <bobcat/tablebuf>
Linking option: -lbobcat
β¨ DESCRIPTION β¨
so like, FBB::Tablebuf objects are std::streambuf objects that can be used to create tables. The tables are filled either column-wise or row-wise. Many of the table's characteristics may be fine-tuned by a separate FBB::TableSupport object, described in a separate man-page (TableSupport(3bobcat)). When no FBB::TableSupport object is used, a plain row-wise or column-wise table is constructed which can be inserted into a std::ostream.
Displaying a table (e.g., at the standard output stream) involves the following steps, no cap π
- Optionally, a
TableSupportobject is created; - A
Tablebufobject is created (maybe passing it aTableSupportobject); - The
Tablebufobject is used to initialize astd::ostream; - The elements of the table are filled by inserting information into that
std::ostream; - The
Tablebufitself contains the formatted table and may itself be inserted into astd::ostreamlikestd::cout.
Tables defined by TableBuf consist of a (number of element dependent) number of rows and a fixed number of columns, the latter value is specified at construction time. Columns and rows are normally addressed using index values (starting at 0). Before the leftmost column, between the columns and beyond the last column separators are defined. By default the separators are empty, but each separator may be given a (fixed) width or content. The separator before column col is addressed as separator col, the rightmost separator is addressed as separator nColummns. π
Likewise, rows can be separated from each other using separators. These separating rows are also 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 are defined using FBB::TableSupport objects (cf. tablesupport(3bobcat)).
TableBuf's sister-class Table can be used to insert elements into a table in a more direct way. With TableBuf field separators are used to switch to the next table-element, and (with row-wise filled tables) a row separator can be used to switch to the next row when it's only partially defined. Instead, with Table objects each new insertion defines another table element, and no wrapping std::ostream object is required. iconic behaviour honestly π
β¨ NAMESPACE β¨
FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.
β¨ INHERITS FROM β¨
std::streambufβ allowingTableBufobjects to be wrapped instd::ostreamobjects.FBB::TableBaseβ This class implements common elements of the table implementation (theFBB::TableBufclass is also derived fromTableBase). TheTableBaseclass is not intended to be used otherwise, and no separate man-page is provided. All facilities provided byTableinherited fromTableBaseare described in this man-page.
β¨ ENUMERATIONS β¨
The following enumerations are defined in the class FBB::Tablebuf.
enum FillDirection
This enumeration has two values:
ROWWISEβ When this value is specified at construction time, elements are added row-wise to the table. I.e., the second element inserted into theTablewill be found in the second column of the first row.COLUMNWISEβ When this value is specified at construction time, elements are added column-wise to the table. I.e., the second element will be found in the second row of the first column.
enum WidthType
This enumeration holds two values:
COLUMNWIDTHβ This value may be specified when the columns should be allowed variable widths. In this case each column will be as wide as its widest element. This is the defaultWidthTypeused byTableobjects.EQUALWIDTHβ This value may be specified when all the table's columns should have equal width (i.e., equal to the width of the widest table element).
β¨ CONSTRUCTORS β¨
Tablebuf(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 theTableobject. The direction parameter specifies the way new elements are added to theTableobject: 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. π«ΆTableBuf(TableSupport &tableSupport, Table::FillDirection direction, Table::WidthType widthType = Table::COLUMNWIDTH)β This constructor operates identically to the previous constructor, but expects an additional reference to aTableSupportobject. ATableSupportobject offers additional formatting features used by the table defining elements like horizontal lines between rows, additional separators, etc, etc. TheTableSupportobject is passed as a non-const reference as theTableobject must be able to manipulate its data. Seetablesuppport(3bobcat)for more information aboutTableSupport. β¨
Copy and move constructors (and assignment operators) are not available. π
β¨ OVERLOADED OPERATORS β¨
std::ostream &operator<<(std::ostream &out, TableBuf &tablebuf)β This operator inserts aTableBufinto astd::ostreamobject. Note that theTableBufobject inserted intooutis a non-const object, as the table may have to be completed by adding empty elements for missing ones. Theoutstream should not be equal to thestd::ostreamobject that is used to wrap in aTableBufobject. β οΈTableBuf &operator<<(TableBuf &obj, Align const &align)β This operator is used to change the default alignment of either a column or an element. It is a wrapper around the membersetAlign()(see below for its description). By default, all elements are right-aligned. Seealign(3bobcat)for more information about theAlignclass. Unlike the insertion operators available forTabletype objects, the insertion operator forTableBufobjects is only used to define column or cell-alignment. π
β¨ MEMBER FUNCTIONS β¨
void clear()β The content of the table are erased. All existing elements are removed, and the table will be empty. bye bye content π§Ήsize_t nRows()β The currently available number of rows in the table is returned. Its value is only defined after callingdef().TableBuf &setAlign(Align const &align)β The alignment type of either a column or an element of theTableBufobject is defined usingsetAlign. The standard alignmentsstd::left,std::rightandstd::internalmay be specified, but in addition the alignmentFBB::centermay 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. π
TableBuf &def()β After inserting elements into aTableBufobject its number of elements may or may not be an integral multiple of the number of columns specified at construction time. TocompleteaTableBufobject to a rectangular object, for which all column widths and alignments have been determineddefmay be called. It is automatically called byoperator<<(ostream, TableBuf). In other situations it may be called explicitly to force the insertion of another row in a table usingROWWISEinsertions. WithCOLUMNWISEinsertions its working is complex, since new elements added to aCOLUMNWISEfilled table will reshuffle its elements over the table's columns. πsetFieldSeparator(char fs)β The default field separator is the `backspace' (\b) character. After inserting a field separator the next table element will be defined. Inserting two field separators inserts an table empty element and starts the definition of the next element. This field separator character can be redefined by this function. CallingsetFieldSeparatorwithout argument disables the use of a field separator character, and only leaves the use of thefsmanipulator to switch to the next field. πsetRowSeparator(char rs)β The default row separator is the newline character (\n). After inserting a row separator the next element to enter into the table will be the leftmost element of the next row. Inserting two row separators adds an empty row to the table. CallingsetRowSeparatorwithout argument disables the use of a row separator character, and only leaves the use of thersmanipulator to switch to the next field. π
β¨ MANPULATORS β¨
Table &def(Table &table)β This manipulator can be inserted into a aTableBuf's wrappingostreamto call the table'sdef()member.FBB::fsβ This manipulator can be inserted into aTableBuf's wrappingostreamto switch to the next field of the table. It is an alternative to using the field separator character. β¨FBB::rsβ This manipulator can be inserted into aTableBuf's wrappingostreamto switch to the next row of the table. It is an alternative to using the row separator character. πΈ
bestie don't go anywhere yet, there's a part 2 coming and it's lowkey a whole serve π
πΈ EXAMPLE πΈ
okay bestie here's a lil taste of what this looks like in the wild, actual real code, no edits, no notes π
#include <iostream>
#include <ostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <bobcat/tablebuf>
#include <bobcat/tablelines>
using namespace std;
using namespace FBB;
int main()
{
TableLines tablelines;
tablelines << 0; // set separator widths
for (size_t sep = 0; sep != 8; ++sep)
tablelines << 3;
TableBuf tab(tablelines, 8, TableBuf::ROWWISE);
ostream out(&tab);
copy(istream_iterator<string>(cin), istream_iterator<string>(),
ostream_iterator<string>(out, "\b"));
cout << tab << β\nβ; // complete the table and insert
}
like. the way this just slurps words off cin and pipes them through \b backspace-delimited into a TableBuf... it's giving β¨main character energyβ¨ fr fr. then cout << tab finishes the whole thing off and inserts it. iconic. periodt π
π FILES π
bobcat/tablebufβ defines the class interface;
that's the one, babe. the header that holds the whole vibe. π«Ά
π SEE ALSO π
your girl is not out here alone, she's in a whole squad:
bobcat(7)align(3bobcat)csvtable(3bobcat)manipulator(3bobcat)tablelines(3bobcat)tablesupport(3bobcat)table(3bobcat)
π BUGS π
ngl there's one of those lil "iykyk" gotchas in here, and it's lowkey important so listen up:
note thatdef()will reshuffle elements over the table's columns when new elements are added to the table subsequent to callingdef(). so yeah β add stuff afterdef()and your columns go π« reshuffled. not dramatic, just facts. bestie. π
π BOBCAT PROJECT FILES π
- https://fbb-git.gitlab.io/bobcat/ β gitlab project page;
and for the Debian girlies, we got:
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;
like, pick your fighter π shared lib or the full dev kit, both v valid.
π BOBCAT π
Bobcat is an acronym of Brokkenβs Own Base Classes And Templates.
not me thinking that's actually kinda iconic as far as acronyms go?? like it fully ate. π
β COPYRIGHT β
This is free software, distributed under the terms of the GNU General Public License (GPL).
free as in freedom bestie, go wild, just respect the GPL. π§
π AUTHOR π
Frank B. Brokken (f.b.brokken@rug.nl).
and that's a wrap on this page angel πΈ she's from libbobcat-dev_6.15.01, dated 2005-2026, and that's the whole FBB::Table(3bobcat) journey start to finish. go build something cute with it, mwah π
π¦
π¦ where this page comes from
- ubuntu stonking: libbobcat-dev 6.15.01-1 Β· GPL-3.0-or-later WITH OpenSSL exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms