--- parser3/src/include/pa_table.h 2003/03/26 18:52:49 1.48.2.11.2.6 +++ parser3/src/include/pa_table.h 2003/11/20 15:35:30 1.54 @@ -8,7 +8,7 @@ #ifndef PA_TABLE_H #define PA_TABLE_H -static const char* IDENT_TABLE_H="$Date: 2003/03/26 18:52:49 $"; +static const char* IDENT_TABLE_H="$Date: 2003/11/20 15:35:30 $"; #include "pa_types.h" #include "pa_hash.h" @@ -34,19 +34,23 @@ 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), I 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 - typedef Hash name2number_hash_class; + /// column name->number lookup table + typedef Hash name2number_hash_class; name2number_hash_class* name2number; - // we own columns? - + /// is that @c index falid? bool valid(size_t index) const { return index>=0 && index