--- parser3/src/include/pa_table.h 2003/03/24 13:43:41 1.48.2.11.2.5 +++ parser3/src/include/pa_table.h 2003/07/24 11:31:21 1.52 @@ -8,7 +8,7 @@ #ifndef PA_TABLE_H #define PA_TABLE_H -static const char* IDENT_TABLE_H="$Date: 2003/03/24 13:43:41 $"; +static const char* IDENT_TABLE_H="$Date: 2003/07/24 11:31:21 $"; #include "pa_types.h" #include "pa_hash.h" @@ -34,25 +34,29 @@ public: Table( columns_type acolumns, - int initial_rows=3); - Table(const Table& src, int offset=0, int limit=0); + size_t initial_rows=3); + Table(const Table& src, Action_options& options); /// gets column names columns_type columns() { return fcolumns; } /// moves @a current pointer - void set_current(int acurrent) { fcurrent=acurrent; } + void set_current(size_t acurrent) { + assert(acurrent==0 || acurrent + void table_for_each(void (*func)(Table& self, I* info), I* info, Action_options& o) { + if(!o.adjust(count())) + return; + + size_t saved_current=current(); + size_t row=o.offset; + if(o.reverse) { // reverse + for(size_t to=row-o.limit; row>=to; --row) { + set_current(row); + func(*this, info); + } + } else { // forward + for(size_t to=row+o.limit; row + bool table_first_that(bool (*func)(Table& self, I* info), void* info, Action_options& o) { + if(!o.adjust(count())) + return false; + + size_t saved_current=current(); + size_t row=o.offset; + if(o.reverse) { // reverse + for(size_t to=row-o.limit; row>=to; --row) { + set_current(row); + + if(func(*this, info)) + return true; + } + } else { // forward + for(size_t to=row+o.limit; rownumber lookup table + /// column name->number lookup table typedef Hash name2number_hash_class; name2number_hash_class* name2number; - // we own columns? - - bool valid(int index) const { return index>=0 && index=0 && index