Diff for /parser3/src/classes/table.C between versions 1.157 and 1.159

version 1.157, 2002/08/06 14:23:22 version 1.159, 2002/08/13 13:08:46
Line 40  static void get_copy_options(Request& r, Line 40  static void get_copy_options(Request& r,
                 return;                  return;
   
         Value& voptions=params->as_no_junction(param_index, "options must be hash, not code");          Value& voptions=params->as_no_junction(param_index, "options must be hash, not code");
         if(!voptions.is_string())          if(!voptions.is_string()) {
                 if(Hash *options=voptions.get_hash(&method_name)) {                  if(Hash *options=voptions.get_hash(&method_name)) {
                         if(Value *voffset=(Value *)options->get(*sql_offset_name))                          if(Value *voffset=(Value *)options->get(*sql_offset_name))
                                 if(voffset->is_string()) {                                  if(voffset->is_string()) {
Line 59  static void get_copy_options(Request& r, Line 59  static void get_copy_options(Request& r,
                         throw Exception("parser.runtime",                          throw Exception("parser.runtime",
                                 &method_name,                                  &method_name,
                                 "options must be hash");                                  "options must be hash");
           }
           if(!limit) // zero limit = sould be 'nothing to copy', for methods zero means 'all'
                   limit=-1; // thus fixing
 }  }
   
 static void _create(Request& r, const String& method_name, MethodParams *params) {  static void _create(Request& r, const String& method_name, MethodParams *params) {
Line 175  static void _save(Request& r, const Stri Line 178  static void _save(Request& r, const Stri
         Value& vfile_name=params->as_no_junction(params->size()-1,           Value& vfile_name=params->as_no_junction(params->size()-1, 
                 "file name must not be code");                  "file name must not be code");
   
         Table& table=static_cast<VTable *>(r.self)->table();          Table& table=static_cast<VTable *>(r.self)->table(&method_name);
   
         bool do_append=false;          bool do_append=false;
         String sdata(pool);          String sdata(pool);
Line 233  static void _save(Request& r, const Stri Line 236  static void _save(Request& r, const Stri
   
 static void _count(Request& r, const String& method_name, MethodParams *) {  static void _count(Request& r, const String& method_name, MethodParams *) {
         Pool& pool=r.pool();          Pool& pool=r.pool();
         int result=static_cast<VTable *>(r.self)->table().size();          int result=static_cast<VTable *>(r.self)->table(&method_name).size();
         r.write_no_lang(*new(pool) VInt(pool, result));          r.write_no_lang(*new(pool) VInt(pool, result));
 }  }
   
 static void _line(Request& r, const String& method_name, MethodParams *) {  static void _line(Request& r, const String& method_name, MethodParams *) {
         Pool& pool=r.pool();          Pool& pool=r.pool();
         int result=1+static_cast<VTable *>(r.self)->table().current();          int result=1+static_cast<VTable *>(r.self)->table(&method_name).current();
         r.write_no_lang(*new(pool) VInt(pool, result));          r.write_no_lang(*new(pool) VInt(pool, result));
 }  }
   
 static void _offset(Request& r, const String& method_name, MethodParams *params) {  static void _offset(Request& r, const String& method_name, MethodParams *params) {
         Pool& pool=r.pool();          Pool& pool=r.pool();
         Table& table=static_cast<VTable *>(r.self)->table();          Table& table=static_cast<VTable *>(r.self)->table(&method_name);
         if(params->size()) {          if(params->size()) {
                 bool absolute=false;                  bool absolute=false;
                 if(params->size()>1) {                  if(params->size()>1) {
Line 271  static void _menu(Request& r, const Stri Line 274  static void _menu(Request& r, const Stri
                   
         Value *delim_maybe_code=params->size()>1?&params->get(1):0;          Value *delim_maybe_code=params->size()>1?&params->get(1):0;
   
         Table& table=static_cast<VTable *>(r.self)->table();          Table& table=static_cast<VTable *>(r.self)->table(&method_name);
         bool need_delim=false;          bool need_delim=false;
         int saved_current=table.current();          int saved_current=table.current();
         int size=table.size();          int size=table.size();
Line 319  static void table_row_to_hash(Array::Ite Line 322  static void table_row_to_hash(Array::Ite
 }  }
 static void _hash(Request& r, const String& method_name, MethodParams *params) {  static void _hash(Request& r, const String& method_name, MethodParams *params) {
         Pool& pool=r.pool();          Pool& pool=r.pool();
         Table& self_table=static_cast<VTable *>(r.self)->table();          Table& self_table=static_cast<VTable *>(r.self)->table(&method_name);
         Value& result=*new(pool) VHash(pool);          Value& result=*new(pool) VHash(pool);
         if(const Array *columns=self_table.columns())          if(const Array *columns=self_table.columns())
                 if(columns->size()>0) {                  if(columns->size()>0) {
Line 388  static void _sort(Request& r, const Stri Line 391  static void _sort(Request& r, const Stri
                 reverse=params->as_no_junction(1, "order must not be code").as_string()=="desc":                  reverse=params->as_no_junction(1, "order must not be code").as_string()=="desc":
                 false; // default=asc                  false; // default=asc
   
         Table& old_table=static_cast<VTable *>(r.self)->table();          Table& old_table=static_cast<VTable *>(r.self)->table(&method_name);
         Table& new_table=*new(pool) Table(pool, &method_name, old_table.columns());          Table& new_table=*new(pool) Table(pool, &method_name, old_table.columns());
   
         Table_seq_item *seq=(Table_seq_item *)pool.malloc(sizeof(Table_seq_item)*old_table.size());          Table_seq_item *seq=(Table_seq_item *)pool.malloc(sizeof(Table_seq_item)*old_table.size());
Line 433  static bool _locate_expression(Request& Line 436  static bool _locate_expression(Request&
   
         Value& expression_code=params->as_junction(0, "must be expression");          Value& expression_code=params->as_junction(0, "must be expression");
   
         Table& table=static_cast<VTable *>(r.self)->table();          Table& table=static_cast<VTable *>(r.self)->table(&method_name);
         int saved_current=table.current();          int saved_current=table.current();
         int size=table.size();          int size=table.size();
         for(int row=0; row<size; row++) {          for(int row=0; row<size; row++) {
Line 451  static bool _locate_name_value(Request& Line 454  static bool _locate_name_value(Request&
                         &method_name,                          &method_name,
                         "locate by name and value has only two parameters - name and value");                          "locate by name and value has only two parameters - name and value");
   
         Table& table=static_cast<VTable *>(r.self)->table();          Table& table=static_cast<VTable *>(r.self)->table(&method_name);
         return table.locate(          return table.locate(
                 params->as_string(0, "column name must be string"),                  params->as_string(0, "column name must be string"),
                 params->as_string(1, "value must be string")                  params->as_string(1, "value must be string")
Line 467  static void _locate(Request& r, const St Line 470  static void _locate(Request& r, const St
   
 static void _flip(Request& r, const String& method_name, MethodParams *params) {  static void _flip(Request& r, const String& method_name, MethodParams *params) {
         Pool& pool=r.pool();          Pool& pool=r.pool();
         Table& old_table=static_cast<VTable *>(r.self)->table();          Table& old_table=static_cast<VTable *>(r.self)->table(&method_name);
         Table& new_table=*new(pool) Table(pool, &method_name, 0/*nameless*/);          Table& new_table=*new(pool) Table(pool, &method_name, 0/*nameless*/);
         if(old_table.size())          if(old_table.size())
                 if(int old_cols=old_table.at(0).size())                   if(int old_cols=old_table.at(0).size()) 
Line 494  static void _append(Request& r, const St Line 497  static void _append(Request& r, const St
         Array& row=*new(pool) Array(pool);          Array& row=*new(pool) Array(pool);
         string.split(row, 0, "\t", 1, String::UL_AS_IS);          string.split(row, 0, "\t", 1, String::UL_AS_IS);
   
         static_cast<VTable *>(r.self)->table()+=&row;          static_cast<VTable *>(r.self)->table(&method_name)+=&row;
 }  }
   
 static void _join(Request& r, const String& method_name, MethodParams *params) {  static void _join(Request& r, const String& method_name, MethodParams *params) {
Line 507  static void _join(Request& r, const Stri Line 510  static void _join(Request& r, const Stri
                         "source is not a table");                          "source is not a table");
   
         Table& src=*maybe_src;          Table& src=*maybe_src;
         Table& dest=static_cast<VTable *>(r.self)->table();          Table& dest=static_cast<VTable *>(r.self)->table(&method_name);
         if(&src == &dest)          if(&src == &dest)
                 throw Exception("parser.runtime",                   throw Exception("parser.runtime", 
                         &method_name,                           &method_name, 
Line 655  static void _columns(Request& r, const S Line 658  static void _columns(Request& r, const S
         result_columns+=new(pool) String(pool, "column");          result_columns+=new(pool) String(pool, "column");
         Table& result_table=*new(pool) Table(pool, &method_name, &result_columns);          Table& result_table=*new(pool) Table(pool, &method_name, &result_columns);
   
         Table& source_table=static_cast<VTable *>(r.self)->table();          Table& source_table=static_cast<VTable *>(r.self)->table(&method_name);
         if(const Array *source_columns=source_table.columns()) {          if(const Array *source_columns=source_table.columns()) {
                 Array_iter i(*source_columns);                  Array_iter i(*source_columns);
                 while(i.has_next()) {                  while(i.has_next()) {
Line 673  static void _select(Request& r, const St Line 676  static void _select(Request& r, const St
   
         Value& vcondition=params->as_junction(0, "condition must be expression");          Value& vcondition=params->as_junction(0, "condition must be expression");
   
         Table& source_table=static_cast<VTable *>(r.self)->table();          Table& source_table=static_cast<VTable *>(r.self)->table(&method_name);
         Table& result_table=*new(pool) Table(pool,           Table& result_table=*new(pool) Table(pool, 
                 source_table.origin_string(),                   source_table.origin_string(), 
                 source_table.columns()                  source_table.columns()

Removed from v.1.157  
changed lines
  Added in v.1.159


E-mail: