Aggiunti metodi dup
git-svn-id: svn://10.65.10.50/trunk@3365 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
8657d05879
commit
db174ab6f9
@ -131,6 +131,14 @@ TDir::TDir () : _num(-1), _com(FALSE)
|
||||
zero ();
|
||||
}
|
||||
|
||||
TDir::TDir(const TDir & d)
|
||||
{
|
||||
_dir = new FileDes;
|
||||
*_dir = *d._dir;
|
||||
_num = d._num;
|
||||
_com = d._com;
|
||||
}
|
||||
|
||||
TDir::~TDir ()
|
||||
{
|
||||
delete _dir;
|
||||
@ -143,7 +151,7 @@ const char *TDir::name () const
|
||||
|
||||
const char *TDir::filename () const
|
||||
{
|
||||
strcpy(_files_tmp_string, _dir->SysName);
|
||||
strcpy(_files_tmp_string, CAddPref(_dir->SysName));
|
||||
strcat(_files_tmp_string, ".dbf");
|
||||
return _files_tmp_string;
|
||||
}
|
||||
@ -204,7 +212,7 @@ TRecnotype & TDir::flags () const
|
||||
return _dir->Flags;
|
||||
}
|
||||
|
||||
word & TDir::len ()
|
||||
word & TDir::len () const
|
||||
|
||||
{
|
||||
return (word &) _dir->LenR;
|
||||
@ -306,6 +314,13 @@ TTrec::TTrec ()
|
||||
_num = -1;
|
||||
}
|
||||
|
||||
TTrec::TTrec(const TTrec & r)
|
||||
{
|
||||
_rec = new RecDes;
|
||||
*_rec = *r._rec;
|
||||
_num = r._num;
|
||||
}
|
||||
|
||||
TTrec::~TTrec ()
|
||||
|
||||
{
|
||||
@ -321,7 +336,43 @@ int TTrec::compare(const TSortable & a) const
|
||||
|
||||
void TTrec::rehash()
|
||||
{
|
||||
setrdes (_rec);
|
||||
int pos, tmppos, nf, i;
|
||||
|
||||
for (i = 0; i < MaxFields; i++) _rec->SortFd[i] = INVFLD;
|
||||
if (_rec->NFields)
|
||||
{
|
||||
for (i = 0; i < _rec->NFields; i++)
|
||||
{
|
||||
nf = i;
|
||||
pos = hashfun(_rec->Fd[nf].Name);
|
||||
while (TRUE)
|
||||
{
|
||||
if (_rec->SortFd[pos] == INVFLD)
|
||||
{
|
||||
_rec->SortFd[pos] = (byte) nf;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strcmp(_rec->Fd[_rec->SortFd[pos]].Name, _rec->Fd[nf].Name) <= 0)
|
||||
{
|
||||
pos++;
|
||||
if (pos >= MaxFields)
|
||||
pos = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmppos = _rec->SortFd[pos];
|
||||
_rec->SortFd[pos] = (byte) nf;
|
||||
nf = tmppos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_rec->Fd[0].RecOff = 1;
|
||||
for (i = 1; i < _rec->NFields; i++)
|
||||
_rec->Fd[i].RecOff = _rec->Fd[i - 1].RecOff + _rec->Fd[i - 1].Len;
|
||||
}
|
||||
}
|
||||
|
||||
TTrec & TTrec::operator = (const TTrec & b)
|
||||
@ -363,7 +414,28 @@ void TTrec::put (
|
||||
void TTrec::zero ()
|
||||
|
||||
{
|
||||
zerordes (_rec);
|
||||
_rec->NFields = 0;
|
||||
for (int i = 0; i < MaxFields; i++)
|
||||
{
|
||||
strcpy(_rec->Fd[i].Name, "");
|
||||
_rec->Fd[i].TypeF = _nullfld;
|
||||
_rec->Fd[i].Len = 0;
|
||||
_rec->Fd[i].Dec = 0;
|
||||
_rec->Fd[i].RecOff = 0;
|
||||
_rec->SortFd[i] = INVFLD;
|
||||
}
|
||||
_rec->NKeys = 0;
|
||||
for (i = 1; i < MaxKeys; i++)
|
||||
{
|
||||
_rec->Ky[i].DupKeys = FALSE;
|
||||
_rec->Ky[i].NkFields = 0;
|
||||
for (int j = 0; j < MKFields; j++)
|
||||
{
|
||||
_rec->Ky[i].FieldSeq[j] = INVFLD;
|
||||
_rec->Ky[i].FromCh[j] = INVFLD;
|
||||
_rec->Ky[i].ToCh[j] = INVFLD;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int TTrec::status (TDirtype dirop) const
|
||||
|
@ -135,7 +135,7 @@ public:
|
||||
// @cmember Ritorna il flag del file selezionato
|
||||
TRecnotype& flags() const;
|
||||
// @cmember Ritorna la lunghezza del tracciato record in bytes
|
||||
word& len();
|
||||
word& len() const;
|
||||
// @cmember Ritorna lo stato d'errore del file
|
||||
int status(TDirtype dirtype = _nordir) const ;
|
||||
// @cmember Ritorna il numero di file presenti
|
||||
@ -161,7 +161,11 @@ public:
|
||||
// @cmember Controlla se il file e' attivato dalla chiave hardware.
|
||||
// Valido solo se prefhnd e settato a ""
|
||||
bool is_active() const;
|
||||
// @cmember Duplica il tracciato record
|
||||
virtual TObject* dup() const { return new TDir(*this);}
|
||||
|
||||
// @cmember Costruttore
|
||||
TDir(const TDir & d);
|
||||
// @cmember Costruttore
|
||||
TDir();
|
||||
// @cmember Distruttore
|
||||
@ -248,7 +252,11 @@ public:
|
||||
virtual void read_from(istream& in);
|
||||
void set_des(TConfig* c = NULL, const char* tab = "") { _des = c; _tab = tab;}
|
||||
#endif
|
||||
// @cmember Duplica il descrittore di file
|
||||
virtual TObject* dup() const { return new TTrec(*this);}
|
||||
|
||||
// @cmember Costruttore
|
||||
TTrec(const TTrec & r);
|
||||
// @cmember Costruttore
|
||||
TTrec();
|
||||
// @cmember Distruttore
|
||||
|
Loading…
x
Reference in New Issue
Block a user