|
|
| version 1.217, 2005/11/25 09:52:07 | version 1.220, 2006/01/20 11:28:44 |
|---|---|
| Line 331 static void _load(Request& r, MethodPara | Line 331 static void _load(Request& r, MethodPara |
| } | } |
| Table& table=*new Table(columns); | Table& table=*new Table(columns); |
| int columns_count=columns? columns->count(): 0; | |
| // parse cells | // parse cells |
| Table::element_type row(new ArrayString); | Table::element_type row(new ArrayString(columns_count)); |
| 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.piece && !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] |
| Line 341 static void _load(Request& r, MethodPara | Line 342 static void _load(Request& r, MethodPara |
| *row+=new String(sr.piece, 0, true); | *row+=new String(sr.piece, 0, true); |
| if(sr.delim=='\n') { | if(sr.delim=='\n') { |
| table+=row; | table+=row; |
| row=new ArrayString; | row=new ArrayString(columns_count); |
| skip_empty_and_comment_lines(&data); | skip_empty_and_comment_lines(&data); |
| } | } |
| } | } |
| Line 358 static void maybe_enclose( String& to, c | Line 359 static void maybe_enclose( String& to, c |
| to<<*sencloser; | to<<*sencloser; |
| // while we have 'encloser'... | // while we have 'encloser'... |
| size_t pos_after=0; | size_t pos_after=0; |
| for( size_t pos_before; (pos_before=from.pos( encloser, pos_after ))!=STRING_NOT_FOUND; pos_after=pos_before+1) { | for( size_t pos_before; (pos_before=from.pos( encloser, pos_after ))!=STRING_NOT_FOUND; pos_after=pos_before) { |
| to<<from.mid(pos_before+1/*+found encloser*/, pos_after-pos_before); | pos_before++; // including first encloser (and skipping it for next pos) |
| to<<*sencloser; to<<*sencloser; // doubling encloser | to<<from.mid(pos_after, pos_before); |
| to<<*sencloser; // doubling encloser | |
| } | } |
| // last piece | // last piece |
| size_t from_length=from.length(); | size_t from_length=from.length(); |
| Line 845 static void _join(Request& r, MethodPara | Line 847 static void _join(Request& r, MethodPara |
| #ifndef DOXYGEN | #ifndef DOXYGEN |
| class Table_sql_event_handlers: public SQL_Driver_query_event_handlers { | class Table_sql_event_handlers: public SQL_Driver_query_event_handlers { |
| ArrayString& columns; | ArrayString& columns; |
| int columns_count; | |
| ArrayString* row; | ArrayString* row; |
| public: | public: |
| Table* table; | Table* table; |
| Line 865 public: | Line 868 public: |
| bool before_rows(SQL_Error& error) { | bool before_rows(SQL_Error& error) { |
| try { | try { |
| table=new Table(&columns); | table=new Table(&columns); |
| columns_count=columns.count(); | |
| return false; | return false; |
| } catch(...) { | } catch(...) { |
| error=SQL_Error("exception occured in Table_sql_event_handlers::before_rows"); | error=SQL_Error("exception occured in Table_sql_event_handlers::before_rows"); |
| Line 873 public: | Line 877 public: |
| } | } |
| bool add_row(SQL_Error& error) { | bool add_row(SQL_Error& error) { |
| try { | try { |
| *table+=row=new ArrayString; | *table+=row=new ArrayString(columns_count); |
| return false; | return false; |
| } catch(...) { | } catch(...) { |
| error=SQL_Error("exception occured in Table_sql_event_handlers::add_row"); | error=SQL_Error("exception occured in Table_sql_event_handlers::add_row"); |