--- parser3/src/main/pa_table.C 2015/10/26 01:21:59 1.69 +++ parser3/src/main/pa_table.C 2020/12/25 22:05:31 1.72 @@ -1,24 +1,23 @@ /** @file Parser: table class. - Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ #include "pa_table.h" -volatile const char * IDENT_PA_TABLE_C="$Id: pa_table.C,v 1.69 2015/10/26 01:21:59 moko Exp $" IDENT_PA_TABLE_H; +volatile const char * IDENT_PA_TABLE_C="$Id: pa_table.C,v 1.72 2020/12/25 22:05:31 moko Exp $" IDENT_PA_TABLE_H; #include "pa_exception.h" -Table::Table(columns_type acolumns, size_t initial_rows): - Array(initial_rows), - - fcurrent(0), - fcolumns(acolumns), - name2number(new name2number_hash_class) { +Table::Table(columns_type acolumns, size_t initial_rows): Array(initial_rows), fcurrent(0), fcolumns(acolumns), name2number(NULL){ + column_names_init(); +} - if(fcolumns) { +void Table::column_names_init(){ + if(fcolumns){ + name2number = new name2number_hash_class; size_t number=1; for(Array_iterator i(*fcolumns); i.has_next(); ) { const String& name=*i.next(); @@ -58,9 +57,7 @@ int Table::column_name2index(const Strin if(fcolumns) {// named int result=name2number->get(column_name)-1; // -1 = column not found if(bark && result<0) - throw Exception(PARSER_RUNTIME, - &column_name, - "column not found"); + throw Exception(PARSER_RUNTIME, &column_name, "column not found"); return result; } else // nameless return column_name.as_int(); @@ -107,14 +104,12 @@ bool locate_int_string(Table& self, Loca return item_value && *item_value==*info->value; } -bool Table::locate(int column, const String& value, - Table::Action_options& options) { +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) { +bool Table::locate(const String& column, const String& value, Table::Action_options& options) { return locate(column_name2index(column, true), value, options); }