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
|
#include "tablebase.ih"
std::ios_base &(*ctr)(std::ios_base &stream) = FBB::center;
ostream &TableBase::insert(ostream &ostr)
{
def();
if (!d_nRows)
return ostr;
d_tableSupport.setParam(ostr, d_nRows, d_nColumns, d_align);
for (size_t row = 0; row < d_nRows; ++row)
{
d_tableSupport.hline(row);
for (size_t col = 0; col < d_nColumns; ++col)
{
size_t colwidth = columnWidth(col);
d_tableSupport.vline(col);
Element &element = elementAt(row, col);
Manipulator manip = element.d_manip;
if (!manip)
manip = columnManip(col);
// if (manip != FBB::center)
if (manip != ctr)
ostr << manip << setw(colwidth) << element.d_text;
else
{
int available = colwidth - element.length();
if (available < 0)
available = 0;
if (size_t skip = available >> 1)
ostr << setw(skip) << " ";
ostr << element.d_text;
if (size_t skip = available - (available >> 1))
ostr << setw(skip) << " ";
}
}
d_tableSupport.vline();
}
d_tableSupport.hline();
return ostr;
}
|