table_stream.h
1/***************************************************************************
2 *
3 * Copyright (C) 2007 by David Smith
4 * Licensed under the Academic Free License version 2.1
5 *
6 ***************************************************************************/
7
8
9#ifndef __Table_Stream_h
10#define __Table_Stream_h
11
12
13
14#include <iostream>
15#include <vector>
16#include <string>
17
18
19
20class table_stream
21{
22public:
23 table_stream( std::ostream *set_target );
24 void set_stream( std::ostream *set_target );
25
26 typedef std::ostream& (*token_type) ( std::ostream& os );
27
28 enum justification { left, right, centre };
29
30 void add_string( std::string );
31 void add_row( void );
32 void flush( void );
33
34 bool is_numeric( std::string );
35
36 void determine_widths( void );
37 void determine_justifications( void );
38
39private:
40 std::ostream *target;
41 bool adding_headings;
42 int current_row;
43
44 std::vector< std::string > headings;
45 std::vector< std::vector< std::string > > data;
46 std::vector< int > column_widths;
47 std::vector< justification > justifications;
48};
49
50extern table_stream &operator<<( table_stream &rhs, const std::string &lhs );
51extern table_stream &operator<<( table_stream &rhs, table_stream::token_type);
52
53
54
55#endif // __Table_Stream_h
56
57

Generated using doxygen 1.14.0