--- parser3/src/classes/table.C 2009/08/31 08:28:53 1.265 +++ parser3/src/classes/table.C 2009/11/09 00:31:07 1.269 @@ -5,11 +5,10 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_TABLE_C="$Date: 2009/08/31 08:28:53 $"; +static const char * const IDENT_TABLE_C="$Date: 2009/11/09 00:31:07 $"; #if (!defined(NO_STRINGSTREAM) && !defined(FREEBSD4)) #include -using namespace std; #endif #include "classes.h" @@ -55,12 +54,12 @@ String table_reverse_name(TABLE_REVERSE_ // methods static Table::Action_options get_action_options(Request& r, MethodParams& params, - const Table& source) { + size_t options_index, const Table& source) { Table::Action_options result; - if(!params.count()) + if(params.count() <= options_index) return result; - Value& maybe_options=params.last(); + Value& maybe_options=params[options_index]; /* can not do it: want to enable ^table::create[$source; # $.option[] @@ -157,7 +156,7 @@ struct TableSeparators { static void _create(Request& r, MethodParams& params) { // clone/copy part? if(Table *source=params[0].get_table()) { - Table::Action_options o=get_action_options(r, params, *source); + Table::Action_options o=get_action_options(r, params, 1, *source); check_option_param(o.defined, params, 1, "too many parameters"); GET_SELF(r, VTable).set_table(*new Table(*source, o)); @@ -388,7 +387,12 @@ static void _load(Request& r, MethodPara #if (!defined(NO_STRINGSTREAM) && !defined(FREEBSD4)) -void maybe_enclose( ostringstream& to, const String& from, char encloser ) { +#include "gc_allocator.h" + +typedef std::basic_stringstream, gc_allocator > pa_stringstream; +typedef std::basic_string, gc_allocator > pa_string; + +void maybe_enclose( pa_stringstream& to, const String& from, char encloser ) { if(encloser) { to<count()) throw Exception(PARSER_RUNTIME, 0, - "invalid option passed"); + INVALID_OPTION_PASSED); } else { throw Exception(PARSER_RUNTIME, 0, @@ -479,7 +483,7 @@ static void _save(Request& r, MethodPara #if (!defined(NO_STRINGSTREAM) && !defined(FREEBSD4)) - ostringstream ost(stringstream::out); + pa_stringstream ost(std::stringstream::out); // process header if(output_column_names) { @@ -521,10 +525,10 @@ static void _save(Request& r, MethodPara // write { - string data=ost.str(); + pa_string data=ost.str(); const char* data_cstr=data.c_str(); - file_write(file_spec, data_cstr, data.length(), true /* as text */, do_append); + file_write(r.charsets, file_spec, data_cstr, data.length(), true /* as text */, do_append); } #else @@ -566,8 +570,7 @@ static void _save(Request& r, MethodPara // write { const char* data_cstr=sdata.cstr(); - file_write(file_spec, - data_cstr, sdata.length(), true, do_append); + file_write(r.charsets, file_spec, 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 } @@ -920,7 +923,7 @@ static void _sort(Request& r, MethodPara seq[i].value.c_str=Charset::transcode(seq[i].value.c_str, r.charsets.source(), UTF8_charset).cstr(); } -// sort keys + // sort keys _qsort(seq, old_count, sizeof(Table_seq_item), key_values_are_strings?sort_cmp_string:sort_cmp_double); @@ -963,7 +966,7 @@ static bool _locate_name_value(Table& ta static void _locate(Request& r, MethodParams& params) { Table& table=GET_SELF(r, VTable).table(); - Table::Action_options o=get_action_options(r, params, table); + Table::Action_options o=get_action_options(r, params, 1, table); bool result=params[0].get_junction()? _locate_expression(table, o, r, params) : @@ -990,9 +993,8 @@ static void _flip(Request& r, MethodPara } static void _append(Request& r, MethodParams& params) { - // data Temp_lang temp_lang(r, String::L_PASS_APPENDED); - const String& string=r.process_to_string(params.as_junction(0, "body must be code")); + const String& string=r.process_to_string(params[0]); // parse cells Table::element_type row=new ArrayString; @@ -1023,7 +1025,7 @@ static void _join(Request& r, MethodPara "source is not a table"); Table& src=*maybe_src; - Table::Action_options o=get_action_options(r, params, src); + Table::Action_options o=get_action_options(r, params, 1, src); check_option_param(o.defined, params, 1, "invalid extra parameter");