--- parser3/src/include/pa_table.h 2003/04/14 11:23:41 1.48.2.11.2.9 +++ parser3/src/include/pa_table.h 2017/02/07 22:00:37 1.70 @@ -1,14 +1,14 @@ /** @file Parser: table class decl. - Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ #ifndef PA_TABLE_H #define PA_TABLE_H -static const char* IDENT_TABLE_H="$Date: 2003/04/14 11:23:41 $"; +#define IDENT_PA_TABLE_H "$Id: pa_table.h,v 1.70 2017/02/07 22:00:37 moko Exp $" #include "pa_types.h" #include "pa_hash.h" @@ -32,17 +32,6 @@ class Table: public Array public: typedef ArrayString* columns_type; - struct Action_options { - size_t offset; - size_t limit; //< negative limit means 'all'. zero limit means 'nothing' - bool reverse; - bool defined; - - Action_options(): - offset(0), limit(ARRAY_OPTION_LIMIT_ALL), reverse(false), - defined(false) {} - }; - Table( columns_type acolumns, size_t initial_rows=3); @@ -53,7 +42,7 @@ public: /// moves @a current pointer void set_current(size_t acurrent) { - assert(acurrent - bool locate(bool (*func)(Table& self, I* info), void* info, Action_options& o) { - size_t count=this->count(); - if(!count || !o.limit) - return false; + 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(row>=count) - return false; - // max(limit) - size_t m=o.reverse? - o.offset - :count-o.offset; - if(!m) + if(o.reverse) { // reverse + for(size_t i=0; i + bool table_first_that(bool (*func)(Table& self, I info), I info, Action_options& o) { + if(!o.adjust(count())) return false; - // fix limit - if(o.limit==ARRAY_OPTION_LIMIT_ALL || o.limit>m) - o.limit=m; 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); + for(size_t i=0; inumber lookup table - typedef Hash name2number_hash_class; + /// column name->number lookup table + typedef HashString name2number_hash_class; name2number_hash_class* name2number; - // we own columns? - - bool valid(size_t index) const { return index>=0 && index