Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
FBB::Table(3bobcat)		Table-formatter		   FBB::Table(3bobcat)

NAME
       FBB::Table - Generates row- or column-wise filled tables

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

DESCRIPTION
       FBB::Table  objects 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 using 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.

       Tables defined by Table consist of a (number of element dependent) num-
       ber  of	rows and a fixed number	of columns, the	latter value is	speci-
       fied at construction time. Columns and rows are normally	addressed  us-
       ing  index  values (starting at 0). Before the leftmost column, between
       the columns and beyond the last column separators are defined.  By  de-
       fault  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::Table-
       Support objects (cf. tablesupport(3bobcat)).

       Table  objects  look  a lot like	ostream	objects, but they also adopt a
       fairly rigid way	to define new elements:	each new insertion defines an-
       other table element, and	it is difficult	to end a row before it has re-
       ceived its nColumn number of elements. Table's sister-class,  TableBuf,
       is  a std::streambuf type of class, offering additional control through
       the use of a wrapping ostream class object.

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

INHERITS FROM
       std::ostringstream  -  Table inherits from std::ostringstream, allowing
       insertions into a Table object. Each separate  insertion	 adds  another
       element to the Table object.

       FBB::TableBase -	This class implements common elements of the table im-
       plementation (the FBB::TableBuf class is	also derived  from  TableBase.
       The  TableBase class is not intended to be used otherwise, and no sepa-
       rate man-page is	provided. All facilities provided by  Table  inherited
       from TableBase are described in this man-page.

ENUMERATIONS
       The  following  enumerations  are defined by the	class FBB::Table: enum
       FillDirection
       This enumeration	defines	two values:

       o      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 Table will be found in the second column	of  the	 first
	      row.

       o      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	defines	two values:

       o      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 default WidthType used by Table ob-
	      jects.

       o      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
       o      Table(size_t  nColumns,  Table::FillDirection   direction,   Ta-
	      ble::WidthType widthType = Table::COLUMNWIDTH):
	      The  table's number of columns, the fill directions and the col-
	      umn 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  parame-
	      ter  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.

       o      Table(TableSupport    &tableSupport,    size_t   nColumns,   Ta-
	      ble::FillDirection direction, Table::WidthType widthType	=  Ta-
	      ble::COLUMNWIDTH):
	      This  constructor	operates identically to	the previous construc-
	      tor, but expects an additional reference to a  TableSupport  ob-
	      ject.  A	TableSupport  object offers additional formatting fea-
	      tures 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	as  the	 Table	object
	      must  be able to manipulate its data. See	tablesuppport(3bobcat)
	      for more information about TableSupport.	The  copy  constructor
	      is not available.

OVERLOADED OPERATORS
       o      std::ostream &operator<<(std::ostream &str, Table	&table):
	      This  operator inserts a Table into a 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 ob-
	      tain a completely	filled rectangular table.

       o      Table &operator<<(Table &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 member	setAl-
	      ign() (see below for its description). By	default, all  elements
	      are right-aligned. See align(3bobcat) for	more information about
	      the Align	class.

       o      Table &operator<<(Table &obj, Type const &x):
	      This overloaded 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  x  into  the Table's std::ostringstream base class
	      object as	the next element of the	table.	The overloaded assign-
	      ment operator is not available.

MEMBER FUNCTIONS
       o      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	 additional elements to	the Table object. Empty	fields
	      are ignored unless the  parameter	 addEmpty  is  initialized  to
	      true.

       o      void clear():
	      The  contents of the table are erased. All existing elements are
	      removed, and the table will be empty.

       o      void clearStr():
	      The contents of its std::ostringstream  base  class  buffer  are
	      erased.

       o      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	itera-
	      tor pair are inserted into the table as new elements.

       o      void push_back(std::string const &element):
	      New elements can be added	to the table using push_back.  It  is,
	      e.g., called from	a back_inserter	adaptor.

       o      size_t nRows():
	      The currently available number of	rows in	the table is returned.
	      Its value	is only	defined	after calling def().

       o      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 con-
	      struction	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 de-
	      fault, all elements are right-aligned.

       o      Table &def():
	      After inserting elements into a Table object its number of  ele-
	      ments  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 may be called. It  is	 auto-
	      matically	 called	by operator__(ostream, Table). In other	situa-
	      tions it may be called explicitly	to force the insertion of  an-
	      other  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 ta-
	      ble's columns.  )

MANPULATORS
       o      Table &def(Table &table):
	      This manipulator can be inserted into a table to	call  the  ta-
	      ble'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';
       }

FILES
       bobcat/table - defines the class	interface;

SEE ALSO
       bobcat(7),   align(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()

DISTRIBUTION FILES
       o      bobcat_3.25.01-x.dsc: detached signature;

       o      bobcat_3.25.01-x.tar.gz: source archive;

       o      bobcat_3.25.01-x_i386.changes: change log;

       o      libbobcat1_3.25.01-x_*.deb:   debian  package  holding  the  li-
	      braries;

       o      libbobcat1-dev_3.25.01-x_*.deb: debian package holding  the  li-
	      braries, headers and manual pages;

       o      http://sourceforge.net/projects/bobcat: public archive location;

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

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

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

libbobcat-dev_3.25.01-x.tar.gz	   2005-2015		   FBB::Table(3bobcat)

NAME | SYNOPSIS | DESCRIPTION | NAMESPACE | INHERITS FROM | ENUMERATIONS | CONSTRUCTORS | OVERLOADED OPERATORS | MEMBER FUNCTIONS | MANPULATORS | EXAMPLE | FILES | SEE ALSO | BUGS | DISTRIBUTION FILES | BOBCAT | COPYRIGHT | AUTHOR

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=table&sektion=3&manpath=FreeBSD+12.0-RELEASE+and+Ports>

home | help