Diff for /parser3/src/main/pa_table.C between versions 1.70 and 1.75

version 1.70, 2017/02/07 22:00:44 version 1.75, 2024/09/07 16:30:27
Line 1 Line 1
 /** @file  /** @file
         Parser: table class.          Parser: table class.
   
         Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com)          Copyright (c) 2001-2023 Art. Lebedev Studio (http://www.artlebedev.com)
         Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)          Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru>
 */  */
   
 #include "pa_table.h"  #include "pa_table.h"
Line 11  volatile const char * IDENT_PA_TABLE_C=" Line 11  volatile const char * IDENT_PA_TABLE_C="
   
 #include "pa_exception.h"  #include "pa_exception.h"
   
 Table::Table(columns_type acolumns, size_t initial_rows):  Table::Table(columns_type acolumns, size_t initial_rows): Array<element_type>(initial_rows), fcurrent(0), fcolumns(acolumns), name2number(NULL){
         Array<element_type>(initial_rows),          column_names_init();
   }
         fcurrent(0),  
         fcolumns(acolumns),   
         name2number(new name2number_hash_class) {  
   
         if(fcolumns) {  void Table::column_names_init(){
           if(fcolumns){
                   name2number = new name2number_hash_class;
                 size_t number=1;                  size_t number=1;
                 for(Array_iterator<const String*> i(*fcolumns); i.has_next(); ) {                  for(ArrayString::Iterator i(*fcolumns); i; ) {
                         const String& name=*i.next();                          const String& name=*i.next();
                         name2number->put(name, number++);                          name2number->put(name, number++);
                 }                  }
Line 58  int Table::column_name2index(const Strin Line 57  int Table::column_name2index(const Strin
         if(fcolumns) {// named          if(fcolumns) {// named
                 int result=name2number->get(column_name)-1; // -1 = column not found                  int result=name2number->get(column_name)-1; // -1 = column not found
                 if(bark && result<0)                  if(bark && result<0)
                         throw Exception(PARSER_RUNTIME,                          throw Exception(PARSER_RUNTIME, &column_name, "column not found");
                                 &column_name,  
                                 "column not found");  
                 return result;                  return result;
         } else // nameless          } else // nameless
                 return column_name.as_int();                  return column_name.as_int();
Line 107  bool locate_int_string(Table& self, Loca Line 104  bool locate_int_string(Table& self, Loca
         return item_value && *item_value==*info->value;          return item_value && *item_value==*info->value;
 }  }
   
 bool Table::locate(int column, const String& value,  bool Table::locate(int column, const String& value, Table::Action_options& options) {
                    Table::Action_options& options) {  
         Locate_int_string_info info={column, &value};          Locate_int_string_info info={column, &value};
         return table_first_that(locate_int_string, &info, options);          return table_first_that(locate_int_string, &info, options);
 }  }
   
 bool Table::locate(const String& column, const String& value,   bool Table::locate(const String& column, const String& value, Table::Action_options& options) {
                    Table::Action_options& options) {  
         return locate(column_name2index(column, true), value, options);          return locate(column_name2index(column, true), value, options);
 }  }
   

Removed from v.1.70  
changed lines
  Added in v.1.75


E-mail: