--- parser3/src/classes/table.C 2008/02/14 09:10:24 1.239 +++ parser3/src/classes/table.C 2008/04/07 15:14:32 1.240 @@ -5,10 +5,12 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_TABLE_C="$Date: 2008/02/14 09:10:24 $"; +static const char * const IDENT_TABLE_C="$Date: 2008/04/07 15:14:32 $"; +#ifndef NO_STRINGSTREAM #include using namespace std; +#endif #include "classes.h" #include "pa_vmethod_frame.h" @@ -555,6 +557,8 @@ static void _save(Request& r, MethodPara Table& table=GET_SELF(r, VTable).table(); +#ifndef NO_STRINGSTREAM + ostringstream ost(stringstream::out); // process header @@ -602,6 +606,52 @@ static void _save(Request& r, MethodPara file_write(r.absolute(file_name), data_cstr, data.length(), true /* as text */, do_append); } + +#else + + String sdata; + if(output_column_names) { + if(table.columns()) { // named table + for(Array_iterator i(*table.columns()); i.has_next(); ) { + maybe_enclose( sdata, *i.next(), separators.encloser, separators.sencloser ); + if(i.has_next()) + sdata<<*separators.scolumn; + } + } else { // nameless table [we were asked to output column names] + if(int lsize=table.count()?table[0]->count():0) + for(int column=0; column i(table); + while(i.has_next()) { + for(Array_iterator c(*i.next()); c.has_next(); ) { + maybe_enclose( sdata, *c.next(), separators.encloser, separators.sencloser ); + if(c.has_next()) + sdata<<*separators.scolumn; + } + sdata.append_know_length("\n", 1, String::L_CLEAN); + } + + // write + { + const char* data_cstr=sdata.cstr(); + file_write(r.absolute(file_name), + data_cstr, sdata.length(), true, do_append); + if(*data_cstr) // not empty (when empty it's not heap memory) + pa_free((void*)data_cstr); // not needed anymore + } +#endif } static void _count(Request& r, MethodParams&) {