File: tablebuf.yo

package info (click to toggle)
bobcat 6.02.02-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 13,960 kB
  • sloc: cpp: 18,954; fortran: 5,617; makefile: 2,787; sh: 659; perl: 401; ansic: 26
file content (227 lines) | stat: -rw-r--r-- 11,063 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
includefile(include/header)

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

manpagename(FBB::Table)(Generates row- or column-wise filled tables from
information inserted into a std::ostream)

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

manpagedescription()

    bf(FBB::Tablebuf) objects are bf(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
bf(FBB::TableSupport) object, described in a separate man-page
(bf(TableSupport)(3bobcat)). When no bf(FBB::TableSupport) object is used, a
plain row-wise or column-wise table is constructed which can be inserted into
a bf(std::ostream). Displaying a table (e.g., at the standard output stream)
involves the following steps:
    itemization(
    it() Optionally, a  tt(TableSupport) object is created;
    it() A tt(Tablebuf) object is created (maybe passing it a tt(TableSupport)
object);
    it() The tt(Tablebuf) object is used to initialize a tt(std::ostream)
    it() The elements of the table are filled by inserting information into
that tt(std::ostream)
    it() The tt(Tablebuf) itself contains the formatted table and may itself
be inserted into a tt(std::ostream) like tt(std::cout).
    )

    Tables defined by tt(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 em(separators) are defined. By default the 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).

Likewise, rows can be separated from each other using separators. These
separating rows are also 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(TableBuf)'s sister-class tt(Table) can be used to insert elements into a
table in a more direct way. With tt(TableBuf) em(field separators) are used to
switch to the next table-element, and (with row-wise filled tables) a em(row
separator) can be used to switch to the next row when it's only partially
defined. Instead, with tt(Table) objects each new insertion defines another
table element, and no wrapping tt(std::ostream) object is required.

includefile(include/namespace)

manpagesection(INHERITS FROM)

    bf(std::streambuf) - allowing tt(TableBuf) objects to be wrapped in
tt(std::ostream) objects.

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


manpagesection(ENUMERATIONS)
    The following enumerations are defined in the class bf(FBB::Tablebuf).

    bf(enum FillDirection)nl()
    This enumeration has 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 bf(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 will be found in the second
row of the first column.
    )

    bf(enum WidthType)nl()
    This enumeration holds two values:
    itemization(
    itb(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 bf(WidthType) used by bf(Table) objects.
    itb(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),
    )

manpagesection(CONSTRUCTORS)
    itemization(
    itb(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
the bf(Table) object.  The bf(direction) parameter specifies the way new
elements are added to the bf(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(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 a bf(TableSupport) object. A
bf(TableSupport) object offers additional formatting features used by the
table defining elements like horizontal lines between rows, additional
separators, etc, etc. The bf(TableSupport) object is passed as a non-const
reference as the bf(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 &out, TableBuf &tablebuf))
        This operator inserts a bf(TableBuf) into a tt(std::ostream)
object. Note that the tt(TableBuf) object inserted into tt(out) is a non-const
object, as the table may have to be completed by adding empty elements for
missing ones. The tt(out) stream should not be equal to the tt(std::ostream)
object that is used to wrap in a tt(TableBuf) object.
    itb(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 member tt(setAlign()) (see
below for its description). By default, all elements are right-aligned. See
bf(align)(3bobcat) for more information about the tt(Align) class. Unlike the
insertion operators available for tt(Table) type objects, the insertion
operator for tt(TableBuf) objects is only used to define column or
cell-alignment.
    )

manpagesection(MEMBER FUNCTIONS)
    itemization(
    itb(void clear())
        The content of the table are erased. All existing elements are
removed, and the table will be empty.
    itb(size_t nRows())
        The currently available number of rows in the table is returned. Its
value is only defined after calling bf(CHAR(d)ef()).
    itb(TableBuf &setAlign(Align const &align))
        The alignment type of either a column or an element of the bf(TableBuf)
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.
    itb(TableBuf &CHAR(d)ef())
        After inserting elements into a tt(TableBuf) 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 bf(TableBuf) object to a
rectangular object, for which all column widths and alignments have been
determined tt(def) may be called. It is automatically called by
tt(operator<<(ostream, TableBuf)). 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(setFieldSeparator(char fs))
        The default field separator is the `backspace' (tt(\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.  Calling tt(setFieldSeparator) without argument
disables the use of a field separator character, and only leaves the use of
the tt(fs) manipulator to switch to the next field.
    itb(setRowSeparator(char rs))
        The default row separator is the newline character (tt(\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.  Calling tt(setRowSeparator) without argument disables the
use of a row separator character, and only leaves the use of the tt(rs)
manipulator to switch to the next field.
    )

manpagesection(MANPULATORS)
    itemization(
    itb(Table &CHAR(d)ef(Table &table))
        This manipulator can be inserted into a a tt(TableBuf)'s wrapping
tt(ostream) to call the table's bf(CHAR(d)ef()) member.
    itb(FBB::fs)
        This manipulator can be inserted into a tt(TableBuf)'s wrapping
tt(ostream) to switch to the next field of the table. It is an alternative to
using the field separator character.
    itb(FBB::rs)
        This manipulator can be inserted into a tt(TableBuf)'s wrapping
tt(ostream) to switch to the next row of the table. It is an alternative to
using the row separator character.
    )

manpagesection(EXAMPLE)

    verbinclude(../../tablebuf/driver/driver.cc)

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

manpageseealso() 
    bf(bobcat)(7), bf(align)(3bobcat), bf(csvtable)(3bobcat),
    bf(manipulator)(3bobcat), bf(tablelines)(3bobcat),
    bf(tablesupport)(3bobcat), bf(table)(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)