File: align

package info (click to toggle)
bobcat 1.18.1-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,920 kB
  • ctags: 575
  • sloc: makefile: 12,973; cpp: 6,284; perl: 401; ansic: 68; sh: 52
file content (82 lines) | stat: -rw-r--r-- 1,321 bytes parent folder | download
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
#ifndef INCLUDED_BOBCAT_ALIGN_
#define INCLUDED_BOBCAT_ALIGN_

#include <ostream>

namespace FBB
{

typedef std::ios_base &(*Manipulator)(std::ios_base &);

inline std::ios_base &center(std::ios_base &stream)
{
    return stream;
}

class Align
{
    int d_row;              // -1 or the row index to align
    size_t d_col;           // acts as field width when setting the width of 
                            // an element.
    Manipulator d_manip;

    public:
        Align(int row, size_t column, Manipulator manip);
        Align(size_t col = 0, Manipulator manip = std::right);
        Align(Manipulator manip);

        bool hasRow() const;

        operator size_t() const;

        size_t col() const;
        size_t row() const;

        Manipulator manip() const;

        void setWidth(size_t width);
        void setManip(Manipulator manip);
};

inline Align::operator size_t() const
{
    return d_col;
}

inline size_t Align::col() const
{
    return d_col;
}

inline size_t Align::row() const
{
    return d_row;
}

inline bool Align::hasRow() const
{
    return d_row != -1;
}

inline Manipulator Align::manip() const
{
    return d_manip;
}

inline void Align::setManip(Manipulator manip)
{
    d_manip = manip;
}

inline void Align::setWidth(size_t size)
{
    d_col = size;
}

} // FBB

#endif