Corretta la renum_key
git-svn-id: svn://10.65.10.50/trunk@4921 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
1e56247292
commit
09d80ab702
@ -105,9 +105,6 @@ bool TRecord_array::renum_key(
|
|||||||
|
|
||||||
{
|
{
|
||||||
CHECKS(_num != field, "You can't renumber field ", field);
|
CHECKS(_num != field, "You can't renumber field ", field);
|
||||||
const TString& curr = key().get(field);
|
|
||||||
if (curr == num)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
for (int i = _data.last(); i >= 0; i--)
|
for (int i = _data.last(); i >= 0; i--)
|
||||||
{
|
{
|
||||||
@ -158,16 +155,10 @@ int TRecord_array::insert_row(TRectype* r)
|
|||||||
int TRecord_array::add_row(TRectype* r)
|
int TRecord_array::add_row(TRectype* r)
|
||||||
{
|
{
|
||||||
const int nr = rec2row(*r);
|
const int nr = rec2row(*r);
|
||||||
_data.add(r, nr);
|
if (nr==0)
|
||||||
if (nr == 0 && rows() > 0) // Se ho cambiato il record campione
|
set_key(r);
|
||||||
{ // e ci sono altre righe ...
|
else
|
||||||
for (int f = r->items()-1; f >= 0; f--)
|
_data.add(r, nr);
|
||||||
{
|
|
||||||
const char* fn = r->fieldname(f);
|
|
||||||
const TString& v = r->get(fn);
|
|
||||||
if (v.not_empty()) renum_key(fn, v); // ... aggiorna tutte le righe in base
|
|
||||||
} // ai campi non vuoti del campione
|
|
||||||
}
|
|
||||||
return nr;
|
return nr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,16 +238,17 @@ bool TRecord_array::good(
|
|||||||
|
|
||||||
int TRecord_array::read(TRectype* filter)
|
int TRecord_array::read(TRectype* filter)
|
||||||
{
|
{
|
||||||
|
CHECK(filter != NULL , "You can't specify NULL as filter ");
|
||||||
CHECKD(filter->num() == _file, "Bad key record ", filter->num());
|
CHECKD(filter->num() == _file, "Bad key record ", filter->num());
|
||||||
CHECKS(filter->get(_num).empty(), "You can't specify in the filter the field ", (const char*)_num);
|
CHECKS(filter->get(_num).empty(), "You can't specify in the filter the field ", (const char*)_num);
|
||||||
|
|
||||||
_data.destroy();
|
_data.destroy();
|
||||||
|
set_key(filter);
|
||||||
int err = NOERR;
|
int err = NOERR;
|
||||||
if (filter != NULL && !filter->empty())
|
if (!filter->empty())
|
||||||
{
|
{
|
||||||
TLocalisamfile f(_file);
|
TLocalisamfile f(_file);
|
||||||
|
|
||||||
set_key(filter);
|
|
||||||
TRectype* rec = (TRectype*)filter->dup();
|
TRectype* rec = (TRectype*)filter->dup();
|
||||||
err = rec->read(f, _isgteq);
|
err = rec->read(f, _isgteq);
|
||||||
for (int e = err; e == NOERR && good(*rec); e = rec->next(f))
|
for (int e = err; e == NOERR && good(*rec); e = rec->next(f))
|
||||||
@ -265,7 +257,8 @@ int TRecord_array::read(TRectype* filter)
|
|||||||
rec = (TRectype*)(key().dup());
|
rec = (TRectype*)(key().dup());
|
||||||
}
|
}
|
||||||
delete rec;
|
delete rec;
|
||||||
}
|
} else
|
||||||
|
err = _iskeynotfound;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,6 +304,9 @@ int TRecord_array::write(bool re) const
|
|||||||
|
|
||||||
TLocalisamfile f(_file);
|
TLocalisamfile f(_file);
|
||||||
const int u = _data.last();
|
const int u = _data.last();
|
||||||
|
|
||||||
|
//TRectype* rec = (TRectype*)key().dup();
|
||||||
|
CHECK(u<1 || !key().empty(), "Can't write rows using an empty key");
|
||||||
for (int i = 1; i <= u; i++)
|
for (int i = 1; i <= u; i++)
|
||||||
{
|
{
|
||||||
const TRectype* r = (TRectype*)_data.objptr(i);
|
const TRectype* r = (TRectype*)_data.objptr(i);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user