yat  0.21pre
ColumnStream.h
1 #ifndef _theplu_yat__utility_column_stream_
2 #define _theplu_yat__utility_column_stream_
3 
4 // $Id: ColumnStream.h 3330 2014-10-14 08:03:25Z peter $
5 
6 /*
7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2009, 2010, 2011, 2014 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  size_t activated_;
92  std::vector<size_t> margins_;
93  std::ostream& os_;
94  std::vector<std::stringstream*> buffer_;
95  std::vector<size_t> width_;
96  };
97 
98 
107  template <typename T>
109  {
110  std::stringstream ss;
111  ss << rhs;
112  s.print(ss);
113  return s;
114  }
115 
116 }}} // end of namespace utility, yat, theplu
117 
118 #endif
Definition: ColumnStream.h:37
The Department of Theoretical Physics namespace as we define it.
void next_column(void)
jump to next column
void set_column(size_t)
select which column is active
ColumnStream & operator<<(ColumnStream &s, const T &rhs)
ColumnStream output operator.
Definition: ColumnStream.h:108
ColumnStream(std::ostream &os, size_t columns)
Constructor.
void print(std::stringstream &)
print to active column

Generated on Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14