22 bool open(
const std::string& a_filename)
27 m_in.open(a_filename.c_str());
44 value =
m_in.is_open();
50 char buffer[1024] = { 0 };
52 if (!
m_in.getline(buffer,1024)) {
60 <<
"*** ERROR: check_output::get_line() - Out of memory?"
67 const std::string&
str(
void)
const
72 bool remove(
const std::string& a_filename)
74 if (unlink(a_filename.c_str()) != 0) {
97 assert(!(tcb == tcb2));
100 out.open(
"./test-table.txt");
101 assert(out.is_open());
105 assert(check.
open(
"./test-table.txt"));
107 assert(check.
close());
108 assert(check.
remove(
"./test-table.txt"));
116 estr =
"Hello World";
119 assert(tce.
height() == 1);
120 assert(tce.
width() == estr.size());
124 assert(tce2.height() == 1);
125 assert(tce2.width() == estr.size());
129 assert(tce3.height() == 1);
130 assert(tce3.width() == estr.size());
133 out.open(
"./test-table.txt");
134 assert(out.is_open());
141 assert(check.
open(
"./test-table.txt"));
142 assert(check.
get_line() && check.
str() ==
"Hello World ");
145 assert(check.
close());
146 assert(check.
remove(
"./test-table.txt"));
154 assert(t.
ncols() == 0);
155 assert(t.
nrows() == 0);
156 assert(t.
width() == 0);
160 out.open(
"./test-table.txt");
161 assert(out.is_open());
165 assert(check.
open(
"./test-table.txt"));
167 assert(check.
close());
168 assert(check.
remove(
"./test-table.txt"));
176 assert(t.
ncols() == 1);
177 assert(t.
nrows() == 1);
182 assert(t.
width() == 0);
186 out.open(
"./test-table.txt");
187 assert(out.is_open());
191 assert(check.
open(
"./test-table.txt"));
193 assert(check.
close());
194 assert(check.
remove(
"./test-table.txt"));
196 t.
assign(0,0,
"Hello World");
198 assert(t.ncols() == 1);
199 assert(t.nrows() == 1);
200 assert(t.col_width(0) == 11);
201 assert(t.row_width() == 11);
202 assert(t.col_height() == 1);
203 assert(t.row_height(0) == 1);
204 assert(t.width() == 11);
205 assert(t.height() == 1);
207 out.open(
"./test-table.txt");
208 assert(out.is_open());
212 assert(check.
open(
"./test-table.txt"));
213 assert(check.
get_line() && check.
str() ==
"Hello World");
215 assert(check.
close());
216 assert(check.
remove(
"./test-table.txt"));
220 assert(t.ncols() == 2);
221 assert(t.nrows() == 1);
222 assert(t.col_width(0) == 11);
223 assert(t.row_width() == 11);
224 assert(t.col_height() == 1);
225 assert(t.row_height(0) == 1);
226 assert(t.width() == 11);
227 assert(t.height() == 1);
229 out.open(
"./test-table.txt");
230 assert(out.is_open());
234 assert(check.
open(
"./test-table.txt"));
235 assert(check.
get_line() && check.
str() ==
"Hello World");
237 assert(check.
close());
238 assert(check.
remove(
"./test-table.txt"));
240 t.assign(0,0,
"Hello ");
241 t.assign(1,0,
"World");
243 assert(t.ncols() == 2);
244 assert(t.nrows() == 1);
245 assert(t.col_width(0) == 6);
246 assert(t.col_width(1) == 5);
247 assert(t.row_width() == 11);
248 assert(t.col_height() == 1);
249 assert(t.row_height(0) == 1);
250 assert(t.width() == 11);
251 assert(t.height() == 1);
253 out.open(
"./test-table.txt");
254 assert(out.is_open());
258 assert(check.
open(
"./test-table.txt"));
259 assert(check.
get_line() && check.
str() ==
"Hello World");
261 assert(check.
close());
262 assert(check.
remove(
"./test-table.txt"));
266 assert(t.ncols() == 2);
267 assert(t.nrows() == 2);
268 assert(t.col_width(0) == 6);
269 assert(t.col_width(1) == 5);
270 assert(t.col_height() == 1);
271 assert(t.row_height(0) == 1);
272 assert(t.row_height(1) == 0);
273 assert(t.width() == 11);
274 assert(t.height() == 1);
276 out.open(
"./test-table.txt");
277 assert(out.is_open());
281 assert(check.
open(
"./test-table.txt"));
282 assert(check.
get_line() && check.
str() ==
"Hello World");
284 assert(check.
close());
285 assert(check.
remove(
"./test-table.txt"));
288 t.assign(1,1,
"There");
290 assert(t.ncols() == 2);
291 assert(t.nrows() == 2);
292 assert(t.col_width(0) == 6);
293 assert(t.col_width(1) == 5);
294 assert(t.row_width() == 11);
295 assert(t.col_height() == 2);
296 assert(t.row_height(0) == 1);
297 assert(t.row_height(1) == 1);
298 assert(t.width() == 11);
299 assert(t.height() == 2);
301 out.open(
"./test-table.txt");
302 assert(out.is_open());
306 assert(check.
open(
"./test-table.txt"));
307 assert(check.
get_line() && check.
str() ==
"Hello World");
308 assert(check.
get_line() && check.
str() ==
"Hi There");
310 assert(check.
close());
311 assert(check.
remove(
"./test-table.txt"));
329 assert(t.
ncols() == 2);
330 assert(t.
nrows() == 2);
337 assert(t.
width() == 12);
341 out.open(
"./test-table.txt");
342 assert(out.is_open());
346 assert(check.
open(
"./test-table.txt"));
347 assert(check.
get_line() && check.
str() ==
"Hello World ");
348 assert(check.
get_line() && check.
str() ==
"Hi A B ");
351 assert(check.
close());
352 assert(check.
remove(
"./test-table.txt"));
358 assert(t.
ncols() == 0);
359 assert(t.
nrows() == 0);
363 assert(t.
ncols() == 0);
364 assert(t.
nrows() == 1);
368 assert(t.
ncols() == 1);
369 assert(t.
nrows() == 1);
375 assert(t.
ncols() == 2);
376 assert(t.
nrows() == 1);
382 assert(t.
ncols() == 3);
383 assert(t.
nrows() == 1);
389 assert(t.
ncols() == 3);
390 assert(t.
nrows() == 2);
397 out.open(
"./test-table.txt");
401 assert(check.
open(
"./test-table.txt"));
402 assert(check.
get_line() && check.
str() ==
"Hello World");
403 assert(check.
get_line() && check.
str() ==
"Hi There");
405 assert(check.
close());
406 assert(check.
remove(
"./test-table.txt"));
412 table t, subt1, subt2;
413 char const * array1[] = {
416 "alces:/export/home/a1/",
417 "alces:/export/home/a2/",
418 "alces:/export/home/a3/",
419 "alces:/export/home/a4/",
420 "alces:/export/home/a5/",
421 "alces:/export/home/b1/",
422 "alces:/export/home/b2/",
423 "alces:/export/home/b3/",
424 "alces:/export/home/b4/",
425 "alces:/export/home/b5/",
426 "alces:/export/home/c1/",
427 "alces:/export/home/c2/",
428 "alces:/export/home/c3/",
429 "alces:/export/home/c4/",
430 "alces:/export/home/c5/",
431 "alces:/export/home/d1/",
432 "alces:/export/home/d2/",
433 "alces:/export/home/d3/",
434 "alces:/export/home/d4/",
435 "alces:/export/home/d5/",
439 char const * array2[] = {
442 "alces/export/home/a1/",
443 "alces/export/home/a2/",
444 "alces/export/home/a3/",
445 "alces/export/home/a4/",
446 "alces/export/home/a5/",
447 "alces/export/home/b1/",
448 "alces/export/home/b2/",
449 "alces/export/home/b3/",
450 "alces/export/home/b4/",
451 "alces/export/home/b5/",
452 "alces/export/home/c1/",
453 "alces/export/home/c2/",
454 "alces/export/home/c3/",
455 "alces/export/home/c4/",
456 "alces/export/home/c5/",
457 "alces/export/home/d1/",
458 "alces/export/home/d2/",
459 "alces/export/home/d3/",
460 "alces/export/home/d4/",
461 "alces/export/home/d5/",
468 for (c = 0; array1[c] != 0; ++c) {
469 subt1 <<
"From:" <<
" " << array1[c] <<
" " <<
"To:" <<
" " << array2[c]
473 estr =
"Start Time:";
479 estr =
"2004 Mar 31 21:32:10";
485 estr =
"Total Files:";
497 estr =
"Total Size:";
517 estr =
"2004 Mar 31 23:16:31";
523 estr =
"Xferd Files:";
535 estr =
"Xferd Size:";
585 t <<
"Status" <<
" " <<
"Stats" <<
table_endl;
596 out.open(
"./test-table.txt");
600 assert(check.
open(
"./test-table.txt"));
601 assert(check.
get_line() && check.
str() ==
"Status Stats ");
602 assert(check.
get_line() && check.
str() ==
"------ -----------------------------------------------------------------------");
603 assert(check.
get_line() && check.
str() ==
"Ok From: alces:/ To: alces/ ");
604 assert(check.
get_line() && check.
str() ==
" From: alces:/export/ To: alces/export/ ");
605 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/a1/ To: alces/export/home/a1/ ");
606 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/a2/ To: alces/export/home/a2/ ");
607 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/a3/ To: alces/export/home/a3/ ");
608 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/a4/ To: alces/export/home/a4/ ");
609 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/a5/ To: alces/export/home/a5/ ");
610 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/b1/ To: alces/export/home/b1/ ");
611 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/b2/ To: alces/export/home/b2/ ");
612 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/b3/ To: alces/export/home/b3/ ");
613 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/b4/ To: alces/export/home/b4/ ");
614 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/b5/ To: alces/export/home/b5/ ");
615 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/c1/ To: alces/export/home/c1/ ");
616 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/c2/ To: alces/export/home/c2/ ");
617 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/c3/ To: alces/export/home/c3/ ");
618 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/c4/ To: alces/export/home/c4/ ");
619 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/c5/ To: alces/export/home/c5/ ");
620 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/d1/ To: alces/export/home/d1/ ");
621 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/d2/ To: alces/export/home/d2/ ");
622 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/d3/ To: alces/export/home/d3/ ");
623 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/d4/ To: alces/export/home/d4/ ");
624 assert(check.
get_line() && check.
str() ==
" From: alces:/export/home/d5/ To: alces/export/home/d5/ ");
625 assert(check.
get_line() && check.
str() ==
" From: alces:/var/spool/ To: alces/var/spool/ ");
627 assert(check.
get_line() && check.
str() ==
" Start Time: 2004 Mar 31 21:32:10 Total Files: 119,743 Total Size: 9.5GB");
628 assert(check.
get_line() && check.
str() ==
" Stop Time: 2004 Mar 31 23:16:31 Xferd Files: 1 Xferd Size: 6.0KB");
629 assert(check.
get_line() && check.
str() ==
" Duration: 01:34:21 Percent: 0.0% Percent: 0.0%");
631 assert(check.
close());
632 assert(check.
remove(
"./test-table.txt"));
635 int main(
int argc,
char const * argv[])
size_type col_height(void) const
table & table_endl(table &a_table)
virtual size_type height(void) const
virtual void assign(const table &a_class)
An extended string class.
virtual void write(std::ostream &out, size_type a_line, size_type a_width) const
size_type col_width(const size_type a_x) const
virtual void write(std::ostream &out, size_type a_line, size_type a_width) const
static const size_type npos
table & table_skip(table &a_table)
size_type row_height(const size_type a_y) const
virtual size_type width(void) const
const std::string & str(void) const
virtual void insert_col(const size_type a_x)
const size_type nrows(void) const
int main(int argc, char const *argv[])
virtual void insert_row(const size_type a_y)
const size_type ncols(void) const
virtual size_type height(void) const
bool remove(const std::string &a_filename)
virtual void assign(const table_cell_estring &a_class)
virtual void resize(const size_type a_x, const size_type a_y)
alignment align(const alignment a_alignment)
Set the alignment used for formatted strings.
size_type row_width(void) const
virtual size_type width(void) const
bool open(const std::string &a_filename)