--- parser3/src/main/pa_table.C 2001/03/21 14:06:46 1.16 +++ parser3/src/main/pa_table.C 2001/03/26 10:36:56 1.19 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_table.C,v 1.16 2001/03/21 14:06:46 paf Exp $ + $Id: pa_table.C,v 1.19 2001/03/26 10:36:56 paf Exp $ */ #include @@ -14,12 +14,12 @@ #include "pa_pool.h" Table::Table(Pool& apool, - const String& asource, + const String *aorigin_string, Array *acolumns, int initial_rows) : Array(apool, initial_rows), - fsource(asource), + forigin_string(aorigin_string), fcurrent(0), fcolumns(acolumns), name2number(pool(), false) { @@ -56,3 +56,44 @@ const String *Table::item(const String& return item(column_index); } + +void Table::save(bool nameless_save, const String& file_spec) { + String sdata(pool()); + if(!nameless_save) { // not nameless=named output + // write out names line + if(fcolumns) { // named table + for(int column=0; columnsize(); column++) { + if(column) + sdata.APPEND_CONST("\t"); + sdata.append(*static_cast(fcolumns->quick_get(column)), + String::UL_TABLE); + } + } else { // nameless table + int lsize=size()?static_cast(get(0))->size():0; + if(lsize) + for(int column=0; column(quick_get(index)); + for(int column=0; columnsize(); column++) { + if(column) + sdata.APPEND_CONST("\t"); + sdata.append(*static_cast(row->quick_get(column)), + String::UL_TABLE); + } + sdata.APPEND_CONST("\n"); + } + + // write + char *cdata=sdata.cstr(); + file_write(pool(), file_spec, cdata, strlen(cdata), true); +} \ No newline at end of file