--- parser3/src/main/pa_table.C 2003/04/02 08:35:43 1.53.2.10.2.4 +++ parser3/src/main/pa_table.C 2003/11/20 15:35:32 1.57 @@ -5,13 +5,13 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_TABLE_C="$Date: 2003/04/02 08:35:43 $"; +static const char* IDENT_TABLE_C="$Date: 2003/11/20 15:35:32 $"; #include "pa_table.h" #include "pa_exception.h" -Table::Table(columns_type acolumns, int initial_rows): +Table::Table(columns_type acolumns, size_t initial_rows): Array(initial_rows), fcurrent(0), @@ -19,22 +19,22 @@ Table::Table(columns_type acolumns, int name2number(new name2number_hash_class) { if(fcolumns) { - size_t fcolumns_count=fcolumns->count(); - for(size_t i=0; iget(i); - name2number->put(name, i+1); + size_t number=1; + for(Array_iterator i(*fcolumns); i.has_next(); ) { + const String& name=*i.next(); + name2number->put(name, number++); } } } -Table::Table(const Table& src, int offset, int limit) : - Array(limit/*may be more than needed, no harm done*/), +Table::Table(const Table& src, Action_options& options) : + Array(options.limit==ARRAY_OPTION_LIMIT_ALL?0:options.limit/*may be more than needed, no harm done*/), fcurrent(0), fcolumns(src.fcolumns), name2number(src.name2number) { - append(src, offset, limit); + append(src, options.offset, options.limit, options.reverse); } int Table::column_name2index(const String& column_name, bool bark) const { @@ -58,21 +58,26 @@ const String* Table::item(size_t column) return 0; // it's OK we don't have row|column, just return nothing } -bool Table::locate(size_t column, const String& value) { - size_t scurrent=fcurrent; - size_t lcount=count(); - for(fcurrent=0; fcurrentcolumn); + return item_value && *item_value==*info->value; +} + +bool Table::locate(int column, const String& value, + Table::Action_options& options) { + Locate_int_string_info info={column, &value}; + return table_first_that(locate_int_string, &info, options); +} + +bool Table::locate(const String& column, const String& value, + Table::Action_options& options) { + return locate(column_name2index(column, true), value, options); } void Table::offset(bool absolute, int offset) {