Eliminati ld*

Correzzioni ai multirec


git-svn-id: svn://10.65.10.50/trunk@4660 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1997-06-13 14:00:54 +00:00
parent 9b77c6ebca
commit dea93322f2
4 changed files with 60 additions and 175 deletions

View File

@ -1,69 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdtypes.h>
#include <strings.h>
#include <scanner.h>
#include <isam.h>
#include <tabutil.h>
int main(int argc,char** argv)
{
init_global_vars();
if (argc > 2)
{
argv++;
TScanner dfile(*argv);
TLocalisamfile* of;
TString s(dfile.line());
TToken_string w(s);
const char* work = w.get();
const int nf = atoi(work);
const TString nt(work);
const int reclen = w.get_int();
if (nf) of = new TLocalisamfile(nf);
else of = new TTable(nt);
TToken_string d(40, ',');
while (*(work = dfile.line()))
d.add(work);
argv++;
TScanner ifile(*argv);
TString name, just(3), ws(256);
while (*(work = ifile.line()))
{
s = work;
s.left_just(reclen);
d.restart();
of->zero();
w = d.get();
while (w.not_empty())
{
const int st = w.get_int();
const int len = w.get_int();
name = w.get();
if (name != "-")
{
ws = s.mid(st, len);
just = w.get();
if (just == "Z") ws.right_just(len, '0');
else
if (just == "R") ws.right_just(len);
else
if (just == "L") ws.left_just(len);
of->put(name, ws);
}
w = d.get();
}
of->write();
if (of->bad()) of->rewrite();
}
delete of;
}
free_global_vars();
}

View File

@ -1,79 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdtypes.h>
#include <strings.h>
#include <scanner.h>
#include <isam.h>
#include <tabutil.h>
#include <utility.h>
int main(int argc,char** argv)
{
init_global_vars();
if (argc > 2)
{
argv++;
TScanner dfile(*argv);
TLocalisamfile* of;
TString s(dfile.line());
TToken_string w(s);
const char* work = w.get();
const int nf = atoi(work);
const TString nt(work);
const int reclen = w.get_int();
if (nf) of = new TLocalisamfile(nf);
else of = new TTable(nt);
TToken_string d(40, ',');
while (*(work = dfile.line()))
d.add(work);
argv++;
TScanner ifile(*argv);
TString name, ws(256), depcom(10);
int ncodi = 2, ncodd = 2;
while (*(work = ifile.line()))
{
s = work;
s.left_just(reclen);
d.restart();
w = d.get();
int st = w.get_int();
int len = w.get_int();
name = w.get();
ws = s.mid(st, len);
if (ws != depcom)
{
if (depcom.not_empty()) of->rewrite();
ncodi = 2;
ncodd = 2;
of->zero();
of->put(name, ws);
of->read();
if (of->good()) depcom = ws;
else depcom = "";
}
w = d.get();
st = w.get_int();
len = w.get_int();
name = s.mid(st, len);
w = d.get();
st = w.get_int();
len = w.get_int();
ws = s.mid(st, len);
if (name == "UI")
name = format("UFFIVA%1d", ncodi++);
else
name = format("UFFIIDD%1d", ncodd++);
of->put(name, ws);
}
if (depcom.not_empty()) of->rewrite();
delete of;
}
free_global_vars();
}

View File

@ -18,18 +18,16 @@ void TMultiple_rectype::set_body_key(TRectype & rowrec)
void TMultiple_rectype::load_rows_file(int logicnum)
{
const int index = log2ind(logicnum);
TRectype & rec = get_body_record(logicnum);
set_body_key(rec);
TRectype * rec = new_body_record(logicnum);
set_body_key(*rec);
if (_files.objptr(index) == NULL)
{
// crea
TRecord_array * r = new TRecord_array(rec, (TString &) _numfields[index]);
_files.add( r, index);
} else {
// rilegge
((TRecord_array &)_files[index]).read(rec);
}
_changed[index]=FALSE;
// crea
TRecord_array * r = new TRecord_array(logicnum, (TString &) _numfields[index]);
_files.add( r, index);
}
((TRecord_array &)_files[index]).read(rec); // rilegge
_changed[index]=FALSE;
}
int TMultiple_rectype::find(int logicnum, const char * fieldname, const char * s, int from, bool reverse) const
@ -189,19 +187,47 @@ void TMultiple_rectype::zero(char c)
int TMultiple_rectype::read(TRectype & rec, word op, word lockop)
{
TLocalisamfile f(num());
int err = NOERR;
*this = rec;
_nuovo = FALSE;
int err = TRectype::read(f, op, lockop);
if (op == _isequal)
{
TRectype r(rec);
err = TRectype::read(f, op, lockop);
if (err != NOERR)
{
*this = r;
_nuovo = TRUE;
}
}
else
err = TRectype::read(f, op, lockop);
for (int i = _nfiles - 1; i >= 0 ; i--)
{
if (_autoload[i])
load_rows_file(_logicnums[i]);
else if (_files.objptr(i) != NULL)
_changed[i]=TRUE;
if (_nuovo)
{
TRecord_array * b = (TRecord_array *) _files.objptr(i);
if (b != NULL)
{
_changed[i] = FALSE;
b->destroy_rows();
TRectype * r = new_body_record(_logicnums[i]);
set_body_key(*r);
b->set_key(r);
}
}
else
{
if (_autoload[i])
load_rows_file(_logicnums[i]);
else
if (_files.objptr(i) != NULL)
_changed[i] = TRUE;
}
}
_nuovo = err != NOERR;
return err;
}
@ -212,7 +238,7 @@ int TMultiple_rectype::remove(TBaseisamfile & f) const
for (int i = _nfiles - 1; err == NOERR && i >= 0 ; i--)
{
TRecord_array & r = body(_logicnums[i]);
r.remove();
err = r.remove();
}
if (err == NOERR)
err = TRectype::remove(f);
@ -228,7 +254,7 @@ TMultiple_rectype::TMultiple_rectype(int hfn)
void TMultiple_rectype::enable_autoload(int logicnum,bool on)
{
const int index = log2ind(logicnum);
_autoload[index] = on;
_autoload[index] = on;
}
bool TMultiple_rectype::autoload_enabled(int logicnum)
@ -241,6 +267,7 @@ void TMultiple_rectype::add_file(int logicnum, const char * numfield)
{
CHECK(_nfiles < maxfiles, "Too many files added");
_logicnums[_nfiles] = logicnum;
_autoload[_nfiles] = FALSE;
_numfields.add(numfield, _nfiles++);
}
@ -262,6 +289,12 @@ TMultiple_rectype::TMultiple_rectype(const TMultiple_rectype& r)
// copia..
_nuovo=r._nuovo;
_nfiles=r._nfiles; // file delle righe
for (int i = _nfiles - 1; i >= 0; i--)
{
_logicnums[i] = r._logicnums[i];
_changed[i] = r._changed[i];
_autoload[i] = r._autoload[i];
}
_numfields=r._numfields;
}

View File

@ -46,7 +46,7 @@ protected:
// @cmember renumera le chiavi di tutti i corpi in base alla testata
virtual void renum_key();
// @cmember Genera il record del corpo
virtual TRectype & get_body_record(int logicnum = 0) { return *(new TRectype(logicnum ? logicnum : _logicnums[0])); }
virtual TRectype * new_body_record(int logicnum = 0) { return new TRectype(logicnum ? logicnum : _logicnums[0]); }
// @cmember Crea e carica il record array del corpo
virtual void load_rows_file(int logicnum);
// @cmember Ritorna l'indice di <p _files> del numero logico passato
@ -85,9 +85,9 @@ public:
void destroy_rows(int logicnum = 0) { body(logicnum).destroy_rows(); }
// @cmember Abilita il caricamento del corpo <par lognum> insieme alla testata
void enable_autoload(int lognum,bool on =TRUE);
void enable_autoload(int lognum,bool on =TRUE);
// @cmember Restituisce il flag di caricamento del corpo <par lognum> insieme alla testata
bool autoload_enabled(int lognum);
bool autoload_enabled(int lognum);
//***********************
// record e I/O
@ -100,16 +100,16 @@ public:
virtual void zero(char c = '\0');
virtual int read(TRectype & rec, word op = _isequal, word lockop = _nolock);
virtual int read(word op = _isequal, word lockop = _nolock) { return TMultiple_rectype::read(*this, op, lockop); }
int read(TBaseisamfile & f, word op = _isequal, word lockop = _nolock) { return TMultiple_rectype::read(f.curr(), op, lockop); }
virtual int read(word op = _isequal, word lockop = _nolock) { return read(*this, op, lockop); }
int read(TBaseisamfile & f, word op = _isequal, word lockop = _nolock) { return read(f.curr(), op, lockop); }
virtual int write(TBaseisamfile& f) const { return write_rewrite(f);}
virtual int rewrite(TBaseisamfile& f) const { return write_rewrite(f, TRUE);}
virtual int remove(TBaseisamfile& f) const;
int write() const { TBaseisamfile f(num()); return write(f);}
int rewrite() const { TBaseisamfile f(num()); return rewrite(f);}
int remove() const { TBaseisamfile f(num()); return remove(f);}
virtual int remove() const { TLocalisamfile f(num()); return remove(f);}
virtual int write() const { TLocalisamfile f(num()); return write(f);}
virtual int rewrite() const { TLocalisamfile f(num()); return rewrite(f);}
//**************************
// @cmember costruttore dal numero del file