--- parser3/src/include/pa_table.h 2003/04/11 16:05:43 1.48.2.11.2.8 +++ parser3/src/include/pa_table.h 2015/08/04 21:10:17 1.67 @@ -1,14 +1,14 @@ /** @file Parser: table class decl. - Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2012 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/11 16:05:43 $"; +#define IDENT_PA_TABLE_H "$Id: pa_table.h,v 1.67 2015/08/04 21:10:17 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); @@ -52,11 +41,19 @@ public: columns_type columns() { return fcolumns; } /// moves @a current pointer - void set_current(size_t acurrent); /// @return current pointer + void set_current(size_t acurrent) { + assert(acurrent==0 || 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; - if(o.limit==ARRAY_OPTION_LIMIT_ALL) - o.limit=count; - size_t row=o.offset; + 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 - size_t to=row>o.limit?row-o.limit:0; - for(; row>=to; --row) { + 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; + + size_t saved_current=current(); + size_t row=o.offset; + if(o.reverse) { // reverse + 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