Aggiunto metodo set_key() ai recordarray
git-svn-id: svn://10.65.10.50/trunk@1742 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
4f13e4ddb2
commit
0a37576514
@ -69,7 +69,6 @@ protected: // TObject
|
||||
protected:
|
||||
const char* start(int nf) const;
|
||||
void setempty(bool val) { _isempty = val;} // Rende vero is_empty
|
||||
virtual RecDes* rec_des() const;
|
||||
|
||||
public: // TObject
|
||||
virtual TObject* dup() const; // Duplica record
|
||||
@ -138,7 +137,7 @@ public:
|
||||
TRectype& operator =(const char* rec); // assegnazione tra TRectype
|
||||
TRectype& operator =(const TBaseisamfile& f);
|
||||
|
||||
// const isdef* filehnd() const { return _i; } // Ritorna il file isam associato
|
||||
virtual RecDes* rec_des() const; // Ritorna il descrittore del record
|
||||
int num() const { return _logicnum;} // Ritorna il numero logico
|
||||
bool empty() const {return _isempty;} // Ritorna se e' vuoto
|
||||
bool valid() const {return _rec[0] == ' ';} // Ritorna se il record non e'cancellato
|
||||
|
@ -38,5 +38,6 @@
|
||||
#define PART_CHIUSA "CHIUSA"
|
||||
#define PART_DATARIFPAG "DATARIFPAG"
|
||||
#define PART_NUMRIFPAG "NUMRIFPAG"
|
||||
|
||||
#define PART_GRUPPOCL "GRUPPOCL"
|
||||
#define PART_CONTOCL "CONTOCL"
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
// $Id: relation.cpp,v 1.59 1995-08-23 14:33:45 guy Exp $
|
||||
// $Id: relation.cpp,v 1.60 1995-08-28 07:51:24 guy Exp $
|
||||
// relation.cpp
|
||||
// fv 12/8/93
|
||||
// relation class for isam files
|
||||
@ -1604,7 +1604,7 @@ TRecord_array::TRecord_array(int logicnum, const char* numfield, int first)
|
||||
|
||||
TRecord_array::TRecord_array(const TRecord_array& a)
|
||||
: TArray(a), _file(a._file), _offset(a._offset), _num(a._num)
|
||||
{}
|
||||
{}
|
||||
|
||||
const TRectype& TRecord_array::key() const
|
||||
{
|
||||
@ -1660,10 +1660,32 @@ bool TRecord_array::renum_key(const char* field, long num)
|
||||
return renum_key(field, n);
|
||||
}
|
||||
|
||||
void TRecord_array::set_key(TRectype* r)
|
||||
{
|
||||
CHECK(r->num() == _file, "Bad key record");
|
||||
add(r, 0); // Setta il nuovo campo chiave
|
||||
|
||||
if (rows() > 0)
|
||||
{
|
||||
const int numkey = 0; // Memento! Gli indici delle chiavi partono da zero!
|
||||
const RecDes* recd = r->rec_des(); // Descrizione del record della testata
|
||||
const KeyDes& kd = recd->Ky[numkey]; // Elenco dei campi chaive
|
||||
|
||||
// Copia tutti i campi chiave, tranne l'ultimo, in tutti i records
|
||||
for (int i = recd->Ky[numkey].NkFields-1; i >= 0; i--)
|
||||
{
|
||||
const int nf = kd.FieldSeq[i] % MaxFields;
|
||||
const RecFieldDes& rf = recd->Fd[nf];
|
||||
const TString& val = r->get(rf.Name);
|
||||
renum_key(rf.Name, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int TRecord_array::rec2row(const TRectype& r) const
|
||||
{
|
||||
CHECK(r.num() == key().num(), "Incompatible record");
|
||||
CHECK(r.num() == _file, "Incompatible record");
|
||||
const int n = atoi(r.get(_num)) - _offset; // Non e' detto che sia un int!
|
||||
CHECKD(n >= 0 && n < 30000, "Bad line number in record ", n + _offset);
|
||||
return n;
|
||||
@ -1701,7 +1723,7 @@ bool TRecord_array::destroy_row(int r, bool pack)
|
||||
|
||||
void TRecord_array::destroy_rows()
|
||||
{
|
||||
for (int i = last(); i > 0; i--)
|
||||
for (int i = last(); i > 0; i = pred(i))
|
||||
destroy(i);
|
||||
}
|
||||
|
||||
@ -1711,7 +1733,7 @@ int TRecord_array::read(TRectype* filter)
|
||||
CHECKS(filter->get(_num).empty(), "You can't specify in the filter the field ", (const char*)_num);
|
||||
|
||||
destroy();
|
||||
add(filter, 0); // Store filter record for later use
|
||||
set_key(filter);
|
||||
|
||||
int err = NOERR;
|
||||
if (!filter->empty())
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: relation.h,v 1.26 1995-08-24 12:47:05 angelo Exp $ */
|
||||
/* $Id: relation.h,v 1.27 1995-08-28 07:51:30 guy Exp $ */
|
||||
// join.h
|
||||
// fv 12/8/93
|
||||
// join class for isam files
|
||||
@ -160,6 +160,7 @@ public:
|
||||
virtual bool destroy_row(const TRectype& r, bool pack = FALSE) { return destroy_row(rec2row(r), pack); }
|
||||
void destroy_rows(); // Cancella tutte le righe
|
||||
|
||||
void set_key(TRectype* r); // Cambia l'intera chiave (solo se vuoto!)
|
||||
bool renum_key(const char* field, const TString& num);
|
||||
bool renum_key(const char* field, long num); // Rinumera campo chiave in seguito a reinsert
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user