--- parser3/src/targets/parser/Attic/parser.C 2001/01/30 13:07:31 1.2 +++ parser3/src/targets/parser/Attic/parser.C 2001/01/30 14:57:42 1.4 @@ -1,5 +1,5 @@ /* - $Id: parser.C,v 1.2 2001/01/30 13:07:31 paf Exp $ + $Id: parser.C,v 1.4 2001/01/30 14:57:42 paf Exp $ */ #include @@ -9,7 +9,7 @@ #include "pa_array.h" #include "pa_table.h" #include "pa_common.h" -#include "pool.h" +#include "pa_pool.h" char *itoa(int n, char *buf){ snprintf(buf,MAX_STRING,"%d",n); @@ -19,7 +19,7 @@ char *itoa(int n, char *buf){ int main(int argc, char *argv[]) { Exception fatal_exception; if(EXCEPTION_TRY(fatal_exception)) { - parser_Pool pool(fatal_exception); + Pool pool(fatal_exception); char *file="file1"; String& string=pool.make_string(); @@ -73,49 +73,56 @@ int main(int argc, char *argv[]) { asum.get_cstr(0), asum.get_cstr(1)); - parser_Pool request_pool(fatal_exception); + Pool request_pool(fatal_exception); Request request(request_pool); Exception operator_exception; Local_request_exception subst(request, operator_exception); if(EXCEPTION_TRY(request.exception())) { + /* Array acolumns(request.pool()); acolumns+="id"; acolumns+="name"; acolumns+="age"; - Table named_table(request, "_file.cfg", 1, &acolumns); + Table table(request, "_file.cfg", 1, &acolumns); + */ + Table table(request, "_file.cfg", 1, 0); for(int n=1; n<=5; n++) { - Array& row=request.pool().make_array(named_table.columns()->size()); + Array& row=request.pool().make_array(3/*table.columns()->size()*/); char *buf=static_cast(request.pool().malloc(MAX_STRING)); row+=itoa(n, buf); row+="paf"; row+="99"; - named_table+=&row; + table+=&row; } - - for(int i=0; isize(); i++) - printf("%s\t", named_table.columns()->get_cstr(i)); + /* + for(int i=0; isize(); i++) + printf("%s\t", table.columns()->get_cstr(i)); printf("\n"); - for(named_table.set_current(0); named_table.get_current()size(); i++) { - //String name(request.pool()); - //char *buf=static_cast(request.pool().malloc(MAX_STRING)); - //name.APPEND(itoa(i, buf), "names file", 0); + for(int i=0; i<5/*table.columns()->size()*/; i++) { + /**/ + String name(request.pool()); + char *buf=static_cast(request.pool().malloc(MAX_STRING)); + name.APPEND(itoa(i, buf), "names file", 0); //name.APPEND("id", "names file", 0); - //named_table.read_item(line, name); - const char *cstr_name=named_table.columns()->get_cstr(i); + table.read_item(line, name); + /* + const char *cstr_name=table.columns()->get_cstr(i); String name(request.pool()); name.APPEND(cstr_name, 0, 0); - named_table.read_item(line, name); + table.read_item(line, name); + /**/ line.APPEND("\t", 0, 0); } printf("%s\n", line.cstr()); } } else { - printf("operator_error occured: \n"); Exception& e=request.exception(); + printf("operator_error occured: %s\n", e.comment()); const String *type=e.type(); if(type) { printf(" type: %s", type->cstr()); @@ -127,11 +134,10 @@ int main(int argc, char *argv[]) { const String *problem_source=e.problem_source(); if(problem_source) { const Origin& origin=problem_source->origin(); - printf(" origin: '%s', file '%s', line %d\n", + printf(" '%s' [%s:%d]\n", problem_source->cstr(), origin.file, origin.line); } - printf(" comment: %s\n", e.comment()); } } else { printf("fatal exception occured: %s\n", fatal_exception.comment());