yat  0.10.4pre
ColumnStream.h
1 #ifndef _theplu_yat__utility_column_stream_
2 #define _theplu_yat__utility_column_stream_
3 
4 // $Id: ColumnStream.h 2526 2011-07-25 02:03:35Z peter $
5 
6 /*
7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2009, 2010, 2011 Peter Johansson
9 
10  This file is part of yat, http://dev.thep.lu.se/yat
11 
12  yat is free software; you can redistribute it and/or modify it
13  under the terms of the GNU General Public License as published by
14  the Free Software Foundation; either version 3 of the License, or
15  (at your option) any later version.
16 
17  yat is distributed in the hope that it will be useful, but
18  WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with yat. If not, see <http://www.gnu.org/licenses/>.
24 */
25 
26 #include <iosfwd>
27 #include <sstream>
28 #include <vector>
29 
30 namespace theplu {
31 namespace yat {
32 namespace utility {
33 
38  {
39  public:
40 
44  ColumnStream(std::ostream& os, size_t columns);
45 
49  ~ColumnStream(void);
50 
54  void flush(void);
55 
59  size_t& margin(size_t c);
60 
64  void next_column(void);
65 
69  void print(std::stringstream&);
70 
74  void set_column(size_t);
75 
79  size_t& width(size_t c);
80 
81  private:
85  ColumnStream(const ColumnStream&);
86 
87  void fill(size_t, size_t);
88  bool writeline(size_t i);
89  size_t columns(void) const;
90 
91 
92  size_t activated_;
93  std::vector<size_t> margins_;
94  std::ostream& os_;
95  std::vector<std::stringstream*> buffer_;
96  std::vector<size_t> width_;
97  };
98 
99 
108  template <typename T>
109  ColumnStream& operator<<(ColumnStream& s, const T& rhs)
110  {
111  std::stringstream ss;
112  ss << rhs;
113  s.print(ss);
114  return s;
115  }
116 
117 }}} // end of namespace utility, yat, theplu
118 
119 #endif

Generated on Mon Nov 11 2013 09:41:44 for yat by  doxygen 1.8.1