Corretti alcuni metodi di TTRec:
len() : ritorna solo se il numero di campi e' > 0 operatore di uguaglianza: e' cambiato il criterio, non effettua piu' la memcmp() dump : corretto lo scarico per il nome delle tabelle. git-svn-id: svn://10.65.10.50/trunk@4343 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
2a87255bc6
commit
f91f9f442e
@ -13,6 +13,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <extcdecl.h>
|
#include <extcdecl.h>
|
||||||
|
#include <lffiles.h>
|
||||||
|
|
||||||
#define BLOCKLEN 512
|
#define BLOCKLEN 512
|
||||||
#define INVFLD 255
|
#define INVFLD 255
|
||||||
@ -366,7 +367,41 @@ TTrec::~TTrec ()
|
|||||||
int TTrec::compare(const TSortable & a) const
|
int TTrec::compare(const TSortable & a) const
|
||||||
{
|
{
|
||||||
const TTrec & r = (const TTrec &) a;
|
const TTrec & r = (const TTrec &) a;
|
||||||
const int res = memcmp ((const void *) _rec, (const void *) r._rec, sizeof (*_rec));
|
int res = 0;
|
||||||
|
|
||||||
|
if (_rec->NFields != r._rec->NFields || _rec->NKeys != r._rec->NKeys) // Confronta prima il numero dei campi o il numero delle chiavi
|
||||||
|
res = 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const int nkeys = _rec->NKeys;
|
||||||
|
for (int i=0; i<nkeys && res==0; i++) // scorre la lista delle chiavi (sono meno del numero di campi)
|
||||||
|
{
|
||||||
|
const KeyDes& k1 = _rec->Ky[i];
|
||||||
|
const KeyDes& k2 = r._rec->Ky[i];
|
||||||
|
if (k1.DupKeys != k2.DupKeys || k1.NkFields != k2.NkFields)
|
||||||
|
res = 1;
|
||||||
|
else
|
||||||
|
for (int j=0; j<k1.NkFields && res==0; j++)
|
||||||
|
if (k1.FieldSeq[j] != k2.FieldSeq[j] || k1.FromCh[j] != k2.FromCh[j]
|
||||||
|
|| (k1.FromCh[j] != INVFLD && k1.ToCh[j] != k2.ToCh[j]))
|
||||||
|
res = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res == 0) // se sono ancora uguali confronta tutti i campi
|
||||||
|
{
|
||||||
|
const int nflds = _rec->NFields;
|
||||||
|
for (int n=0; n<nflds && res==0; n++)
|
||||||
|
{
|
||||||
|
const RecFieldDes& r1 = _rec->Fd[n];
|
||||||
|
const RecFieldDes& r2 = r._rec->Fd[n];
|
||||||
|
if (r1.TypeF != r2.TypeF || r1.Len != r2.Len || r1.Dec != r2.Dec)
|
||||||
|
res = 1;
|
||||||
|
else
|
||||||
|
if (strcmp(r1.Name,r2.Name) != 0)
|
||||||
|
res = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -570,7 +605,7 @@ void TTrec::update_keydef (int key, const char *desc)
|
|||||||
|
|
||||||
_rec->Ky[key].FieldSeq[n] = i;
|
_rec->Ky[key].FieldSeq[n] = i;
|
||||||
_rec->Ky[key].FromCh[n] = INVFLD;
|
_rec->Ky[key].FromCh[n] = INVFLD;
|
||||||
_rec->Ky[key].FromCh[n] = INVFLD;
|
_rec->Ky[key].ToCh[n] = INVFLD;
|
||||||
inst = c.step ();
|
inst = c.step ();
|
||||||
sym = inst.getsym ();
|
sym = inst.getsym ();
|
||||||
if (sym == _upper)
|
if (sym == _upper)
|
||||||
@ -596,7 +631,7 @@ void TTrec::print_on (ostream & out) const
|
|||||||
{
|
{
|
||||||
const int n = num();
|
const int n = num();
|
||||||
out << n;
|
out << n;
|
||||||
if (_des && n>=3 && n<=5) // Solo se e' una tabella...
|
if (_des && n>=LF_TABGEN && n<=LF_TAB && _tab.not_empty()) // Solo se e' una tabella...
|
||||||
out << "|" << _tab;
|
out << "|" << _tab;
|
||||||
out << '\n';
|
out << '\n';
|
||||||
const int nfields = fields ();
|
const int nfields = fields ();
|
||||||
@ -628,7 +663,7 @@ void TTrec::read_from (istream & in)
|
|||||||
const int n = num();
|
const int n = num();
|
||||||
|
|
||||||
in.getline (_files_tmp_string, sizeof (_files_tmp_string), '\n');
|
in.getline (_files_tmp_string, sizeof (_files_tmp_string), '\n');
|
||||||
if (_des && n>=3 && n<=5)
|
if (_des && n>=LF_TABGEN && n<=LF_TAB)
|
||||||
{
|
{
|
||||||
TString t(_files_tmp_string);
|
TString t(_files_tmp_string);
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ public:
|
|||||||
const char* keydef(int key) const;
|
const char* keydef(int key) const;
|
||||||
// @cmember Ritorna la lunghezza del record
|
// @cmember Ritorna la lunghezza del record
|
||||||
int len() const
|
int len() const
|
||||||
{ return _rec->Fd[fields() - 1].RecOff + _rec->Fd[fields() - 1].Len; }
|
{ return fields() > 0 ? _rec->Fd[fields() - 1].RecOff + _rec->Fd[fields() - 1].Len : 0; }
|
||||||
|
|
||||||
#ifndef FOXPRO
|
#ifndef FOXPRO
|
||||||
// @cmember Aggiorna la chiave. <p desc> e' una token string
|
// @cmember Aggiorna la chiave. <p desc> e' una token string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user