Frobby 0.10.0
Loading...
Searching...
No Matches
ColumnPrinter.h
1/* Frobby: Software for monomial ideal computations.
2 Copyright (C) 2009 Bjarke Hammersholt Roune (www.broune.com)
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see http://www.gnu.org/licenses/.
16*/
17#ifndef COLUMN_PRINTER_GUARD
18#define COLUMN_PRINTER_GUARD
19
20#include "ElementDeleter.h"
21
22#include <sstream>
23#include <vector>
24
26
27class ColumnPrinter {
28 public:
29 ColumnPrinter(size_t columnCount = 0);
30
31 void setPrefix(const string& prefix);
32 void addColumn(bool flushLeft = true,
33 const string& prefix = " ", const string& suffix = "");
34 size_t getColumnCount() const;
35
36 ostream& operator[](size_t col);
37
38 void print(ostream& out) const;
39 void print(FrobbyStringStream& out) const;
40
41 private:
42 struct Col {
43 string prefix;
44 stringstream text;
45 string suffix;
46 bool flushLeft;
47 };
48 vector<Col*> _cols;
49 ElementDeleter<vector<Col*> > _colsDeleter;
50 string _prefix;
51};
52
53ostream& operator<<(ostream& out, const ColumnPrinter& printer);
54void print(FILE* out, const ColumnPrinter& pr);
55
56#endif
Definition ColumnPrinter.h:27
Definition ElementDeleter.h:50
Definition FrobbyStringStream.h:26