rvm  1.11
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
table.h
Go to the documentation of this file.
1 #ifndef __table_h__
2 #define __table_h__
3 
4 #include <iostream>
5 #include <vector>
6 #include <list>
7 
8 #include "asserts.h"
9 #include "estring.h"
10 
11 class table;
12 
14 {
15 public:
17  static const size_type npos;
18 
20  table_cell_base(const table_cell_base& a_class);
21  virtual ~table_cell_base();
22 
23  virtual void assign(const table_cell_base& a_class);
24 
25  virtual size_type height(void) const;
26  virtual size_type width(void) const;
27  virtual void write(
28  std::ostream& out,
29  size_type a_line,
30  size_type a_width
31  ) const;
32 
33  table_cell_base& operator=(const table_cell_base& a_class);
34 
37  bool repeat;
38 
39 private:
40 };
41 
42 bool operator==(const table_cell_base& a_1, const table_cell_base& a_2);
43 
45 {
46 public:
48  table_cell_estring(const table_cell_estring& a_class);
49  table_cell_estring(const estring& a_class);
50  virtual ~table_cell_estring();
51 
52  virtual void assign(const table_cell_estring& a_class);
53  virtual void assign(const estring& a_class);
54 
55  virtual size_type height(void) const;
56  virtual size_type width(void) const;
57  virtual void write(
58  std::ostream& out,
59  size_type a_line,
60  size_type a_width
61  ) const;
62 
64  table_cell_estring& operator=(const estring& a_class);
65 
66 private:
68 };
69 
71 {
72 public:
74  table_cell_table(const table_cell_table& a_class);
75  table_cell_table(const table& a_class);
76  virtual ~table_cell_table();
77 
78  virtual void assign(const table_cell_table& a_class);
79  virtual void assign(const table& a_class);
80 
81  virtual size_type height(void) const;
82  virtual size_type width(void) const;
83  virtual void write(
84  std::ostream& out,
85  size_type a_line,
86  size_type a_width
87  ) const;
88 
90  table_cell_table& operator=(const table& a_class);
91 
92 private:
94 };
95 
96 class table
97 {
98 public:
99  typedef std::vector<table_cell_base *> table_row_type;
100  typedef std::vector<table_row_type> table_type;
102 
103  table();
104  table(const size_type a_ncols, const size_type a_nrows);
105  table(const table& a_class);
106  virtual ~table();
107 
108  virtual void resize(const size_type a_x, const size_type a_y);
109  virtual void insert_row(const size_type a_y);
110  virtual void insert_col(const size_type a_x);
111 
112  virtual void assign(const table& a_class);
113  virtual void assign(
114  const size_type a_x,
115  const size_type a_y,
116  const estring& a_class
117  );
118  virtual void assign(
119  const size_type a_x,
120  const size_type a_y,
121  const table& a_class
122  );
123 
124  size_type col_width(const size_type a_x) const;
125  size_type row_width(void) const;
126  size_type col_height(void) const;
127  size_type row_height(const size_type a_y) const;
128 
129  virtual size_type height(void) const;
130  virtual size_type width(void) const;
131  virtual void write(
132  std::ostream& out,
133  size_type a_line,
134  size_type a_width
135  ) const;
136 
137  const size_type ncols(void) const;
138  const size_type nrows(void) const;
139 
140  table& operator=(const table& a_class);
141 
142  size_type cursor_x(void) const;
143  size_type cursor_y(void) const;
144  void set_cursor(size_type a_x, size_type a_y);
145  bool eot(void) const;
146 
147  void repeat(const bool a_bool);
148 
149 private:
151  std::list<table_cell_estring> m_list_estring;
152  std::list<table_cell_table> m_list_table;
155  bool m_repeat;
156 
157  void mf_init(void);
158  void mf_add_elt(const table_cell_estring& a_class);
159  void mf_add_elt(const table_cell_table& a_class);
160  void mf_remove_elt(const table_cell_estring& a_class);
161  void mf_remove_elt(const table_cell_table& a_class);
162  void mf_remove_elt(
163  size_type a_x,
164  size_type a_y
165  );
166  void mf_remove_row(size_type a_y);
167 };
168 
169 std::ostream& operator<<(std::ostream& a_out, table& a_class);
170 
171 table& table_write(table& a_table, const estring& a_estr);
172 table& table_write(table& a_table, const table& a_subtable);
173 table& table_endl(table& a_table);
174 table& table_rewind(table& a_table);
175 table& table_skip(table& a_table);
176 table& table_repeat(table& a_table);
177 table& operator<<(table& a_table, const estring& a_estr);
178 table& operator<<(table& a_table, const table& a_subtable);
179 table& operator<<(table& a_table, table& (*a_arg)(table&));
180 
181 #endif
virtual void assign(const table_cell_table &a_class)
Definition: table.cc:185
size_type col_height(void) const
Definition: table.cc:470
virtual size_type height(void) const
Definition: table.cc:504
virtual void assign(const table &a_class)
Definition: table.cc:347
table & table_write(table &a_table, const estring &a_estr)
Definition: table.cc:825
An extended string class.
Definition: estring.h:52
table_cell_estring & operator=(const table_cell_estring &a_class)
Definition: table.cc:143
virtual void write(std::ostream &out, size_type a_line, size_type a_width) const
Definition: table.cc:46
size_type col_width(const size_type a_x) const
Definition: table.cc:431
virtual void assign(const table_cell_base &a_class)
Definition: table.cc:32
virtual void write(std::ostream &out, size_type a_line, size_type a_width) const
Definition: table.cc:117
virtual ~table_cell_estring()
Definition: table.cc:86
size_type y
Definition: table.h:36
table & operator=(const table &a_class)
Definition: table.cc:614
virtual ~table_cell_base()
Definition: table.cc:28
static const size_type npos
Definition: table.h:17
void repeat(const bool a_bool)
Definition: table.cc:659
size_type m_cursor_x
Definition: table.h:153
void mf_remove_row(size_type a_y)
Definition: table.cc:785
void mf_add_elt(const table_cell_estring &a_class)
Definition: table.cc:671
size_type row_height(const size_type a_y) const
Definition: table.cc:482
virtual ~table_cell_table()
Definition: table.cc:179
size_type x
Definition: table.h:35
table_cell_base::size_type size_type
Definition: table.h:101
virtual size_type width(void) const
Definition: table.cc:108
size_type cursor_x(void) const
Definition: table.cc:621
table & table_repeat(table &a_table)
Definition: table.cc:883
estring m_value
Definition: table.h:67
virtual void insert_col(const size_type a_x)
Definition: table.cc:332
table & table_skip(table &a_table)
Definition: table.cc:869
table & table_rewind(table &a_table)
Definition: table.cc:862
const size_type nrows(void) const
Definition: table.cc:561
void mf_init(void)
Definition: table.cc:664
bool operator==(const table_cell_base &a_1, const table_cell_base &a_2)
Definition: table.cc:61
virtual ~table()
Definition: table.cc:287
bool m_repeat
Definition: table.h:155
virtual void insert_row(const size_type a_y)
Definition: table.cc:315
bool eot(void) const
Definition: table.cc:650
const size_type ncols(void) const
Definition: table.cc:549
virtual size_type width(void) const
Definition: table.cc:41
virtual size_type height(void) const
Definition: table.cc:103
bool repeat
Definition: table.h:37
virtual void assign(const table_cell_estring &a_class)
Definition: table.cc:90
virtual void resize(const size_type a_x, const size_type a_y)
Definition: table.cc:291
table * m_value
Definition: table.h:93
table_type m_table
Definition: table.h:150
virtual size_type height(void) const
Definition: table.cc:36
std::ostream & operator<<(std::ostream &a_out, table &a_class)
Definition: table.cc:807
value_type::size_type size_type
The size type.
Definition: estring.h:59
virtual size_type height(void) const
Definition: table.cc:202
std::vector< table_cell_base * > table_row_type
Definition: table.h:99
std::list< table_cell_estring > m_list_estring
Definition: table.h:151
size_type cursor_y(void) const
Definition: table.cc:626
size_type m_cursor_y
Definition: table.h:154
size_type row_width(void) const
Definition: table.cc:454
table_cell_table & operator=(const table_cell_table &a_class)
Definition: table.cc:243
virtual void write(std::ostream &out, size_type a_line, size_type a_width) const
Definition: table.cc:570
estring::size_type size_type
Definition: table.h:16
table_cell_base()
Definition: table.cc:16
std::vector< table_row_type > table_type
Definition: table.h:100
void set_cursor(size_type a_x, size_type a_y)
Definition: table.cc:631
Definition: table.h:96
virtual void write(std::ostream &out, size_type a_line, size_type a_width) const
Definition: table.cc:220
void mf_remove_elt(const table_cell_estring &a_class)
Definition: table.cc:707
table_cell_base & operator=(const table_cell_base &a_class)
Definition: table.cc:54
virtual size_type width(void) const
Definition: table.cc:524
std::list< table_cell_table > m_list_table
Definition: table.h:152
virtual size_type width(void) const
Definition: table.cc:211
table & table_endl(table &a_table)
Definition: table.cc:853
table()
Definition: table.cc:260