|
|
| version 1.194, 2003/11/25 15:41:57 | version 1.201, 2004/04/01 15:08:48 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b table parser class. | Parser: @b table parser class. |
| Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001-2004 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| */ | */ |
| Line 251 static void skip_empty_and_comment_lines | Line 251 static void skip_empty_and_comment_lines |
| while( char c=*data ) { | while( char c=*data ) { |
| if( c== '\n' || c == '#' ) { | if( c== '\n' || c == '#' ) { |
| /*nowhere=*/getrow(&data); // remove empty&comment lines | /*nowhere=*/getrow(&data); // remove empty&comment lines |
| *data_ref=data; | if(!(*data_ref=data)) |
| break; | |
| continue; | continue; |
| } | } |
| break; | break; |
| Line 335 static void _load(Request& r, MethodPara | Line 336 static void _load(Request& r, MethodPara |
| Table::element_type row(new ArrayString); | Table::element_type row(new ArrayString); |
| skip_empty_and_comment_lines(&data); | skip_empty_and_comment_lines(&data); |
| while( lsplit_result sr=lsplit(&data, separators.column, '\n', separators.encloser) ) { | while( lsplit_result sr=lsplit(&data, separators.column, '\n', separators.encloser) ) { |
| if(!sr.delim && !row->count()) // append last empty column [if without \n] | if(!*sr.piece && !sr.delim && !row->count()) // append last empty column [if without \n] |
| break; | break; |
| *row+=new String(sr.piece, 0, true); | *row+=new String(sr.piece, 0, true); |
| if(sr.delim=='\n') { | if(sr.delim=='\n') { |
| Line 629 static void _hash(Request& r, MethodPara | Line 630 static void _hash(Request& r, MethodPara |
| } else | } else |
| throw Exception("parser.runtime", | throw Exception("parser.runtime", |
| 0, | 0, |
| "value field(s) must be string or self_table" | "value field(s) must be string or table" |
| ); | ); |
| } else { // by all columns, including key | } else { // by all columns, including key |
| if(!(distinct!=D_ILLEGAL && distinct!=D_FIRST)) | if(!(distinct!=D_ILLEGAL && distinct!=D_FIRST)) |
| Line 644 static void _hash(Request& r, MethodPara | Line 645 static void _hash(Request& r, MethodPara |
| &r, | &r, |
| &self_table, | &self_table, |
| /*key_code=*/key_param->get_junction()?key_param:0, | /*key_code=*/key_param->get_junction()?key_param:0, |
| /*key_field=*/(info.key_code?-1 | /*key_field=*/0/*filled below*/, |
| :self_table.column_name2index(key_param->as_string(), true)), | |
| &value_fields, | &value_fields, |
| &result.hash(), | &result.hash(), |
| distinct, | distinct, |
| /*row=*/0 | /*row=*/0 |
| }; | }; |
| info.key_field=(info.key_code?-1 | |
| :self_table.column_name2index(key_param->as_string(), true)); | |
| int saved_current=self_table.current(); | int saved_current=self_table.current(); |
| self_table.for_each(table_row_to_hash, &info); | self_table.for_each(table_row_to_hash, &info); |