Aggiunte le funzioni rewriteat.

git-svn-id: svn://10.65.10.50/trunk@46 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1994-08-22 11:16:25 +00:00
parent 441344d49c
commit 94b43f2779

View File

@ -52,48 +52,48 @@ class TExtrectype;
class TRectype : public TSortable
{
friend class TExtrectype;
friend class TRecfield;
friend class TBaseisamfile;
friend class TLocalisamfile;
friend class TIsamtempfile;
friend class TExtrectype;
friend class TRecfield;
friend class TBaseisamfile;
friend class TLocalisamfile;
friend class TIsamtempfile;
// DPRIV
char* _rec; // Puntatore a inizio record
int _logicnum; // Numero logico
int _length; // Lunghezza
isdef* _i; // Puntatore al file isam
bool _isempty; // Se il record e' vuoto
// @END
// DPRIV
char* _rec; // Puntatore a inizio record
int _logicnum; // Numero logico
int _length; // Lunghezza
isdef* _i; // Puntatore al file isam
bool _isempty; // Se il record e' vuoto
// @END
protected:
// FPROT
const char* start(int nf) const;
protected:
// FPROT
const char* start(int nf) const;
void setempty(bool val) { _isempty = val;} // Rende vero is_empty
virtual TObject* dup() const; // Duplica record
virtual int compare(const TSortable& s) const;
// @END
virtual int compare(const TSortable& s) const;
// @END
public:
// FPUB
int items() const;
void setdirty() { setempty(FALSE); }
public:
// FPUB
int items() const;
void setdirty() { setempty(FALSE); }
char* string() const { return _rec;} // Ritorna il puntatore all'inizio. NON dovrebbe essere usata!
void discard() { *_rec = char(_deleted);} // Setta il flag di cancellazione
void discard() { *_rec = char(_deleted);} // Setta il flag di cancellazione
void recall() { *_rec = char(_valid);} // Ripristina il flag di cancellazione
bool isdeleted() const { return *_rec == _deleted;} // Chiede se e' cancellato
int len() const { return _length;} // Ritorna la lunghezza
TFieldtypes type(const char* fieldname) const; // Ritorna il tipo del campo
int length(const char* fieldname) const; // Ritorna lunghezza campo
int ndec(const char* fieldname) const; // Ritorna numero di decimali
bool exist(const char* fieldname) const; // Ritorna l'esistenza del campo
const char* fieldname(int i) const; // Ritorna il nome del campo i
TFieldtypes type(const char* fieldname) const; // Ritorna il tipo del campo
int length(const char* fieldname) const; // Ritorna lunghezza campo
int ndec(const char* fieldname) const; // Ritorna numero di decimali
bool exist(const char* fieldname) const; // Ritorna l'esistenza del campo
const char* fieldname(int i) const; // Ritorna il nome del campo i
// @DES Get tipizzata. Ritorna il contenuto del campo nei vari tipi
// @FPUB
// @DES Get tipizzata. Ritorna il contenuto del campo nei vari tipi
// @FPUB
#ifndef FOXPRO
int get_int(const char* fieldname) const ;
int get_int(const char* fieldname) const ;
long get_long(const char* fieldname) const ;
word get_word(const char* fieldname) const ;
char get_char(const char* fieldname) const ;
@ -102,48 +102,48 @@ protected:
#endif
TDate get_date(const char* fieldname) const ;
// @DES Get non tipizzata. Il campo e' ritornato come TString&
// @FPUB
// @DES Get non tipizzata. Il campo e' ritornato come TString&
// @FPUB
const TString& get(const char* fieldname) const ;
// @DES Put tipizzata
// @FPUB
// @DES Put tipizzata
// @FPUB
#ifndef FOXPRO
void put(const char* fieldname, int val);
void put(const char* fieldname, long val);
void put(const char* fieldname, word val);
void put(const char* fieldname, const TDate& val);
void put(const char* fieldname, char val);
void put(const char* fieldname, bool val);
void put(const char* fieldname, char val);
void put(const char* fieldname, bool val);
void put(const char* fieldname, const real& val);
#endif
// @DES Put NON tipizzata
// @FPUB
void put(const char* fieldname, const char* val);
// void put(const char* fieldname, TString& val);
// @DES Put NON tipizzata
// @FPUB
void put(const char* fieldname, const char* val);
// void put(const char* fieldname, TString& val);
void zero(const char * fieldname); // Vuota campo puntato da fieldname
void zero(); // Vuota tutto il record
void zero(char c); // Vuota tutto il record usando il carattere c
void zero(const char * fieldname); // Vuota campo puntato da fieldname
void zero(); // Vuota tutto il record
void zero(char c); // Vuota tutto il record usando il carattere c
TRectype& operator =(const TRectype& rec); // assegnazione tra TRectype
TRectype& operator =(const char* rec); // assegnazione tra TRectype
TRectype& operator =(const TBaseisamfile& f);
TRectype& operator =(const TRectype& rec); // assegnazione tra TRectype
TRectype& operator =(const char* rec); // assegnazione tra TRectype
TRectype& operator =(const TBaseisamfile& f);
const isdef* filehnd() const { return _i; } // Ritorna il file isam associato
int num() const { return _logicnum;} // Ritorna il numero logico
bool empty() const {return _isempty;} // Ritorna se e' vuoto
bool valid() const {return _rec[0] == 0;} // Ritorna se il record non e'cancellato
const char* key(int numkey = 1) const; // Ritorna l'espressione della chiave numero numkey
bool ok() const { return _i != NULL;}
const isdef* filehnd() const { return _i; } // Ritorna il file isam associato
int num() const { return _logicnum;} // Ritorna il numero logico
bool empty() const {return _isempty;} // Ritorna se e' vuoto
bool valid() const {return _rec[0] == 0;} // Ritorna se il record non e'cancellato
const char* key(int numkey = 1) const; // Ritorna l'espressione della chiave numero numkey
bool ok() const { return _i != NULL;}
TRectype(int logicnum); // Costruisce un record staccato da un file. Bisogna poi chiamare linkfile(). Sarebbe meglio utilizzare una delle altre due
TRectype(const TBaseisamfile* i); // Costruisce record e lo associa al file isam i
TRectype(const TRectype& r); // Costruisce il record a partire da r
TRectype(int logicnum); // Costruisce un record staccato da un file. Bisogna poi chiamare linkfile(). Sarebbe meglio utilizzare una delle altre due
TRectype(const TBaseisamfile* i); // Costruisce record e lo associa al file isam i
TRectype(const TRectype& r); // Costruisce il record a partire da r
virtual ~TRectype();
virtual ~TRectype();
};
// @C
@ -155,7 +155,7 @@ protected:
class TBaseisamfile : public TObject
{
// @DPRIV
// @DPRIV
isdef* _isamfile; // Descrittore file isam
int _logicnum; // Numero logico del record corrente
int _lasterr; // Ultimo errore
@ -168,124 +168,126 @@ class TBaseisamfile : public TObject
TRecnotype _lasthf;
TRecnotype _recno;
friend class TRectype;
friend class TRectype;
friend class TLocalisamfile;
friend class TIsamfile;
friend class TIsamtempfile;
friend class TRecfield;
// friend class TCursor;
// @END
// @FPRIV
// friend class TCursor;
// @END
// @FPRIV
// friend TRecnotype __buildcursor(TFilecursor* tic, TRecnotype rp);
// friend TRecnotype __filtercursor(TFilecursor* tic);
// friend bool __evalcondition(TBaseisamfile* i,TString& condition);
// friend void __readrec(TFilecursor* tic);
int gethr(TRectype& rec, TDate& atdate);
int gethr(TRectype& rec, TDate& atdate);
int addhr(const TRectype& rec, TDate& atdate);
int rewhr(const TRectype& rec, TDate& atdate);
int delhr(const TRectype& rec, TDate& atdate);
protected:
// @FPROT
protected:
// @FPROT
isdef** ptrfilehnd() const { return (isdef**) &_isamfile;}
void clearfilehnd() { _isamfile = NULL;}
int _open(unsigned int mode = _manulock); // Apre isam file con lock
int _close();
const char* filename() const;
const char* filename() const;
public:
// @FPUB
public:
// @FPUB
void setkey(int nkey); // Attiva una chiave
int getkey() const; // Ritorna la chiave
int getkey() const; // Ritorna la chiave
void setstatus(int status) { _lasterr = status;} // Setta _lasterr
virtual int first(word lockop = _nolock);
virtual int last(word lockop = _nolock);
virtual int next(word lockop = _nolock);
virtual int next(TDate& atdate);
virtual int prev(word lockop = _nolock);
virtual int prev(TDate& atdate);
virtual int reread(word lockop = _nolock, TDate& atdate = botime);
virtual int reread(TRectype& rec, word lockop = _nolock, TDate& atdate = botime);
virtual int skip(TRecnotype nrec, word lockop = _nolock);
virtual int read(word op = _isequal, word lockop = _nolock, TDate& atdate = botime);
virtual int read(TRectype& rec, word op = _isequal, word lockop = _nolock, TDate& atdate = botime);
virtual int readat(TRecnotype nrec, word lockop = _nolock);
virtual int readat(TRectype& rec, TRecnotype nrec, word lockop = _nolock);
virtual int write(TDate& atdate = botime);
virtual int write(const TRectype& rec, TDate& atdate = botime);
virtual int rewrite(TDate& atdate = botime);
virtual int rewrite(const TRectype& rec, TDate& atdate = botime);
virtual int remove(TDate& atdate = botime);
virtual int remove(const TRectype& rec, TDate& atdate = botime);
virtual const char* name() const;
virtual int first(word lockop = _nolock);
virtual int last(word lockop = _nolock);
virtual int next(word lockop = _nolock);
virtual int next(TDate& atdate);
virtual int prev(word lockop = _nolock);
virtual int prev(TDate& atdate);
virtual int reread(word lockop = _nolock, TDate& atdate = botime);
virtual int reread(TRectype& rec, word lockop = _nolock, TDate& atdate = botime);
virtual int skip(TRecnotype nrec, word lockop = _nolock);
virtual int read(word op = _isequal, word lockop = _nolock, TDate& atdate = botime);
virtual int read(TRectype& rec, word op = _isequal, word lockop = _nolock, TDate& atdate = botime);
virtual int readat(TRecnotype nrec, word lockop = _nolock);
virtual int readat(TRectype& rec, TRecnotype nrec, word lockop = _nolock);
virtual int write(TDate& atdate = botime);
virtual int write(const TRectype& rec, TDate& atdate = botime);
virtual int rewrite(TDate& atdate = botime);
virtual int rewrite(const TRectype& rec, TDate& atdate = botime);
virtual int rewriteat(TRecnotype nrec);
virtual int rewriteat(const TRectype& rec, TRecnotype nrec);
virtual int remove(TDate& atdate = botime);
virtual int remove(const TRectype& rec, TDate& atdate = botime);
virtual const char* name() const;
TRecnotype recno() const { return _recno;}
int lock(); // Attiva lock di tutto il file
int unlock(); // Disattiva lock di tutto il file
void indexon(); // Accende gli indici
void indexoff(); // Spegne gli indici
int status() const { return _lasterr; } // Ritorna _lasterr
TRectype& curr() const {return *_current;} // Ritorna puntatore a record corrente
bool eof() const { return status() == _iseof || status() == _isemptyfile;} // Vero se siamo a fine file
bool bof() const { return status() == _isbof || status() == _isemptyfile;} // Vero se siamo a inizio file
bool good() const { return status() == NOERR;} // Vero se _lasterr non contiene codici d'errore
bool bad() const { return status() != NOERR;} // Vero se _lasterr contiene codici d'errore
bool empty(); // Vero se il file e' vuoto
int num() const { return _logicnum;} // Ritorna il numero logico del record corrente
TRecnotype eod() const { return filehnd()->d->EOD;}
TRecnotype recno() const { return _recno;}
int lock(); // Attiva lock di tutto il file
int unlock(); // Disattiva lock di tutto il file
void indexon(); // Accende gli indici
void indexoff(); // Spegne gli indici
int status() const { return _lasterr; } // Ritorna _lasterr
TRectype& curr() const {return *_current;} // Ritorna puntatore a record corrente
bool eof() const { return status() == _iseof || status() == _isemptyfile;} // Vero se siamo a fine file
bool bof() const { return status() == _isbof || status() == _isemptyfile;} // Vero se siamo a inizio file
bool good() const { return status() == NOERR;} // Vero se _lasterr non contiene codici d'errore
bool bad() const { return status() != NOERR;} // Vero se _lasterr contiene codici d'errore
bool empty(); // Vero se il file e' vuoto
int num() const { return _logicnum;} // Ritorna il numero logico del record corrente
TRecnotype eod() const { return filehnd()->d->EOD;}
isdef* filehnd() const { return (isdef*) _isamfile;} // Ritorna l'handle del file isam nella tabella
isdef* filehnd() const { return (isdef*) _isamfile;} // Ritorna l'handle del file isam nella tabella
long items() const; // n.o di records nel file
long items() const; // n.o di records nel file
// @DES Get tipizzata. Ritorna il contenuto del campo nei vari tipi
// @FPUB
// @DES Get tipizzata. Ritorna il contenuto del campo nei vari tipi
// @FPUB
#ifndef FOXPRO
int get_int(const char* fieldname) const
{ return curr().get_int(fieldname);}
{ return curr().get_int(fieldname);}
long get_long(const char* fieldname) const
{ return curr().get_long(fieldname);}
{ return curr().get_long(fieldname);}
word get_word(const char* fieldname) const
{ return curr().get_word(fieldname);}
{ return curr().get_word(fieldname);}
char get_char(const char* fieldname) const
{ return curr().get_char(fieldname);}
{ return curr().get_char(fieldname);}
bool get_bool(const char* fieldname) const
{ return curr().get_bool(fieldname);}
{ return curr().get_bool(fieldname);}
real get_real(const char* fieldname) const
{ return curr().get_real(fieldname);}
{ return curr().get_real(fieldname);}
#endif
TDate get_date(const char* fieldname) const
{ return curr().get_date(fieldname);}
{ return curr().get_date(fieldname);}
// @DES Get non tipizzata. Il campo e' ritornato come TString&
// @FPUB
// @DES Get non tipizzata. Il campo e' ritornato come TString&
// @FPUB
const TString& get(const char* fieldname) const
{ return curr().get(fieldname);}
{ return curr().get(fieldname);}
// @DES Put NON tipizzata
// @FPUB
// @DES Put NON tipizzata
// @FPUB
#ifndef FOXPRO
void put(const char* fieldname, int val)
{ curr().put(fieldname, val);}
{ curr().put(fieldname, val);}
void put(const char* fieldname, long val)
{ curr().put(fieldname, val);}
{ curr().put(fieldname, val);}
void put(const char* fieldname, word val)
{ curr().put(fieldname, val);}
{ curr().put(fieldname, val);}
void put(const char* fieldname, const TDate& val)
{ curr().put(fieldname, val);}
{ curr().put(fieldname, val);}
void put(const char* fieldname, char val)
{ curr().put(fieldname, val);}
{ curr().put(fieldname, val);}
void put(const char* fieldname, bool val)
{ curr().put(fieldname, val);}
{ curr().put(fieldname, val);}
void put(const char* fieldname, const real& val)
{ curr().put(fieldname, val);}
{ curr().put(fieldname, val);}
#endif
// @DES Put NON tipizzata
// @FPUB
// @DES Put NON tipizzata
// @FPUB
void put(const char* fieldname, const char* val)
{ curr().put(fieldname, val);}
{ curr().put(fieldname, val);}
void zero(const char * fieldname) { curr().zero(fieldname);}
void zero() { curr().zero();}
@ -305,8 +307,8 @@ class TBaseisamfile : public TObject
class TIsamfile : public TBaseisamfile
{
public:
// @FPUB
public:
// @FPUB
int flags(bool updateeod = FALSE);
int open(unsigned int mode = _manulock) { return _open(mode);} // Apre isam file con lock
int close() { return _close();}
@ -323,10 +325,10 @@ class TIsamfile : public TBaseisamfile
class TIsamtempfile : public TBaseisamfile
{
public:
// @FPUB
public:
// @FPUB
int open(char* radix, bool create = TRUE, TRecnotype eod = 0,
TRecnotype eox = 100); // Apre il file. radix e' la radice del path del file, se create e' falso vuol dire che il file esiste gia', e allora eod dice quanti record ci sono; eox quanti bisogna aggiungerne
TRecnotype eox = 100); // Apre il file. radix e' la radice del path del file, se create e' falso vuol dire che il file esiste gia', e allora eod dice quanti record ci sono; eox quanti bisogna aggiungerne
int close(bool flagdel = TRUE); // Chiude il file e se e' vero flagdel lo cancella
@ -341,8 +343,8 @@ class TIsamtempfile : public TBaseisamfile
class TSystemisamfile : public TIsamfile
{
public:
// @FPUB
public:
// @FPUB
int build(TRecnotype eox); // Costruisce un file isam
int extend(TRecnotype eox); // Estende un file preesistente
long size(TRecnotype eox); // Calcola lo spazio che il file occuperebbe se venisse esteso a eox
@ -351,11 +353,11 @@ class TSystemisamfile : public TIsamfile
int packfile(bool vis = TRUE); // Rimuove fisicamente i record cancellati
int packindex(bool vis = TRUE); // La stessa cosa sugli indici
// @DES Importa un file ascii. from e' il nome del file da importare
int load(const char* from, char fs = '|', char fd = '\0', char rs = '\n', bool vis = TRUE) ;
// @DES Importa un file ascii. from e' il nome del file da importare
int load(const char* from, char fs = '|', char fd = '\0', char rs = '\n', bool vis = TRUE) ;
// @DES Esporta VERSO un file ascii.
int dump(const char* to, int nkey = 1, char fs = '|', char fd = '\0', char rs = '\n', bool vis = TRUE, bool withdeleted = FALSE);
// @DES Esporta VERSO un file ascii.
int dump(const char* to, int nkey = 1, char fs = '|', char fd = '\0', char rs = '\n', bool vis = TRUE, bool withdeleted = FALSE);
TSystemisamfile(int logicnum, bool linkrecinst = TRUE);
virtual ~TSystemisamfile();
@ -368,12 +370,12 @@ class TSystemisamfile : public TIsamfile
class TLocalisamfile : public TBaseisamfile
{
// @DPRIV
bool _was_open; // Vero se il file e' stato aperto come Localisamfile
// @DPRIV
bool _was_open; // Vero se il file e' stato aperto come Localisamfile
bool _isatab; // Vero se il file e' una tabella
public:
// @FPUB
public:
// @FPUB
virtual int operator +=(const TRecnotype npos); // Avanza npos record
virtual int operator -=(const TRecnotype npos); // Sposta indietro di npos
virtual int operator ++(); // record successivo
@ -383,7 +385,7 @@ class TLocalisamfile : public TBaseisamfile
int open(unsigned int mode = _manulock);
int close() ;
// Costruttore. linkrecinst dice se il file deve utilizzare un area record separata oppure la stessa.
// Costruttore. linkrecinst dice se il file deve utilizzare un area record separata oppure la stessa.
TLocalisamfile(int logicnum, bool linkrecinst = TRUE);
virtual ~TLocalisamfile();
};
@ -395,8 +397,8 @@ class TLocalisamfile : public TBaseisamfile
class TRec_array : public TArray
{
public:
// @FPUB
public:
// @FPUB
TRec_array(int dimension, TBaseisamfile& i);
};
@ -407,22 +409,22 @@ class TRec_array : public TArray
class TRecfield : public TObject
{
// @DPRIV
// @DPRIV
char _name[12]; // Nome campo
TRectype* _rec; // Puntatore a inizio record
char* _p; // Puntatore a inizio campo
byte _len; // Lunghezza campo
byte _dec; // Numero di decimali
byte _type; // Tipo del campo
// @END
// @END
// @FPRIV
// @FPRIV
void set(int from, int to);
public:
// @FPUB
// @DES Operatore di assegnazione (=) per i vari tipi
// @FPUB
public:
// @FPUB
// @DES Operatore di assegnazione (=) per i vari tipi
// @FPUB
int operator =(int i) ;
long operator =(long l) ;
@ -432,8 +434,8 @@ class TRecfield : public TObject
const real& operator =(const real& r) ;
#endif // FOXPRO
// @DES Operatore di estrazione per i vari tipi
// @FPUB
// @DES Operatore di estrazione per i vari tipi
// @FPUB
operator int() const ;
operator long() const ;
operator const char*() const ;
@ -462,15 +464,15 @@ class TRecfield : public TObject
class TTransaction
{
public:
// @FPUB
public:
// @FPUB
void begin();
void end(bool success = TRUE);
void abort() { end(FALSE);}
};
#ifdef __ISAM_CPP
#define extern
#define extern
#endif
// @DPUB