File: insert2.cc

package info (click to toggle)
bobcat 6.11.00-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,292 kB
  • sloc: cpp: 21,370; fortran: 6,507; makefile: 2,787; sh: 724; perl: 401; ansic: 26
file content (41 lines) | stat: -rw-r--r-- 1,425 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
//#define XERR
#include "csvtabins.ih"

    // fmt insertion:
    //     hline: inserts hline unless beyond the last column
    //
    //     left/right/center formatting:
    //          beyond the last column:
    //              at LEFT: align left, otherwise right
    //              set precision unless d_size (acting as precision) == ~0U
    //              d_nCols is ignored
    //          within the table:
    //              set extraFMT with d_precision: fmt.d_width
    //                                d_wdith: width(fmt)

CSVTabIns &CSVTabIns::insert(FMT const &fmt)
{
    if (fmt.align() == FMT::HLINE)          // fmt contains total width
        hline(fmt);                         // and nCols used by the hline
    else if (d_idx == d_format.size())      // ignore beyond the last column
    {
        if (fmt.d_width != ~0U)
            d_out->precision(fmt.d_width);

        *d_out << (fmt.align() == FMT::LEFT ? std::left : std::right);
    }
    else
    {
        d_useExtraFMT = true;
        d_extraFMT = fmt;
                                                // when inserting d_width is
        d_extraFMT.d_precision = fmt.d_width;   // the precision

                                                        // and use d_format's
        d_extraFMT.d_width = d_format[d_idx].d_width;   // width

        d_extraFMT.d_width = width(d_extraFMT); // compute the width
    }

    return *this;
}