diff --git a/include/isam.cpp b/include/isam.cpp index caf4afcab..401cf2256 100755 --- a/include/isam.cpp +++ b/include/isam.cpp @@ -21,7 +21,7 @@ #include #include -#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_NT +#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32 #include #else #include @@ -419,7 +419,7 @@ HIDDEN int __build_key(RecDes *recd, int numkey, RecType recin, char *key, bool int w = l, j = l + len; while (w < j && key[w] == ' ') w++; while (w < j && key[w] == '0') key[w++] = ' '; - if (w == j) key[w-1] = build_x_cb ? '0' : 0xFF; + if (w == j) key[w-1] = build_x_cb ? '0' : null_char; } if (upp) for (int i = l+len-1; i >= l; i--) @@ -525,6 +525,7 @@ HIDDEN int cisread(isfdptr isfd, TRectype & record, int mode) return err; } +#ifndef CB6 HIDDEN int delkeys(isfdptr fd, char* record,long recno) { int rt=NOERR,oldkey = fd->knum; @@ -543,6 +544,8 @@ HIDDEN int delkeys(isfdptr fd, char* record,long recno) DB_tagselect(fd->fhnd,oldkey); return(rt); } +#endif + //////////////////////////////////////////////////////////////////////////////////////////////////// // Funzioni implementate per la gestione file dati tramite Codebase //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -641,72 +644,6 @@ TBaseisamfile::~TBaseisamfile() } -int TBaseisamfile::gethr(TRectype& rec, TDate& atdate) - -{ - TRecfield fd0(rec, RFLD_SYS_DATE); - TDate d0((const TDate&) fd0); - - if (d0 < atdate) - { - atdate = eotime; - return NOERR; - } - TRectype wr(rec); - - TRecfield flf(wr, RFLD_SYS_FIRST), - fll(wr, RFLD_SYS_LAST), - fd1(wr, RFLD_SYS_DATE); - - TDate d1; - TRecnotype wr0 = RECORD_NON_FISICO, wr1 = RECORD_NON_FISICO; - - if ((wr0 == flf.ptr()) == RECORD_NON_FISICO) return _iskeynotfound; - _hf.read(wr.string(), wr0); - if ((d1 = (const TDate&) fd1) > atdate) - { - rec = wr; - atdate = d0 - 1L; - return _iskeynotfound; - } - while ((d1 < atdate) && (wr0 > 0)) - { - rec = wr; - wr1 = wr0; - if ((wr0 = fll.ptr()) > 0) - { - _hf.read(wr.string(), wr0); - d1 = (const TDate&) fd1; - } - } - if (wr0 <= 0) - atdate = d0 - 1L; - else - atdate = d1 - 1L; - return NOERR; -} - - -int TBaseisamfile::addhr(const TRectype& rec, TDate& atdate) - -{ - return NOERR; -} - - -int TBaseisamfile::rewhr(const TRectype& rec, TDate& atdate) - -{ - return NOERR; -} - - -int TBaseisamfile::delhr(const TRectype& rec, TDate& atdate) - -{ - return NOERR; -} - long TBaseisamfile::items() const { NOT_OPEN(); @@ -835,15 +772,7 @@ int TBaseisamfile::_next(word lockop) int TBaseisamfile::next(word lockop) { - return curr().next(*this, lockop); -} - - -int TBaseisamfile::next(TDate& atdate) - -{ - error_box("TBaseisamfile::next(TDate&) is no more available"); - return NOERR; + return curr().next(*this, lockop); } @@ -871,13 +800,7 @@ int TBaseisamfile::prev(word lockop) } -int TBaseisamfile::prev(TDate& atdate) -{ - error_box("TBaseisamfile::prev(TDate&) is no more available"); - return NOERR; -} - -int TBaseisamfile::reread(word lockop, TDate& atdate) +int TBaseisamfile::reread(word lockop) { NOT_OPEN(); @@ -892,7 +815,7 @@ int TBaseisamfile::reread(word lockop, TDate& atdate) } -int TBaseisamfile::reread(TRectype& rec, word lockop, TDate& atdate) +int TBaseisamfile::reread(TRectype& rec, word lockop) { NOT_OPEN(); @@ -942,7 +865,7 @@ int TBaseisamfile::skip(TRecnotype nrec, word lockop) // funzione di lettura dei file -int TBaseisamfile::_read(TRectype& rec, word op, word lockop, TDate& atdate) +int TBaseisamfile::_read(TRectype& rec, word op, word lockop) { NOT_OPEN(); rec.setdirty(); @@ -954,30 +877,30 @@ int TBaseisamfile::_read(TRectype& rec, word op, word lockop, TDate& atdate) return _lasterr; } -int TBaseisamfile::read(TRectype& rec, word op, word lockop, TDate& atdate) +int TBaseisamfile::read(TRectype& rec, word op, word lockop) { // CHECKD(op >= _iscurr && op <= _isgteq, "Invalid read operation : ", op); NOT_OPEN(); - _lasterr=rec.read(*this, op, lockop, atdate); + _lasterr=rec.read(*this, op, lockop); return _lasterr; } -int TBaseisamfile::read(word op, word lockop, TDate& atdate) +int TBaseisamfile::read(word op, word lockop) { // CHECKD(op >= _iscurr && op <= _isgteq, "Invalid read operation : ", op); - return TBaseisamfile::read(curr(),op, lockop, atdate); + return TBaseisamfile::read(curr(),op, lockop); } int TBaseisamfile::readat(TRectype& rec, TRecnotype nrec, word lockop) { - return rec.readat(*this,nrec,lockop); + return rec.readat(*this,nrec,lockop); } int TBaseisamfile::readat(TRecnotype nrec, word lockop) { - return TBaseisamfile::readat(curr(),nrec,lockop); + return TBaseisamfile::readat(curr(),nrec,lockop); } @@ -990,14 +913,14 @@ int TBaseisamfile::_readat(TRectype& rec, TRecnotype nrec, word lockop) _lasterr = get_error(_lasterr); else rec = (const char *) DB_getrecord(_isamfile->fhnd); - _recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd); + _recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd); if( rec.has_memo( ) ) rec.init_memo( _recno ); return _lasterr; } -int TBaseisamfile::_write(const TRectype& rec, TDate& atdate) +int TBaseisamfile::_write(const TRectype& rec) { /* NOT_OPEN(); @@ -1044,21 +967,21 @@ int TBaseisamfile::_write(const TRectype& rec, TDate& atdate) return _lasterr; } -int TBaseisamfile::write(const TRectype& rec, TDate& atdate) +int TBaseisamfile::write(const TRectype& rec) { // CHECK(!rec.empty(), "Can't write an empty record"); - return rec.write(*this, atdate); + return rec.write(*this); } -int TBaseisamfile::write(TDate& atdate) +int TBaseisamfile::write() { // CHECK(!curr().empty(), "Can't write an empty record"); - return TBaseisamfile::write(curr(),atdate); + return TBaseisamfile::write(curr()); } -int TBaseisamfile::_rewrite(const TRectype& rec, TDate& atdate) +int TBaseisamfile::_rewrite(const TRectype& rec) { CHECK(!rec.empty(), "Can't write an empty record"); @@ -1088,17 +1011,17 @@ int TBaseisamfile::_rewrite(const TRectype& rec, TDate& atdate) return _lasterr; } -int TBaseisamfile::rewrite(const TRectype& rec, TDate& atdate) +int TBaseisamfile::rewrite(const TRectype& rec) { // CHECK(!rec.empty(), "Can't write an empty record"); - return rec.rewrite(*this,atdate); + return rec.rewrite(*this); } -int TBaseisamfile::rewrite(TDate& atdate) +int TBaseisamfile::rewrite() { -// CHECK(!curr().empty(), "Can't rewrite an empty record"); - return TBaseisamfile::rewrite(curr(),atdate); +// CHECK(!curr().empty(), "Can't rewrite an empty record"); + return TBaseisamfile::rewrite(curr()); } @@ -1128,98 +1051,48 @@ int TBaseisamfile::rewriteat(TRecnotype nrec) } -int TBaseisamfile::_remove(const TRectype& rec, TDate& atdate) +int TBaseisamfile::_remove(const TRectype& rec) { CHECK(!rec.empty(), "Can't remove an empty record"); NOT_OPEN(); memcpy(DB_getrecord(_isamfile->fhnd),rec.string(),DB_reclen(_isamfile->fhnd)); if ((_lasterr=cisread(_isamfile, (TRectype&) rec, _isequal + _nolock))==NOERR) - { - _lasterr = DB_delete(_isamfile->fhnd); // Put only deletion flag on record, must remove keys too! - if (_lasterr != NOERR) - _lasterr = get_error(_lasterr); - else - { - _lasterr=delkeys(_isamfile,rec.string(),_isamfile->RecNo); - if (_lasterr != NOERR) - { - DB_recall(_isamfile->fhnd); - _lasterr = get_error(_lasterr); - } - } - } - - if(_lasterr == NOERR && curr().has_memo()) - curr().memo_recno(); - - _recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd); - return _lasterr; -} - -int TBaseisamfile::remove(const TRectype& rec, TDate& atdate) -{ - /* old version: - CHECK(!rec.empty(), "Can't remove an empty record"); - - NOT_OPEN(); - memcpy(DB_getrecord(_isamfile->fhnd),rec.string(),DB_reclen(_isamfile->fhnd)); - if ((_lasterr=cisread(_isamfile, (TRectype&) rec, _isequal + _nolock))==NOERR) - { - _lasterr = DB_delete(_isamfile->fhnd); // Put only deletion flag on record, must remove keys too! - if (_lasterr != NOERR) - _lasterr = get_error(_lasterr); - else - { - _lasterr=delkeys(_isamfile,rec.string(),_isamfile->RecNo); - if (_lasterr != NOERR) - { - DB_recall(_isamfile->fhnd); - _lasterr = get_error(_lasterr); - } - } - } - - if(_lasterr == NOERR && curr().has_memo()) - curr().memo_recno(); - - _recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd); - return _lasterr; - */ - // new version: - return rec.remove(*this, atdate); -} - -int TBaseisamfile::remove(TDate& atdate) -{ -/* old version: - CHECK(!curr().empty(), "Can't remove empty record"); - - NOT_OPEN(); - - if ((_lasterr=cisread(_isamfile, curr(), _isequal + _nolock)) == NOERR) { _lasterr = DB_delete(_isamfile->fhnd); // Put only deletion flag on record, must remove keys too! - if (_lasterr != NOERR) + if (_lasterr != NOERR) + { _lasterr = get_error(_lasterr); + DB_recall(_isamfile->fhnd); + } +#ifndef CB6 else { - _lasterr=delkeys(_isamfile,curr().string(), _isamfile->RecNo); - if (_lasterr != NOERR) + _lasterr=delkeys(_isamfile,rec.string(),_isamfile->RecNo); + if (_lasterr != NOERR) { DB_recall(_isamfile->fhnd); - _lasterr = get_error(_lasterr); + _lasterr = get_error(_lasterr); } } +#endif } + if(_lasterr == NOERR && curr().has_memo()) curr().memo_recno(); - + _recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd); return _lasterr; - */ - // new version: - return TBaseisamfile::remove(curr(),atdate); +} + +int TBaseisamfile::remove(const TRectype& rec) +{ + return rec.remove(*this); +} + +int TBaseisamfile::remove() +{ + return TBaseisamfile::remove(curr()); } @@ -1591,7 +1464,7 @@ TIsamtempfile::TIsamtempfile(int logicnum, const char* radix, bool create) FILE* f = fopen(n, "r"); -#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_NT +#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32 CHECKS(f, "Can't open temporary file ", (const char*)_strerror(NULL)); #else CHECKS(f, "Can't open temporary file ", (const char*)n); @@ -3106,14 +2979,14 @@ TRectype& TRectype::operator =(const TBaseisamfile& f) } // Certified ??% -int TRectype::read(TBaseisamfile& f, word op, word lockop, TDate& atdate) +int TRectype::read(TBaseisamfile& f, word op, word lockop) { - return f._read(*this,op,lockop,atdate) ; + return f._read(*this,op,lockop) ; } int TRectype::readat(TBaseisamfile& f, TRecnotype nrec, word lockop) { - return f._readat(*this,nrec,lockop); + return f._readat(*this,nrec,lockop); } @@ -3126,19 +2999,19 @@ int TRectype::next(TBaseisamfile& f,word lockop) } // Certified ??% -int TRectype::write(TBaseisamfile& f, TDate& atdate ) const -{ return f._write(*this,atdate); } +int TRectype::write(TBaseisamfile& f) const +{ return f._write(*this); } // Certified ??% -int TRectype::rewrite(TBaseisamfile& f, TDate& atdate) const +int TRectype::rewrite(TBaseisamfile& f) const { - return f._rewrite(*this,atdate); + return f._rewrite(*this); } // Certified ??% -int TRectype::remove(TBaseisamfile& f, TDate& atdate) const +int TRectype::remove(TBaseisamfile& f) const { - return f._remove(*this,atdate); + return f._remove(*this); } void TRectype::renum_key(const char* field, const char* val) diff --git a/include/isam.h b/include/isam.h index d26b8ed56..f85fd7a15 100755 --- a/include/isam.h +++ b/include/isam.h @@ -117,17 +117,17 @@ public: virtual TObject* dup() const; // @cmember Legge il file

con il tipo di record - virtual int read(TBaseisamfile& f, word op = _isequal, word lockop = _nolock, TDate& atdate = (TDate&)botime); + virtual int read(TBaseisamfile& f, word op = _isequal, word lockop = _nolock); // @cmember Legge il file

con il tipo di record alla posizione desiderata virtual int readat(TBaseisamfile& f, TRecnotype nrec, word lockop = _nolock); // @cmember Legge il prossimo record virtual int next(TBaseisamfile& f, word lockop = _nolock); // @cmember Aggiunge il record al file - virtual int write(TBaseisamfile& f,TDate& atdate = (TDate&)botime) const; + virtual int write(TBaseisamfile& f) const; // @cmember Riscrive il record sul file - virtual int rewrite(TBaseisamfile& f,TDate& atdate = (TDate&)botime) const; + virtual int rewrite(TBaseisamfile& f) const; // @cmember Elimina il record dal file - virtual int remove(TBaseisamfile& f,TDate& atdate = (TDate&)botime) const; + virtual int remove(TBaseisamfile& f) const; // @cmember Cambia il campo

della chiave principale con il valore

virtual void renum_key(const char* field, const char* val); @@ -318,22 +318,14 @@ class TBaseisamfile : public TObject TRecnotype _recno; // @cmember:(INTERNAL) Indica se il file possiede dei campi memo bool _has_memo; - // @cmember:(INTERNAL) UNUSED - int gethr(TRectype& rec, TDate& atdate); - // @cmember:(INTERNAL) Ritorna NOERR - int addhr(const TRectype& rec, TDate& atdate); - // @cmember:(INTERNAL) Ritorna NOERR - int rewhr(const TRectype& rec, TDate& atdate); - // @cmember:(INTERNAL) Ritorna NOERR - int delhr(const TRectype& rec, TDate& atdate); - - // @cmember:(INTERNAL) IO su file: - int _next(word lockop = _nolock); - int _read(TRectype& rec, word op = _isequal, word lockop = _nolock, TDate& atdate = (TDate&)botime); - int _readat(TRectype& rec, TRecnotype nrec, word lockop = _nolock); - int _write(const TRectype& rec, TDate& atdate = (TDate&)botime); - int _rewrite(const TRectype& rec, TDate& atdate = (TDate&)botime); - int _remove(const TRectype& rec, TDate& atdate = (TDate&)botime); + + // @cmember:(INTERNAL) IO su file: + int _next(word lockop = _nolock); + int _read(TRectype& rec, word op = _isequal, word lockop = _nolock); + int _readat(TRectype& rec, TRecnotype nrec, word lockop = _nolock); + int _write(const TRectype& rec); + int _rewrite(const TRectype& rec); + int _remove(const TRectype& rec); // @access Protected Member protected: // @cmember Ritorna il descrittore del file isam @@ -370,42 +362,38 @@ public: virtual int last(word lockop = _nolock); // @cmember Si posiziona sul successivo record del file (vedi ) virtual int next(word lockop = _nolock); - // @cmember Si posiziona sul successivo record del file (UNUSED) - virtual int next(TDate& atdate); // @cmember Si posiziona sul precedente record del file (vedi ) virtual int prev(word lockop = _nolock); - // @cmember Si posiziona sul precedente record del file (UNUSED) - virtual int prev(TDate& atdate); // @cmember Rilegge l'ultimo record letto (vedi ) - virtual int reread(word lockop = _nolock, TDate& atdate = (TDate&)botime); + virtual int reread(word lockop = _nolock); // @cmember Rilegge l'ultimo record letto e lo copia in

(vedi ) - virtual int reread(TRectype& rec, word lockop = _nolock, TDate& atdate = (TDate&)botime); + virtual int reread(TRectype& rec, word lockop = _nolock); // @cmember Salta

record dalla posizione corrente (vedi ) virtual int skip(TRecnotype nrec, word lockop = _nolock); // @cmember Legge il record (vedi e ) - virtual int read(word op = _isequal, word lockop = _nolock, TDate& atdate = (TDate&)botime); + virtual int read(word op = _isequal, word lockop = _nolock); // @cmember Legge il record e lo copia in

(vedi e ) - virtual int read(TRectype& rec, word op = _isequal, word lockop = _nolock, TDate& atdate = (TDate&)botime); + virtual int read(TRectype& rec, word op = _isequal, word lockop = _nolock); // @cmember Legge il record alla posizione

(vedi ) virtual int readat(TRecnotype nrec, word lockop = _nolock); // @cmember Legge il record alla posizione

e lo copia in

(vedi ) virtual int readat(TRectype& rec, TRecnotype nrec, word lockop = _nolock); // @cmember Aggiunge un record - virtual int write(TDate& atdate = (TDate&)botime); + virtual int write(); // @cmember Aggiunge un record copiando da

- virtual int write(const TRectype& rec, TDate& atdate = (TDate&)botime); + virtual int write(const TRectype& rec); // @cmember Riscrive un record - virtual int rewrite(TDate& atdate = (TDate&)botime); + virtual int rewrite(); // @cmember Riscrive un record (il record

) - virtual int rewrite(const TRectype& rec, TDate& atdate = (TDate&)botime); + virtual int rewrite(const TRectype& rec); // @cmember Riscrive un record alla posizione

virtual int rewriteat(TRecnotype nrec); // @cmember Riscrive un record alla posizione

copiando da

virtual int rewriteat(const TRectype& rec, TRecnotype nrec); // @cmember Elimina il record - virtual int remove(TDate& atdate = (TDate&)botime); + virtual int remove(); // @cmember Elimina il record copiando da

- virtual int remove(const TRectype& rec, TDate& atdate = (TDate&)botime); + virtual int remove(const TRectype& rec); // @cmember Ritorna il numero logico del file sotto forma di stringa virtual const char* name() const; diff --git a/include/relation.cpp b/include/relation.cpp index 44a123c31..a5f9fb514 100755 --- a/include/relation.cpp +++ b/include/relation.cpp @@ -534,10 +534,10 @@ void TRelation::replace( _files.add(f, index); if (relexprs && *relexprs ) { - TRelationdef* oldr=(TRelationdef*)_reldefs.objptr(index-1); - TRelationdef* r = new TRelationdef(this, index, key, oldr->link(), + TRelationdef* oldr=(TRelationdef*)_reldefs.objptr(index-1); + TRelationdef* r = new TRelationdef(this, index, key, oldr->link(), relexprs, oldr->alias(), oldr->allow_lock()); - _reldefs.add(r,index-1); + _reldefs.add(r,index-1); } } @@ -570,7 +570,6 @@ void TRelation::zero() int TRelation::position_rels( TIsamop op, // @parm Operatore che esegue la relazione (default _isequal) TReclock lockop, // @parm Tipo di lock sul file (default _nolock) - TDate& atdate, // @parm UNUSED int first) // @parm Numero del file da cui costruire la relazione (default // 0, cioe' dal file principale) @@ -604,17 +603,17 @@ int TRelation::position_rels( TString expr (rd.evaluate_expr(j, to)); TFieldref& s = (TFieldref&) rd._fields[j]; if (from.is_sorted() && from.curr().type(s.name()) ==_alfafld) - expr.rpad(s.len(from.curr()),'~'); + expr.rpad(s.len(from.curr()),'~'); s.write(expr, furr); } // for each field if (from.is_sorted()) { - ((TSortedfile &)from).setregion(from.curr(),from.curr()); - from.first(); + ((TSortedfile &)from).setregion(from.curr(),from.curr()); + from.first(); // read record: if not found, zero current record } else - from.read(op, lck, atdate); + from.read(op, lck); if (from.bad()) { bool eq = TRUE; @@ -734,7 +733,7 @@ bool TRelation::next_match( } // Riposiziona gli eventuali files successivi - position_rels(_isequal, _nolock, (TDate&)botime, j+1); + position_rels(_isequal, _nolock, j+1); reldef(j)._first_match = FALSE; return ok; @@ -799,7 +798,7 @@ bool TRelation::isconsistent( if (bad) return _errors = bad; - position_rels(_isequal, _nolock, (TDate&)botime); + position_rels(_isequal, _nolock); for (i = 0; i < _files.items(); i++) if (file(i).recno() != recnos[i]) { @@ -818,9 +817,9 @@ bool TRelation::isconsistent( #endif -int TRelation::write(bool force, TDate& atdate) +int TRelation::write(bool force) { - _errors = file(0).write(atdate); + _errors = file(0).write(); if (_errors != NOERR) return _errors; @@ -832,9 +831,9 @@ int TRelation::write(bool force, TDate& atdate) if (!rd.write_enable() || lf.curr().empty()) continue; - int res = lf.write(atdate); + int res = lf.write(); if (force && res == _isreinsert) - res = lf.rewrite(atdate); + res = lf.rewrite(); if (_errors == NOERR) _errors = res; } @@ -842,11 +841,11 @@ int TRelation::write(bool force, TDate& atdate) return _errors; } -int TRelation::rewrite(bool force, TDate& atdate) +int TRelation::rewrite(bool force) { - _errors = file(0).rewrite(atdate); // Riscrive testata + _errors = file(0).rewrite(); // Riscrive testata if (force && _errors == _iskeynotfound) // Se non la trova ... - _errors = file(0).write(atdate); // ... forza la scrittura + _errors = file(0).write(); // ... forza la scrittura for (int i = 0; i < _reldefs.items(); i++) { @@ -856,18 +855,18 @@ int TRelation::rewrite(bool force, TDate& atdate) if (!rd.write_enable() || lf.curr().empty()) continue; - int res = lf.rewrite(atdate); + int res = lf.rewrite(); if (force && res == _iskeynotfound) - res = lf.write(atdate); + res = lf.write(); if (_errors == NOERR) _errors = res; } return _errors; } -int TRelation::remove(TDate& atdate) +int TRelation::remove() { - const int res = file(0).remove(atdate); + const int res = file(0).remove(); if (_errors == NOERR && res != _iskeynotfound) _errors = res; for (int i = 0; i < _reldefs.items(); i++) { @@ -877,7 +876,7 @@ int TRelation::remove(TDate& atdate) if (!rd.write_enable() || (file(log).curr()).empty()) continue; - const int res = file(log).remove(atdate); + const int res = file(log).remove(); if (_errors == NOERR && res != _iskeynotfound) _errors = res; } return _errors; @@ -1216,7 +1215,7 @@ int TCursor::test(TIsamop op, TReclock lockop) const return err; } -TRecnotype TCursor::read(TIsamop op, TReclock lockop, TDate& atdate) +TRecnotype TCursor::read(TIsamop op, TReclock lockop) { int err = test(op, lockop); TLocalisamfile& curfile = file(); @@ -2252,194 +2251,194 @@ TRelation_description::~TRelation_description() // @mfunc Avanza di

record int TSortedfile::operator +=(const TRecnotype npos) { - *_curs+=npos; - setstatus(_curs->file().status()); - return _curs->test(); + *_curs+=npos; + setstatus(_curs->file().status()); + return _curs->test(); } // @mfunc Sposta indietro di

record int TSortedfile::operator -=(const TRecnotype npos) { - *_curs-=npos; - setstatus(_curs->file().status()); - return _curs->test(); + *_curs-=npos; + setstatus(_curs->file().status()); + return _curs->test(); } // @mfunc Avanza al record successivo int TSortedfile::operator ++() -{ - return *this+=1; +{ + return *this+=1; } // @mfunc Indietreggia al record precedente int TSortedfile::operator --() -{ - return *this-=1; +{ + return *this-=1; } // @mfunc Si posiziona sul primo record del file (vedi ) int TSortedfile::first(word lockop ) { - _curs->first_item(); - setstatus(_curs->file().status()); - return _curs->items()>0; + _curs->first_item(); + setstatus(_curs->file().status()); + return _curs->items()>0; } // @mfunc Si posiziona sull'ultimo record del file (vedi ) int TSortedfile::last(word lockop ) { - _curs->last_item(); - setstatus(_curs->file().status()); - return _curs->items()>0; + _curs->last_item(); + setstatus(_curs->file().status()); + return _curs->items()>0; } // @mfunc Si posiziona sul successivo record del file (vedi ) int TSortedfile::next(word lockop ) { - _curs->succ_item(); - setstatus(_curs->file().status()); - return _curs->pos()<=_curs->items(); + _curs->succ_item(); + setstatus(_curs->file().status()); + return _curs->pos()<=_curs->items(); } // @mfunc Si posiziona sul precedente record del file (vedi ) int TSortedfile::prev(word lockop ) { - _curs->pred_item(); - setstatus(_curs->file().status()); - return _curs->pos()>0; + _curs->pred_item(); + setstatus(_curs->file().status()); + return _curs->pos()>0; } // @mfunc Salta

record dalla posizione corrente (vedi ) int TSortedfile::skip(TRecnotype nrec, word lockop ) { -// return *this+=nrec; manca il lock... - setstatus(_curs->file().status()); - error_box("Operazione 'skip' non consentita sul cursore"); - return 0; +// return *this+=nrec; manca il lock... + setstatus(_curs->file().status()); + error_box("Operazione 'skip' non consentita sul cursore"); + return 0; } // @mfunc Rilegge l'ultimo record letto (vedi ) -int TSortedfile::reread(word lockop , TDate& atdate ) +int TSortedfile::reread(word lockop ) { - return reread(curr(),lockop,atdate); + return reread(curr(),lockop); } // @mfunc Rilegge l'ultimo record letto e lo copia in

(vedi ) -int TSortedfile::reread(TRectype& rec, word lockop , TDate& atdate) +int TSortedfile::reread(TRectype& rec, word lockop) { - return 0; + return 0; } // @mfunc Legge il record (vedi e ) -int TSortedfile::read(word op , word lockop , TDate& atdate ) +int TSortedfile::read(word op , word lockop ) { - return read(curr(),op,lockop,atdate); + return read(curr(),op,lockop); } // @mfunc Legge il record e lo copia in

(vedi e ) -int TSortedfile::read(TRectype& rec, word op , word lockop, TDate& atdate ) +int TSortedfile::read(TRectype& rec, word op , word lockop ) { - _curs->read((TIsamop)op,(TReclock)lockop,atdate); - setstatus(_curs->file().status()); - return status(); + _curs->read((TIsamop)op,(TReclock)lockop); + setstatus(_curs->file().status()); + return status(); } // @mfunc Legge il record alla posizione

e lo copia in

(vedi ) int TSortedfile::readat(TRectype& rec, TRecnotype nrec, word lockop ) { - *_curs=nrec; - //read(_isequal,lockop); - rec=curr(); - setstatus(_curs->file().status()); - return status(); + *_curs=nrec; + //read(_isequal,lockop); + rec=curr(); + setstatus(_curs->file().status()); + return status(); } // @mfunc Legge il record alla posizione

e lo copia in

(vedi ) int TSortedfile::readat(TRecnotype nrec, word lockop ) { - return readat(curr(),nrec, lockop ); + return readat(curr(),nrec, lockop ); } // @mfunc Aggiunge un record - int TSortedfile::write(TDate& atdate) + int TSortedfile::write() { - return write(curr(),atdate); + return write(curr()); } // @mfunc Aggiunge un record copiando da

- int TSortedfile::write(const TRectype& rec, TDate& atdate ) + int TSortedfile::write(const TRectype& rec) { - return 0; + return 0; } // @mfunc Riscrive un record - int TSortedfile::rewrite(TDate& atdate ) + int TSortedfile::rewrite() { - return 0; + return 0; } // @mfunc Riscrive un record (il record

) - int TSortedfile::rewrite(const TRectype& rec, TDate& atdate ) + int TSortedfile::rewrite(const TRectype& rec) { - return 0; + return 0; } // @mfunc Riscrive un record alla posizione

copiando da

int TSortedfile::rewriteat(TRecnotype nrec) { - return rewriteat(curr(),nrec); + return rewriteat(curr(),nrec); } // @mfunc Riscrive un record alla posizione

copiando da

int TSortedfile::rewriteat(const TRectype& rec, TRecnotype nrec) { - error_box("Operazione 'rewriteat' non consentita sul cursore"); - return 0; + error_box("Operazione 'rewriteat' non consentita sul cursore"); + return 0; } // @mfunc Elimina il record -int TSortedfile::remove(TDate& atdate ) +int TSortedfile::remove() { - return remove(curr(),atdate); + return remove(curr()); } // @mfunc Elimina il record copiando da

-int TSortedfile::remove(const TRectype& rec, TDate& atdate ) +int TSortedfile::remove(const TRectype& rec) { - return 0; + return 0; } // @mfunc Attiva la chiave

sul file aperto void TSortedfile::setkey(int nkey) { - _curs->setkey(nkey); + _curs->setkey(nkey); } // @mfunc Resetta la regione del file (chiama

void TSortedfile::setregion(const TRectype &f,const TRectype &t) { - _curs->setregion(f,t); + _curs->setregion(f,t); } // @mfunc TRecnotype TSortedfile::eod() const { - return _curs->items(); + return _curs->items(); } // @mfunc bool TSortedfile::empty() { - return _curs->items()==0; + return _curs->items()==0; } // @mfunc Costruttore. TSortedfile::TSortedfile(int logicnum,TRelation * rel,const char * ordexpr,const char * filter, int nkey) - :TLocalisamfile(logicnum),_rel(NULL) + :TLocalisamfile(logicnum),_rel(NULL) { - // costruisce il cursore - if (!rel) - { - _rel = new TRelation(logicnum); - } - else - _rel=rel; + // costruisce il cursore + if (!rel) + { + _rel = new TRelation(logicnum); + } + else + _rel=rel; _curs = new TSorted_cursor(_rel,ordexpr,filter,nkey); _curs->setfilter(filter,TRUE); //BUG: cursors doesn't update rel. - if (&curr()!=&(_curs->file().curr())) - _curs->file().set_curr(&curr()); + if (&curr()!=&(_curs->file().curr())) + _curs->file().set_curr(&curr()); } // @mfunc Distruttore TSortedfile::~TSortedfile() { - delete _curs; + delete _curs; if (_rel) delete _rel; } diff --git a/include/relation.h b/include/relation.h index 919c05765..1b4faac1e 100755 --- a/include/relation.h +++ b/include/relation.h @@ -52,7 +52,7 @@ protected: { return (TLocalisamfile&)_files[i]; } // @cmember Permette di posizionare l'albero di relazioni tra i file - int position_rels(TIsamop op = _isequal, TReclock lockop = _nolock, TDate& atdate = (TDate&)botime, int first = 0); + int position_rels(TIsamop op = _isequal, TReclock lockop = _nolock, int first = 0); // @access Public Member public: // TObject @@ -74,12 +74,6 @@ public: //@cmember Sposta la relazione sul record precedente del file principale (chiama ) virtual int prev(TReclock lockop = _nolock) { return file().prev(lockop) == NOERR ? position_rels(_isequal, lockop) : file().status(); } - //@cmember Sposta la relazione sul record successivo del file principale (chiama ) - virtual int next(TDate& atdate) - { return file().next(atdate) == NOERR ? position_rels(_isequal, _nolock, atdate) : file().status(); } - //@cmember Sposta la relazione sul record precedente del file principale (chiama ) - virtual int prev(TDate& atdate) - { return file().prev(atdate) == NOERR ? position_rels(_isequal, _nolock, atdate) : file().status(); } //@cmember Sposta la relazione sul primo record del file principale (chiama ) virtual int first(TReclock lockop = _nolock) { return file().first(lockop) == NOERR ? position_rels(_isequal, lockop) : file().status(); } @@ -90,8 +84,8 @@ public: virtual int skip(TRecnotype nrec, TReclock lockop = _nolock) { return file().skip(nrec, lockop) == NOERR ? position_rels(_isequal, lockop) : file().status(); } //@cmember Legge il record (chiama ) - virtual int read(TIsamop op = _isgteq, TReclock lockop = _nolock, TDate& atdate = (TDate&)botime) - { return file().read(op, lockop, atdate) == NOERR ? position_rels(_isequal, lockop, atdate) : file().status();} + virtual int read(TIsamop op = _isgteq, TReclock lockop = _nolock) + { return file().read(op, lockop) == NOERR ? position_rels(_isequal, lockop) : file().status();} // @cmember Ritorna il descrittore del file TLocalisamfile& lfile(int logicnum = 0) const; @@ -129,11 +123,11 @@ public: void replace(TLocalisamfile* f, int index = 0,const char * relexprs="",int key=1); // @cmember Aggiunge il record corrente - virtual int write (bool force = TRUE, TDate& atdate = (TDate&)botime); + virtual int write (bool force = TRUE); // @cmember Riscrive il record corrente - virtual int rewrite (bool force = TRUE, TDate& atdate = (TDate&)botime); + virtual int rewrite (bool force = TRUE); // @cmember Elimina il record corrente - virtual int remove (TDate& atdate = (TDate&)botime); + virtual int remove (); // @cmember Controlla se e' stata raggiunta la fine del file // (se

= 0 dell'intera relazione, altrimenti del file indicato ) @@ -333,7 +327,7 @@ public: //@cmember Testa la presenza di un record senza spostare il cursore int test(TIsamop op = _isequal, TReclock lockop = _nolock) const; // @cmember Legge il record - TRecnotype read(TIsamop op = _isgteq, TReclock lockop = _nolock, TDate& atdate = (TDate&)botime); + TRecnotype read(TIsamop op = _isgteq, TReclock lockop = _nolock); // @cmember Mette un lock sul record int lock(TReclock = _lock); // @cmember Toglie un lock sul record (chiama ) @@ -659,8 +653,8 @@ public: // @author:(INTERNAL) Augusto class TSortedfile : public TLocalisamfile { - TRelation * _rel; - TSorted_cursor * _curs; + TRelation * _rel; + TSorted_cursor * _curs; // @access:(INTERNAL) Private Member // @access Protected Members @@ -693,35 +687,35 @@ public: // @cmember Si posiziona sul precedente record del file (vedi ) virtual int prev(word lockop = _nolock); // @cmember Rilegge l'ultimo record letto (vedi ) - virtual int reread(word lockop = _nolock, TDate& atdate = (TDate&)botime); + virtual int reread(word lockop = _nolock); // @cmember Rilegge l'ultimo record letto e lo copia in

(vedi ) - virtual int reread(TRectype& rec, word lockop = _nolock, TDate& atdate = (TDate&)botime); + virtual int reread(TRectype& rec, word lockop = _nolock); // @cmember Salta

record dalla posizione corrente (vedi ) virtual int skip(TRecnotype nrec, word lockop = _nolock); // @cmember Legge il record (vedi e ) - virtual int read(word op = _isequal, word lockop = _nolock, TDate& atdate = (TDate&)botime); + virtual int read(word op = _isequal, word lockop = _nolock); // @cmember Legge il record e lo copia in

(vedi e ) - virtual int read(TRectype& rec, word op = _isequal, word lockop = _nolock, TDate& atdate = (TDate&)botime); + virtual int read(TRectype& rec, word op = _isequal, word lockop = _nolock); // @cmember Legge il record alla posizione

(vedi ) virtual int readat(TRecnotype nrec, word lockop = _nolock); // @cmember Legge il record alla posizione

e lo copia in

(vedi ) virtual int readat(TRectype& rec, TRecnotype nrec, word lockop = _nolock); // @cmember Aggiunge un record - virtual int write(TDate& atdate = (TDate&)botime); + virtual int write(); // @cmember Aggiunge un record copiando da

- virtual int write(const TRectype& rec, TDate& atdate = (TDate&)botime); + virtual int write(const TRectype& rec); // @cmember Riscrive un record - virtual int rewrite(TDate& atdate = (TDate&)botime); + virtual int rewrite(); // @cmember Riscrive un record (il record

) - virtual int rewrite(const TRectype& rec, TDate& atdate = (TDate&)botime); + virtual int rewrite(const TRectype& rec); // @cmember Riscrive un record alla posizione

virtual int rewriteat(TRecnotype nrec); // @cmember Riscrive un record alla posizione

copiando da

virtual int rewriteat(const TRectype& rec, TRecnotype nrec); // @cmember Elimina il record - virtual int remove(TDate& atdate = (TDate&)botime); + virtual int remove(); // @cmember Elimina il record copiando da

- virtual int remove(const TRectype& rec, TDate& atdate = (TDate&)botime); + virtual int remove(const TRectype& rec); // @cmember virtual TRecnotype eod() const ; // @cmember @@ -730,16 +724,16 @@ public: virtual TRecnotype recno() const {return _curs->pos();} // @cmember setta la chiave - void setkey(int nkey); + void setkey(int nkey); // @cmember Resetta la regione del file (chiama

- void setregion(const TRectype &f,const TRectype &t); + void setregion(const TRectype &f,const TRectype &t); - // TO REMOVE - TRelation &relation() - {return *_rel;} - // TO REMOVE - TSorted_cursor &cursor() - {return *_curs;} + // TO REMOVE + TRelation &relation() + {return *_rel;} + // TO REMOVE + TSorted_cursor &cursor() + {return *_curs;} // @cmember Restituisce se il file è ordinato con indice esterno (default:FALSE) virtual bool is_sorted() {return TRUE;}