FBB::TableSupport(3bobcat)

πŸ’– FBB::TableSupport(3bobcat) β€” the Table Support base class πŸ’–

okay bestie, welcome to FBB::TableSupport β€” this is part 1 of the page, so grab a snack, we're going in ✨


✨ NAME ✨

FBB::TableSupport β€” it defines the protocols for Table-support classes. that's the whole vibe. πŸŽ€


🌸 SYNOPSIS 🌸

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

πŸ¦‹ DESCRIPTION πŸ¦‹

so FBB::TableSupport is used by FBB::Table and FBB::TableBuf objects, and it handles some of their functionality for them. you can derive your own classes from TableSupport and override its virtual members to decide the actual layout of your tables. and by default? the virtual members of TableSupport do not separate the columns of the table from each other. like, at all. no divider, no drama πŸ’…

the Bobcat library also offers a specialized class, TableLines, which extends the basic facilities of TableSupport by giving you facilities to separate rows with (partial) horizontal lines β€” check tablelines(3bobcat) for the details. 🧚

want even more specialized handling? then derive new classes from FBB::TableSupport and override members so they implement what you, the programmer, actually want. an object of that derived class can be handed to a FBB::Table or FBB::TableBuf constructor, and boom β€” the special handling is activated. main character energy fr fr πŸ‘‘


πŸ’œ NAMESPACE πŸ’œ

FBB

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


⭐ INHERITS FROM ⭐

-

(yep. nothing. it's a base class, an original, an icon 😌)


🌈 ENUMERATION 🌈

the enum ColumnType defines these values (and yeah, scroll down for the struct HLine description because they're besties):

  • SKIP β€” a section of a row-separating line should stay empty. this value is normally not used by applications;
  • USE β€” a section of a row-separating line should be used (like, 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 stays 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 stays blank.
heads up! the value SKIP should always be used by itself. the remaining values of the enum may be combined using the binary or (|) operator. 🌟

πŸ’… PUBLIC TYPE HLine πŸ’…

  • 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 specify section(s) of a horizontal separator between table rows that should be displayed or skipped. 🫢

so, like, say you want to specify that a separator should be written:

  • in row 1,
  • from column 2 up to (but not including) column 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 β€”

then you insert this HLine object into the TableSupport ts object:

ts << HLine(LEFT_MID | RIGHT_FULL, 1, 2, 5);

multiple HLine objects may be inserted, in any order, into TableSupport objects. and when column ranges overlap? their ColumnTypes are merged. slay πŸ”₯


πŸŽ€ PROTECTED TYPES πŸŽ€

  • const_iterator β€” the const_iterator is defined in the class's protected section. it's an input-iterator returning iterators to struct Field (see below) objects

for table columns and column separators (see below at the begin and end members)

  • struct Field β€” a Field has two data members: width and type, representing, respectively, the width and ColumnType of a column or separating column. the type values of Field objects returned by TableSupport members only contain single values (like SKIP or LEFT_MID) β€” note that column types can be combined when inserted into Table objects using HLine objects. 🌸

πŸ“ CONSTRUCTORS πŸ“

the default, copy and move constructors as well as the copy and move assignment operators are available. all of them, no gatekeeping πŸ’–


✨ OVERLOADED OPERATORS ✨

the following overloaded operators define separators between columns. the first value inserted into a TableSupport object defines the separator before column 0, the next one defines the separator before column 1, etc, until inserting separator nColumns + 1, which defines the separator to the right of the table's last column. inserting additional separators are ignored. periodt πŸ™ˆ

  • TableSupport &operator<<(TableSupport &support, size_t width) β€” this operator defines a column-separator of width space characters. width may be zero, in which case no visible separator is used;
  • TableSupport &operator<<(TableSupport &support, std::string const &text) β€” this operator defines a separator through text. the length of the text defines the width of the separator. no separator is used when text is empty;
  • TableSupport &operator<<(TableSupport &support, HLine const &hsep) β€” this operator defines how a horizontal separator of a specified row should be displayed (see the HLine description above). πŸ¦‹

πŸ”₯ 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 the virtual member v_hline, passing it row. by default v_hline performs no actions;
  • 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 the virtual member v_hline without arguments, which by default calls hline(nRows);
  • 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 by the Table and TableBuf's def member (and manipulator) to configure the TableSupport with alignment specifications, where:
    • ostr is a reference to the std::ostream to receive the table,
    • nRows specifies the table's number of rows,
    • nColumns specifies the table's number of columns,
    • 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 task is to write a column separator just before the data elements themselves. it calls the virtual member v_vline, passing it its col parameter. by default v_vline inserts the column separator of column col;
  • 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 the virtual member v_vline without arguments, by default calling vline(nColumns) and inserting a newline into the ostream;
  • size_t width() const β€” returns the width of the table in number of characters. it may be called before actually inserting the table into a stream. πŸ‘‘

πŸ’€ PROTECTED MEMBER FUNCTIONS πŸ’€

the following members are available to classes derived from TableSupport. except for sep and sepWidth, their values are only defined after calling setParam, which is called from the def member or manipulator of Table or TableBuf objects.

  • 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.
  • const_iterator begin(size_t row) const β€” an iterator is returned containing information about the first column element when displaying the horizontal separator before line row. use argument nRows() to obtain the information about the separator beyond the last row. the column elements of the table consist of its separators and data columns.

dereferencing the returned const_iterator returns a Field struct containing information about the width and type 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. dereferencing the iterator is defined until the iterator has reached the value returned by end (see below);

  • size_t colWidth(size_t col) const β€” the width of the indicated column is returned;
  • const_iterator end(size_t row) const β€” an iterator indicating the end of the iterator range starting at begin(row) is returned;
  • size_t nColumns() const β€” the table's number of columns is returned;
  • size_t nRows() const β€” the table's number of rows is returned;
  • std::ostream &out() const β€” a reference to the stream into which the table is inserted is returned;
  • std::vector<std::string> const &sep() β€” a reference to the separators defined for the table's columns is returned. element col refers to the separator to the left of the table's column col, element nColumns() refers to the separator to the right of the rightmost column;
  • 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. πŸ’œ

that's part 1 bestie!! part 2 is coming, don't go anywhere 🌈

πŸ’« VIRTUAL MEMBER FUNCTIONS πŸ’«

bestie, these are the little hook points you can override in your own derived class to change up how the horizontal and vertical separators look. you're literally in control of the vibe of your table's skeleton 😀✨

  • virtual void v_hline(size_t row) const β€” this one gets called from hline(size_t row) and it receives that same row parameter, no cap 🫢 its whole job is to write a horizontal separator before row number row. by default? nothing happens, literally nothing gets inserted πŸ’€ if you want, you can build that separator by iterating over the range defined by the begin and end members and making decisions based on the Field objects you get from dereferencing the iterators. OR β€” and this is the slay shortcut β€” if you just want a horizontal line spanning the entire width of the table row, do it like this:
void Derived::v_hline(size_t row) const
{
    out() << setfill(’-’) << setw(width()) << "-" <<
                                                    setfill(’ ’);
}
  • virtual void v_hline() const β€” this one's called from hline() ✨ its task is writing a (partial) horizontal line past the table's last line. default behaviour? it just calls hline(nRows). iconic, honestly.
  • virtual void v_vline(size_t col) const β€” called from vline(size_t col) and it gets handed that col parameter 🌸 its job is to write a separator before data column col. by default it inserts separator[col] if that separator is available β€” and if it's not available, then no separator gets inserted before column col. simple as 🧚
  • virtual void v_vline() const β€” this cutie is called from vline() at the end of every single one of the table's rows πŸ’… its task is to write a column separator and to terminate the table's line that it was called for. by default it inserts the final column separator (if it's defined) plus a newline \n character. periodt.

🌈 EXAMPLE 🌈

okay so the example? it lives over in the table(3bobcat) man-page. go peek there, bestie πŸ“–πŸ’–


πŸŽ€ FILES πŸŽ€

bobcat/tableSupport β€” this is the file that defines the class interface, the blueprint of it all ✨


πŸ”₯ SEE ALSO πŸ”₯

bobcat(7), align(3bobcat), csvtable(3bobcat), table(3bobcat), tablebuf(3bobcat), tablelines(3bobcat)

the whole friend group, tbh 🫢


πŸ’€ BUGS πŸ’€

None Reported.

(not one?! we love a flawless queen πŸ‘‘βœ¨)


πŸ“¦ BOBCAT PROJECT FILES πŸ“¦

Debian Bobcat project files, coming right up:

  • libbobcat6: the debian package containing the shared library, changelog and copyright note πŸ“
  • libbobcat-dev: the debian package containing the static library, headers, manual pages, and developer info πŸ› οΈ

πŸ‘‘ BOBCAT πŸ‘‘

Bobcat is an acronym of `Brokken’s Own Base Classes And Templates’.

(iykyk β€” and now you do 😌)


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


πŸ’œ AUTHOR πŸ’œ

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


and that's a wrap on the whole page, bestie πŸŽ€πŸ’– this was FBB::TableSupport(3bobcat) from the libbobcat-dev_6.15.01 era, dated 2005-2026 β€” yes she's been around and she's still serving looks. go build smth cute with your tables, mwah 😘✨

πŸ“¦ where this page comes from