MOdifiche alla set_body_key
git-svn-id: svn://10.65.10.50/trunk@4540 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									e5ed2843ef
								
							
						
					
					
						commit
						a57c5678f1
					
				@ -1,5 +1,20 @@
 | 
			
		||||
#include <multirec.h>
 | 
			
		||||
 | 
			
		||||
void TMultiple_rectype::set_body_key(TRectype & rowrec)
 | 
			
		||||
{
 | 
			
		||||
  const RecDes* recd = rowrec.rec_des();    // Descrizione del record della testata
 | 
			
		||||
  const KeyDes& kd = recd->Ky[0];       // Elenco dei campi della chiave 1
 | 
			
		||||
  
 | 
			
		||||
    // Copia tutti i campi chiave, tranne l'ultimo, in tutti i records
 | 
			
		||||
  for (int i = kd.NkFields-2; i >= 0; i--)
 | 
			
		||||
  {                        
 | 
			
		||||
    const int nf = kd.FieldSeq[i] % MaxFields;
 | 
			
		||||
    const RecFieldDes& rf = recd->Fd[nf];  
 | 
			
		||||
    const TString& val = get(rf.Name);
 | 
			
		||||
    rowrec.renum_key(rf.Name, val);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TMultiple_rectype::load_rows_file(int logicnum)
 | 
			
		||||
{
 | 
			
		||||
  const int index = log2ind(logicnum);
 | 
			
		||||
@ -72,7 +87,9 @@ int TMultiple_rectype::write_rewrite(TBaseisamfile & f, bool re) const
 | 
			
		||||
      do
 | 
			
		||||
      {
 | 
			
		||||
        err = TRectype::write(f);
 | 
			
		||||
      } while (err == _isreinsert && ((TMultiple_rectype *)this)->renum());
 | 
			
		||||
        if (err == _isreinsert && ((TMultiple_rectype *)this)->renum())
 | 
			
		||||
           ((TMultiple_rectype *)this)->renum_key();
 | 
			
		||||
      } while (err == _isreinsert);
 | 
			
		||||
      ((TMultiple_rectype *)this)->_nuovo = (err != NOERR);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
@ -119,11 +136,20 @@ TRecord_array & TMultiple_rectype::body(int logicnum) const
 | 
			
		||||
  return (TRecord_array &) _files[index];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TMultiple_rectype::renum_key(const char * kfield,const char * val)
 | 
			
		||||
void TMultiple_rectype::renum_key()
 | 
			
		||||
{
 | 
			
		||||
  TRectype::renum_key(kfield, val);       // Aggiorna testata
 | 
			
		||||
  for (int i = _nfiles - 1; i >= 0 ; i--) 
 | 
			
		||||
   body(_logicnums[i]).renum_key(kfield, val); // Aggiorna righe
 | 
			
		||||
  {
 | 
			
		||||
    const int logicnum = _logicnums[i];
 | 
			
		||||
    TRecord_array * b = (TRecord_array *) _files.objptr(i);
 | 
			
		||||
    if (b)
 | 
			
		||||
    {
 | 
			
		||||
      TRectype * rec = new TRectype(b->key());
 | 
			
		||||
 | 
			
		||||
      set_body_key(*rec);
 | 
			
		||||
      b->set_key(rec); // Aggiorna righe
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -36,7 +36,7 @@ class TMultiple_rectype : public TAuto_variable_rectype
 | 
			
		||||
protected:
 | 
			
		||||
  const TArray & files() const { return _files;}
 | 
			
		||||
  // @ cmember funzione per costruire la chiave delle righe
 | 
			
		||||
  virtual void set_body_key(TRectype & rowrec) pure;
 | 
			
		||||
  virtual void set_body_key(TRectype & rowrec); 
 | 
			
		||||
  // @ cmember renumber la chiave del corpo
 | 
			
		||||
  virtual bool renum() { return FALSE; }
 | 
			
		||||
  virtual TRectype & get_body_record(int logicnum = 0) { return *(new TRectype(logicnum ? logicnum : _logicnums[0])); }
 | 
			
		||||
@ -75,7 +75,7 @@ public:
 | 
			
		||||
  virtual void set_fields(TAuto_variable_rectype & rec) {}
 | 
			
		||||
  virtual void reset_fields(TAuto_variable_rectype & rec) { rec.remove_field(); }
 | 
			
		||||
 | 
			
		||||
  virtual void renum_key(const char * kfield,const char * val);
 | 
			
		||||
  virtual void renum_key();
 | 
			
		||||
  virtual TRectype & operator =(const TRectype & r);
 | 
			
		||||
  virtual TRectype & operator =(const char * r);
 | 
			
		||||
  virtual void zero(char c = '\0');
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user