Modifiche per derivare i TVarrec dai TRectype.
git-svn-id: svn://10.65.10.50/trunk@3480 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
1c27eca32a
commit
4cb3dd15ae
309
include/isam.cpp
309
include/isam.cpp
@ -19,6 +19,7 @@
|
||||
#include <utility.h>
|
||||
#include <memo.h>
|
||||
#include <codeb.h>
|
||||
#include <varrec.h>
|
||||
|
||||
#if XVT_OS==XVT_OS_WIN
|
||||
#include <process.h>
|
||||
@ -53,9 +54,6 @@ extern "C" {
|
||||
|
||||
HIDDEN char _isam_string[257];
|
||||
|
||||
HIDDEN void UNKNOWN_FIELD(int num, const char* name)
|
||||
{ yesnofatal_box("Il campo '%s' non appartiene al file %d", name, num); }
|
||||
|
||||
#define NOALLOC (char **) -1
|
||||
|
||||
HIDDEN bool __autoload = TRUE;
|
||||
@ -350,7 +348,8 @@ HIDDEN int cisread(isfdptr isfd, TRectype & record, int mode)
|
||||
}
|
||||
if (err == _islocked)
|
||||
{
|
||||
memcpy(record.string(),DB_getrecord(isfd->fhnd),DB_reclen(isfd->fhnd));
|
||||
record = DB_getrecord(isfd->fhnd);
|
||||
//memcpy(record.string(),DB_getrecord(isfd->fhnd),DB_reclen(isfd->fhnd));
|
||||
CBuildKey(isfd->r, isfd->knum, record.string(), key, TRUE);
|
||||
message_box("Codice %s in uso da parte\ndi un altro utente.", key);
|
||||
}
|
||||
@ -361,8 +360,8 @@ HIDDEN int cisread(isfdptr isfd, TRectype & record, int mode)
|
||||
err=DB_unlock(isfd->fhnd);
|
||||
if (err != NOERR) err=get_error(err);
|
||||
}
|
||||
|
||||
memcpy(record.string(),DB_getrecord(isfd->fhnd),DB_reclen(isfd->fhnd));
|
||||
record = DB_getrecord(isfd->fhnd);
|
||||
//memcpy(record.string(),DB_getrecord(isfd->fhnd),DB_reclen(isfd->fhnd));
|
||||
isfd->RecNo = DB_recno(isfd->fhnd);
|
||||
return err;
|
||||
}
|
||||
@ -479,44 +478,24 @@ void TMemo_info::reset( )
|
||||
_dirty.reset( );
|
||||
}
|
||||
|
||||
void TRectype::init_memo_info(const TRecnotype recnum )
|
||||
{
|
||||
if( _memoinfo )
|
||||
{
|
||||
_memoinfo->reset();
|
||||
_memoinfo->recno( recnum);
|
||||
// delete _memoinfo;
|
||||
}
|
||||
else
|
||||
_memoinfo = new TMemo_info( this, recnum );
|
||||
}
|
||||
|
||||
void TRectype::write_memo_info( isdef * def ) const
|
||||
{
|
||||
CHECK( _memoinfo, "Tentativo di registrare una TMemo_info vuota," );
|
||||
_memoinfo->write_data( def );
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TExtrectype
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TExtrectype : public TRectype
|
||||
class TExtrectype : public TVariable_rectype
|
||||
{
|
||||
RecDes* _rd;
|
||||
|
||||
protected: // TRectype
|
||||
virtual RecDes* rec_des() const { return _rd; }
|
||||
|
||||
virtual bool auto_virtual_fields() const { return TRUE ; }
|
||||
public:
|
||||
// FPUB
|
||||
|
||||
TExtrectype(const TTrec& r); // Costruisce il record a partire da r
|
||||
virtual ~TExtrectype() {}
|
||||
};
|
||||
|
||||
TExtrectype::TExtrectype(const TTrec& r) : TRectype(r.num())
|
||||
TExtrectype::TExtrectype(const TTrec& r) : TVariable_rectype(r.num())
|
||||
|
||||
{
|
||||
delete _rec;
|
||||
@ -524,7 +503,7 @@ TExtrectype::TExtrectype(const TTrec& r) : TRectype(r.num())
|
||||
_rec = new char [ _length ];
|
||||
_rd = r.rec();
|
||||
if( lf_has_memo(r))
|
||||
init_memo_info(RECORD_NON_FISICO );
|
||||
init_memo(RECORD_NON_FISICO );
|
||||
zero();
|
||||
}
|
||||
|
||||
@ -551,6 +530,7 @@ TBaseisamfile::TBaseisamfile(int logicnum, bool linkrecinst)
|
||||
}
|
||||
else
|
||||
{
|
||||
NFCHECK("linkrecinst sparira' quanto prima, poiche' non sicura");
|
||||
_current = openrec[_logicnum - 1];
|
||||
_delrec = FALSE;
|
||||
}
|
||||
@ -695,6 +675,15 @@ TRecnotype TBaseisamfile::eod() const
|
||||
return(DB_reccount(_isamfile->fhnd));
|
||||
}
|
||||
|
||||
void TBaseisamfile::set_curr(TRectype * curr)
|
||||
|
||||
{
|
||||
CHECK(curr != NULL, "You must pass a valid record");
|
||||
if (_current != NULL)
|
||||
delete _current;
|
||||
_current = curr;
|
||||
}
|
||||
|
||||
void TBaseisamfile::setkey(int nkey)
|
||||
|
||||
{
|
||||
@ -723,8 +712,8 @@ int TBaseisamfile::first(word lockop)
|
||||
_lasterr=cisread(_isamfile, curr(), _isfirst + lockop);
|
||||
if (_lasterr != NOERR) _lasterr = get_error(_lasterr);
|
||||
_recno = _isamfile->RecNo;
|
||||
if( has_memo( ) )
|
||||
curr( ).init_memo_info(_recno);
|
||||
if( curr().has_memo( ) )
|
||||
curr( ).init_memo(_recno);
|
||||
return _lasterr;
|
||||
}
|
||||
|
||||
@ -737,8 +726,8 @@ int TBaseisamfile::last(word lockop)
|
||||
_lasterr=cisread(_isamfile, curr(), _islast + lockop );
|
||||
if (_lasterr != NOERR) _lasterr = get_error(_lasterr);
|
||||
_recno = _isamfile->RecNo;
|
||||
if( has_memo( ) )
|
||||
curr( ).init_memo_info(_recno);
|
||||
if( curr().has_memo( ) )
|
||||
curr( ).init_memo(_recno);
|
||||
return _lasterr;
|
||||
}
|
||||
|
||||
@ -764,8 +753,8 @@ int TBaseisamfile::next(word lockop)
|
||||
if (_lasterr != NOERR) _lasterr = get_error(_lasterr);
|
||||
}
|
||||
_recno = _isamfile->RecNo;
|
||||
if( has_memo( ) )
|
||||
curr( ).init_memo_info(_recno );
|
||||
if( curr().has_memo( ) )
|
||||
curr( ).init_memo(_recno );
|
||||
return _lasterr;
|
||||
}
|
||||
|
||||
@ -796,8 +785,8 @@ int TBaseisamfile::prev(word lockop)
|
||||
_lasterr=cisread(_isamfile, curr(), _isprev + lockop);
|
||||
if (_lasterr != NOERR) _lasterr = get_error(_lasterr);
|
||||
_recno = _isamfile->RecNo;
|
||||
if( has_memo( ) )
|
||||
curr( ).init_memo_info(_recno);
|
||||
if( curr().has_memo( ) )
|
||||
curr( ).init_memo(_recno);
|
||||
return _lasterr;
|
||||
}
|
||||
|
||||
@ -818,8 +807,8 @@ int TBaseisamfile::reread(word lockop, TDate& atdate)
|
||||
_lasterr=cisread(_isamfile, curr(), _iscurr + lockop);
|
||||
if (_lasterr != NOERR) _lasterr = get_error(_lasterr);
|
||||
_recno = _isamfile->RecNo;
|
||||
if( has_memo( ) )
|
||||
curr( ).init_memo_info(_recno);
|
||||
if( curr().has_memo( ) )
|
||||
curr( ).init_memo(_recno);
|
||||
return _lasterr;
|
||||
}
|
||||
|
||||
@ -832,8 +821,8 @@ int TBaseisamfile::reread(TRectype& rec, word lockop, TDate& atdate)
|
||||
_lasterr=cisread(_isamfile, rec, _iscurr + lockop);
|
||||
if (_lasterr != NOERR) _lasterr = get_error(_lasterr);
|
||||
_recno = _isamfile->RecNo;
|
||||
if( has_memo( ) )
|
||||
rec.init_memo_info(_recno);
|
||||
if( rec.has_memo( ) )
|
||||
rec.init_memo(_recno);
|
||||
return _lasterr;
|
||||
}
|
||||
|
||||
@ -867,8 +856,8 @@ int TBaseisamfile::skip(TRecnotype nrec, word lockop)
|
||||
_lasterr=cisread(_isamfile,curr(),_iscurr + lockop);
|
||||
} while (_lasterr ==_islocked);
|
||||
_recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd);
|
||||
if( has_memo( ) )
|
||||
curr( ).init_memo_info(_recno);
|
||||
if( curr().has_memo( ) )
|
||||
curr( ).init_memo(_recno);
|
||||
return _lasterr;
|
||||
}
|
||||
|
||||
@ -882,8 +871,8 @@ int TBaseisamfile::read(word op, word lockop, TDate& atdate)
|
||||
_lasterr=cisread(_isamfile, curr(), op + lockop);
|
||||
if (_lasterr != NOERR) _lasterr=get_error(_lasterr);
|
||||
_recno = _isamfile->RecNo;
|
||||
if( has_memo( ) )
|
||||
curr( ).init_memo_info(_recno);
|
||||
if( curr().has_memo( ) )
|
||||
curr( ).init_memo(_recno);
|
||||
return _lasterr;
|
||||
}
|
||||
|
||||
@ -897,8 +886,8 @@ int TBaseisamfile::read(TRectype& rec, word op, word lockop, TDate& atdate)
|
||||
_lasterr=cisread(_isamfile, rec, op + lockop);
|
||||
if (_lasterr != NOERR) _lasterr = get_error(_lasterr);
|
||||
_recno = _isamfile->RecNo;
|
||||
if( has_memo( ) )
|
||||
rec.init_memo_info(_recno);
|
||||
if( rec.has_memo( ) )
|
||||
rec.init_memo(_recno);
|
||||
return _lasterr;
|
||||
}
|
||||
|
||||
@ -912,10 +901,11 @@ int TBaseisamfile::readat(TRecnotype nrec, word lockop)
|
||||
if (_lasterr != NOERR)
|
||||
_lasterr = get_error(_lasterr);
|
||||
else
|
||||
memcpy(curr().string(),DB_getrecord(_isamfile->fhnd),DB_reclen(_isamfile->fhnd));
|
||||
curr() = DB_getrecord(_isamfile->fhnd);
|
||||
//memcpy(curr().string(),DB_getrecord(_isamfile->fhnd),DB_reclen(_isamfile->fhnd));
|
||||
_recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd);
|
||||
if( has_memo( ) )
|
||||
curr( ).init_memo_info(_recno);
|
||||
if( curr().has_memo( ) )
|
||||
curr( ).init_memo(_recno);
|
||||
return _lasterr;
|
||||
}
|
||||
|
||||
@ -928,10 +918,11 @@ int TBaseisamfile::readat(TRectype& rec, TRecnotype nrec, word lockop)
|
||||
_lasterr=DB_go(_isamfile->fhnd,nrec);
|
||||
if (_lasterr != NOERR) _lasterr = get_error(_lasterr);
|
||||
else
|
||||
memcpy(rec.string(),DB_getrecord(_isamfile->fhnd),DB_reclen(_isamfile->fhnd));
|
||||
rec = DB_getrecord(_isamfile->fhnd);
|
||||
//memcpy(rec.string(),DB_getrecord(_isamfile->fhnd),DB_reclen(_isamfile->fhnd));
|
||||
_recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd);
|
||||
if( has_memo( ) )
|
||||
rec.init_memo_info( _recno );
|
||||
if( rec.has_memo( ) )
|
||||
rec.init_memo( _recno );
|
||||
return _lasterr;
|
||||
}
|
||||
|
||||
@ -950,11 +941,8 @@ int TBaseisamfile::write(TDate& atdate)
|
||||
if (_lasterr != NOERR) _lasterr = get_error(_lasterr);
|
||||
setkey(oldkey);
|
||||
_recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd);
|
||||
if( _lasterr == NOERR && has_memo( ) )
|
||||
{
|
||||
curr( ).memo_info( ).recno( _recno );
|
||||
curr( ).write_memo_info( _isamfile);
|
||||
}
|
||||
if( _lasterr == NOERR && curr().has_memo( ) )
|
||||
curr( ).write_memo( _isamfile, _recno);
|
||||
return _lasterr;
|
||||
}
|
||||
|
||||
@ -974,14 +962,8 @@ int TBaseisamfile::write(const TRectype& rec, TDate& atdate)
|
||||
if (_lasterr != NOERR) _lasterr = get_error(_lasterr);
|
||||
setkey(oldkey);
|
||||
_recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd);
|
||||
if (_lasterr == NOERR )
|
||||
{
|
||||
if( has_memo( ) )
|
||||
{
|
||||
rec.memo_info( ).recno( _recno );
|
||||
rec.write_memo_info( _isamfile );
|
||||
}
|
||||
}
|
||||
if (_lasterr == NOERR && rec.has_memo( ) )
|
||||
((TRectype &) rec).write_memo( _isamfile, _recno );
|
||||
return _lasterr;
|
||||
}
|
||||
|
||||
@ -1002,11 +984,8 @@ int TBaseisamfile::rewrite(TDate& atdate)
|
||||
_lasterr = DB_rewrite(_isamfile->fhnd);
|
||||
if (_lasterr != NOERR) _lasterr = get_error(_lasterr);
|
||||
_recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd);
|
||||
if( _lasterr == NOERR && has_memo( ) )
|
||||
{
|
||||
curr( ).memo_info( ).recno( _recno );
|
||||
curr( ).write_memo_info( _isamfile );
|
||||
}
|
||||
if( _lasterr == NOERR && curr().has_memo( ) )
|
||||
curr( ).write_memo( _isamfile, _recno );
|
||||
}
|
||||
return _lasterr;
|
||||
}
|
||||
@ -1027,11 +1006,8 @@ int TBaseisamfile::rewrite(const TRectype& rec, TDate& atdate)
|
||||
_lasterr = DB_rewrite(_isamfile->fhnd);
|
||||
if (_lasterr != NOERR) _lasterr = get_error(_lasterr);
|
||||
_recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd);
|
||||
if( _lasterr == NOERR && has_memo( ) )
|
||||
{
|
||||
rec.memo_info( ).recno( _recno );
|
||||
rec.write_memo_info( _isamfile );
|
||||
}
|
||||
if( _lasterr == NOERR && rec.has_memo( ) )
|
||||
((TRectype &) rec).write_memo( _isamfile, _recno );
|
||||
}
|
||||
return _lasterr;
|
||||
}
|
||||
@ -1050,11 +1026,8 @@ int TBaseisamfile::rewriteat(TRecnotype nrec)
|
||||
} else
|
||||
_lasterr = get_error(_lasterr);
|
||||
_recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd);
|
||||
if( _lasterr == NOERR && has_memo( ) )
|
||||
{
|
||||
curr( ).memo_info( ).recno( _recno );
|
||||
curr( ).write_memo_info( _isamfile );
|
||||
}
|
||||
if( _lasterr == NOERR && curr().has_memo( ) )
|
||||
curr( ).write_memo( _isamfile, _recno );
|
||||
return _lasterr;
|
||||
}
|
||||
|
||||
@ -1071,11 +1044,8 @@ int TBaseisamfile::rewriteat(const TRectype& rec, TRecnotype nrec)
|
||||
} else
|
||||
_lasterr = get_error(_lasterr);
|
||||
_recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd);
|
||||
if( _lasterr == NOERR && has_memo( ) )
|
||||
{
|
||||
rec.memo_info( ).recno( _recno );
|
||||
rec.write_memo_info( _isamfile );
|
||||
}
|
||||
if( _lasterr == NOERR && rec.has_memo( ) )
|
||||
((TRectype &) rec).write_memo( _isamfile, _recno );
|
||||
return _lasterr;
|
||||
}
|
||||
|
||||
@ -1086,26 +1056,6 @@ int TBaseisamfile::remove(TDate& atdate)
|
||||
|
||||
NOT_OPEN();
|
||||
|
||||
/*// rimozione campi memo
|
||||
#ifndef FOXPRO
|
||||
TMemo_file* memo = NULL;
|
||||
|
||||
for (int i = 0; i < curr().items(); i++)
|
||||
{
|
||||
if ( curr().type(curr().fieldname(i)) == _memofld )
|
||||
{
|
||||
long val = curr().get_long(curr().fieldname(i));
|
||||
if (val > 0l)
|
||||
{
|
||||
if (memo == NULL)
|
||||
memo = new TMemo_file(filename());
|
||||
memo->remove_field(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (memo != NULL) delete memo;
|
||||
#endif
|
||||
*/
|
||||
if ((_lasterr=cisread(_isamfile, curr(), _isequal + _nolock)) == NOERR)
|
||||
{
|
||||
_lasterr = DB_delete(_isamfile->fhnd); // Put only deletion flag on record, must remove keys too!
|
||||
@ -1121,7 +1071,7 @@ int TBaseisamfile::remove(TDate& atdate)
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_lasterr == NOERR && has_memo())
|
||||
if(_lasterr == NOERR && curr().has_memo())
|
||||
curr().memo_info().recno(RECORD_NON_FISICO);
|
||||
|
||||
_recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd);
|
||||
@ -1151,7 +1101,7 @@ int TBaseisamfile::remove(const TRectype& rec, TDate& atdate)
|
||||
}
|
||||
}
|
||||
|
||||
if(_lasterr == NOERR && has_memo())
|
||||
if(_lasterr == NOERR && curr().has_memo())
|
||||
curr().memo_info().recno(RECORD_NON_FISICO);
|
||||
|
||||
_recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd);
|
||||
@ -1935,11 +1885,8 @@ int TSystemisamfile::update(
|
||||
browse_null(nrec.string(),DB_reclen(i0->fhnd));
|
||||
memcpy(DB_getrecord(i0->fhnd),nrec.string(),DB_reclen(i0->fhnd));
|
||||
err=DB_add(i0->fhnd);
|
||||
if ( nrec.has_memo())
|
||||
{
|
||||
nrec.memo_info( ).recno( DB_recno(i0->fhnd) );
|
||||
nrec.write_memo_info( i0);
|
||||
}
|
||||
if ( err == NOERR && nrec.has_memo())
|
||||
nrec.write_memo(i0, DB_recno(i0->fhnd));
|
||||
if (err != NOERR) err=get_error(err);
|
||||
setstatus(err);
|
||||
}
|
||||
@ -2023,7 +1970,7 @@ int TSystemisamfile::packfile(
|
||||
d.get(num(),_nolock, (d.is_com()) ? _comdir : _nordir);
|
||||
CHECKS(filehnd() == NULL, "Can't pack open file", (const char*)filename());
|
||||
err=DB_packfile(vis,d.name(),d.eod());
|
||||
if (err == NOERR && has_memo())
|
||||
if (err == NOERR && curr().has_memo())
|
||||
err = DB_packmemo(vis,d.name());
|
||||
if (err != NOERR) err = get_error(err);
|
||||
if (err != NOERR) error_box("Errore in compattamento dati.\nFile %d : %d", num(),err);
|
||||
@ -2431,6 +2378,8 @@ TRectype::TRectype(int logicnum) : _cod(NULL)
|
||||
}
|
||||
_rec = new char [ _length ];
|
||||
*_tab = '\0';
|
||||
if( lf_has_memo( _logicnum ) )
|
||||
init_memo(RECORD_NON_FISICO );
|
||||
if (_length)
|
||||
zero();
|
||||
else
|
||||
@ -2454,6 +2403,8 @@ TRectype::TRectype(const TBaseisamfile* i): _cod(NULL)
|
||||
}
|
||||
*_tab = '\0';
|
||||
_rec = new char [ _length ];
|
||||
if( lf_has_memo( _logicnum ) )
|
||||
init_memo(RECORD_NON_FISICO );
|
||||
if (_length)
|
||||
zero();
|
||||
else
|
||||
@ -2488,6 +2439,29 @@ TRectype::~TRectype()
|
||||
if (_memoinfo != NULL ) delete _memoinfo;
|
||||
}
|
||||
|
||||
void TRectype::unknown_field(const char* name) const
|
||||
{
|
||||
yesnofatal_box("Il campo '%s' non appartiene al file %d", name, _logicnum);
|
||||
}
|
||||
|
||||
void TRectype::write_memo(isdef * file, const TRecnotype recno)
|
||||
{
|
||||
CHECK( _memoinfo, "Tentativo di registrare una TMemo_info vuota," );
|
||||
_memoinfo->recno(recno);
|
||||
_memoinfo->write_data( file );
|
||||
}
|
||||
|
||||
void TRectype::init_memo( const TRecnotype recno)
|
||||
{
|
||||
if( _memoinfo )
|
||||
{
|
||||
_memoinfo->reset();
|
||||
_memoinfo->recno( recno);
|
||||
}
|
||||
else
|
||||
_memoinfo = new TMemo_info( this, recno );
|
||||
}
|
||||
|
||||
void TRectype::settab(const char *tab)
|
||||
{
|
||||
if (_cod != NULL)
|
||||
@ -2677,29 +2651,34 @@ const char* TRectype::fieldname(int i) const
|
||||
return i >= 0 && i < rd->NFields ? rd->Fd[i].Name : NULL;
|
||||
}
|
||||
|
||||
const char* TRectype::get_str(const char* fieldname) const
|
||||
const TString& TRectype::get_str(const char* fieldname) const
|
||||
{
|
||||
char * s = _isam_string;
|
||||
static TFixed_string tmp(_isam_string, sizeof(_isam_string));
|
||||
RecDes* rd = rec_des();
|
||||
|
||||
if (CFieldType((char*) fieldname, rd) == _datefld)
|
||||
{
|
||||
const TRecfield f((TRectype&)*this, fieldname);
|
||||
strcpy(_isam_string, (const char*) f);
|
||||
tmp = f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CGetFieldBuff((char*) fieldname, rd, _rec, _isam_string) == FIELDERR)
|
||||
UNKNOWN_FIELD(num(), fieldname);
|
||||
if (CGetFieldBuff((char*) fieldname, rd, _rec, s) == FIELDERR)
|
||||
{
|
||||
unknown_field(fieldname);
|
||||
*s = '\0';
|
||||
}
|
||||
if (CFieldType((char*) fieldname,rd) == _boolfld)
|
||||
{
|
||||
if (toupper(*_isam_string) == 'T' || toupper(*_isam_string) == 'Y'
|
||||
|| toupper(*_isam_string) == 'S' || toupper(*_isam_string) == 'X')
|
||||
strcpy(_isam_string,"X");
|
||||
if (toupper(*s) == 'T' || toupper(*s) == 'Y'
|
||||
|| toupper(*s) == 'S' || toupper(*s) == 'X')
|
||||
strcpy(s,"X");
|
||||
else
|
||||
strcpy(_isam_string," ");
|
||||
strcpy(s," ");
|
||||
}
|
||||
}
|
||||
return _isam_string;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
#ifndef FOXPRO
|
||||
@ -2718,34 +2697,26 @@ const TString& TRectype::get(const char* fieldname) const
|
||||
|
||||
int TRectype::get_int(const char* fieldname) const
|
||||
{
|
||||
if (CGetFieldBuff((char*) fieldname, rec_des(), _rec, _isam_string) == FIELDERR)
|
||||
UNKNOWN_FIELD(num(), fieldname);
|
||||
return atoi(_isam_string);
|
||||
return atoi(get_str(fieldname));
|
||||
}
|
||||
|
||||
|
||||
long TRectype::get_long(const char* fieldname) const
|
||||
{
|
||||
if (CGetFieldBuff((char*) fieldname, rec_des(), _rec, _isam_string) == FIELDERR)
|
||||
UNKNOWN_FIELD(num(), fieldname);
|
||||
return atol(_isam_string);
|
||||
return atol(get_str(fieldname));
|
||||
}
|
||||
|
||||
|
||||
word TRectype::get_word(const char* fieldname) const
|
||||
|
||||
{
|
||||
if (CGetFieldBuff((char*) fieldname, rec_des(), _rec, _isam_string) == FIELDERR)
|
||||
UNKNOWN_FIELD(num(), fieldname);
|
||||
return (word)atoi(_isam_string);
|
||||
return (word)atoi(get_str(fieldname));
|
||||
}
|
||||
|
||||
real TRectype::get_real(const char* fieldname) const
|
||||
|
||||
{
|
||||
if (CGetFieldBuff((char*) fieldname, rec_des(), _rec, _isam_string) == FIELDERR)
|
||||
UNKNOWN_FIELD(num(), fieldname);
|
||||
real r(_isam_string);
|
||||
real r(get_str(fieldname));
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -2753,22 +2724,14 @@ real TRectype::get_real(const char* fieldname) const
|
||||
char TRectype::get_char(const char* fieldname) const
|
||||
|
||||
{
|
||||
if (CGetFieldBuff((char*) fieldname, rec_des(), _rec, _isam_string) == FIELDERR)
|
||||
UNKNOWN_FIELD(num(), fieldname);
|
||||
return *_isam_string;
|
||||
return *(get_str(fieldname));
|
||||
}
|
||||
|
||||
|
||||
bool TRectype::get_bool(const char* fieldname) const
|
||||
|
||||
{
|
||||
if (CGetFieldBuff((char*) fieldname, rec_des(), _rec, _isam_string) == FIELDERR)
|
||||
UNKNOWN_FIELD(num(), fieldname);
|
||||
if (toupper(*_isam_string) == 'T' || toupper(*_isam_string) == 'Y'
|
||||
|| toupper(*_isam_string) == 'S' || toupper(*_isam_string) == 'X')
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
return *(get_str(fieldname)) == 'X';
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
@ -2798,9 +2761,7 @@ bool TRectype::get_memo(
|
||||
TDate TRectype::get_date(const char* fieldname) const
|
||||
|
||||
{
|
||||
if (CGetFieldBuff((char*) fieldname, rec_des(), _rec, _isam_string) == -1)
|
||||
UNKNOWN_FIELD(num(), fieldname);
|
||||
TDate d(_isam_string);
|
||||
TDate d(get_str(fieldname));
|
||||
return d;
|
||||
}
|
||||
|
||||
@ -2809,8 +2770,8 @@ TDate TRectype::get_date(const char* fieldname) const
|
||||
void TRectype::put(const char* fieldname, int val)
|
||||
|
||||
{
|
||||
if (CPutField((char*) fieldname, rec_des(), &val, _rec) == FIELDERR)
|
||||
UNKNOWN_FIELD(num(), fieldname);
|
||||
sprintf(_isam_string, "%d", val);
|
||||
put_str( fieldname, _isam_string);
|
||||
setempty(FALSE);
|
||||
}
|
||||
|
||||
@ -2818,8 +2779,8 @@ void TRectype::put(const char* fieldname, int val)
|
||||
void TRectype::put(const char* fieldname, long val)
|
||||
|
||||
{
|
||||
if (CPutField((char*) fieldname, rec_des(), &val, _rec) == FIELDERR)
|
||||
UNKNOWN_FIELD(num(), fieldname);
|
||||
sprintf(_isam_string, "%ld", val);
|
||||
put_str( fieldname, _isam_string);
|
||||
setempty(FALSE);
|
||||
}
|
||||
|
||||
@ -2833,10 +2794,9 @@ void TRectype::put(const char* fieldname, TTextfile& txt)
|
||||
|
||||
long id = memo.set_field(txt, isnew ? FIELDERR : val);
|
||||
if (isnew) val = id;
|
||||
TString16 str; str << val;
|
||||
|
||||
if (CPutFieldBuff((char*) fieldname, rec_des(), (char*)(const char*)str, _rec) == FIELDERR)
|
||||
UNKNOWN_FIELD(num(), fieldname);
|
||||
|
||||
sprintf(_isam_string, "%ld", val);
|
||||
put_str( fieldname, _isam_string);
|
||||
setempty(FALSE);
|
||||
}
|
||||
|
||||
@ -2844,22 +2804,20 @@ void TRectype::put(const char* fieldname, TTextfile& txt)
|
||||
void TRectype::put(const char* fieldname, word val)
|
||||
|
||||
{
|
||||
if (CPutField((char*) fieldname, rec_des(), &val, _rec) == FIELDERR)
|
||||
UNKNOWN_FIELD(num(), fieldname);
|
||||
sprintf(_isam_string, "%u", val);
|
||||
put_str( fieldname, _isam_string);
|
||||
setempty(FALSE);
|
||||
}
|
||||
|
||||
void TRectype::put(const char* fieldname, const real& val)
|
||||
{
|
||||
if (CPutFieldBuff((char*) fieldname, rec_des(), (char*)(const char*)val.string(), _rec) == FIELDERR)
|
||||
UNKNOWN_FIELD(num(), fieldname);
|
||||
put_str( fieldname, val.string());
|
||||
setempty(FALSE);
|
||||
}
|
||||
|
||||
void TRectype::put(const char* fieldname, const TDate& val)
|
||||
{
|
||||
TRecfield f(*this, fieldname);
|
||||
f = val.string(full);
|
||||
put_str(fieldname,val.string(full));
|
||||
setempty(FALSE);
|
||||
}
|
||||
|
||||
@ -2868,8 +2826,7 @@ void TRectype::put(const char* fieldname, char val)
|
||||
{
|
||||
char w[2] = {val, '\0'};
|
||||
|
||||
if (CPutFieldBuff((char*) fieldname, rec_des(), w, _rec) == FIELDERR)
|
||||
UNKNOWN_FIELD(num(), fieldname);
|
||||
put_str( fieldname, w);
|
||||
setempty(FALSE);
|
||||
}
|
||||
|
||||
@ -2878,15 +2835,14 @@ void TRectype::put(const char* fieldname, bool val)
|
||||
|
||||
{
|
||||
char s[2] = { val ? 'T' : 'F', '\0'};
|
||||
if (CPutFieldBuff((char*) fieldname, rec_des(), s, _rec) == FIELDERR)
|
||||
UNKNOWN_FIELD(num(), fieldname);
|
||||
put_str( fieldname, s);
|
||||
setempty(FALSE);
|
||||
}
|
||||
|
||||
#endif // FOXPRO
|
||||
|
||||
|
||||
void TRectype::put(const char* fieldname, const char* val)
|
||||
void TRectype::put_str(const char* fieldname, const char* val)
|
||||
{
|
||||
const TFieldtypes ft = (TFieldtypes)CFieldType((char*) fieldname, rec_des());
|
||||
|
||||
@ -2917,7 +2873,7 @@ void TRectype::put(const char* fieldname, const char* val)
|
||||
else
|
||||
{
|
||||
if (CPutFieldBuff((char*) fieldname, rec_des(), (char*)val, _rec) == FIELDERR)
|
||||
UNKNOWN_FIELD(num(), fieldname);
|
||||
unknown_field(fieldname);
|
||||
}
|
||||
setempty(FALSE);
|
||||
}
|
||||
@ -2937,20 +2893,12 @@ void TRectype::zero(const char* fieldname)
|
||||
}
|
||||
else
|
||||
if (CZeroField((char*) fieldname, rec_des(), _rec) == FIELDERR)
|
||||
UNKNOWN_FIELD(num(), fieldname);
|
||||
unknown_field(fieldname);
|
||||
}
|
||||
if( lf_has_memo( _logicnum ) )
|
||||
init_memo_info(RECORD_NON_FISICO );
|
||||
init_memo(RECORD_NON_FISICO );
|
||||
}
|
||||
|
||||
|
||||
void TRectype::zero()
|
||||
|
||||
{
|
||||
zero('\0');
|
||||
}
|
||||
|
||||
|
||||
void TRectype::zero(char c)
|
||||
|
||||
{
|
||||
@ -2961,7 +2909,7 @@ void TRectype::zero(char c)
|
||||
*_cod = _tab;
|
||||
|
||||
if( lf_has_memo( _logicnum ) )
|
||||
init_memo_info( RECORD_NON_FISICO );
|
||||
init_memo( RECORD_NON_FISICO );
|
||||
setempty(TRUE);
|
||||
}
|
||||
|
||||
@ -2993,7 +2941,6 @@ TRectype& TRectype::operator =(const TRectype& rec)
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// Certified 100%
|
||||
TRectype& TRectype::operator =(const TBaseisamfile& f)
|
||||
{
|
||||
|
@ -150,18 +150,24 @@ class TRectype : public TSortable
|
||||
|
||||
// @access Protected Member
|
||||
protected: // TObject
|
||||
// @cmember Segnalazione di un campo inesistente
|
||||
virtual void unknown_field(const char* name) const;
|
||||
// @cmember Compara due tipo di record del file (vedi <c TSortable>)
|
||||
virtual int compare(const TSortable& s) const;
|
||||
// @cmember Ritorna il nome dell'ultimo campo chiave identificato da <p key>
|
||||
const char* last_key_field(int key) const;
|
||||
|
||||
protected:
|
||||
// @cmember Ritorna il contenuto del campo <p nf>-esimo
|
||||
// @cmember Ritorna il contenuto del campo <p nf>-esimo
|
||||
const char* start(int nf) const;
|
||||
// @cmember Permette di settare il valore di <p _isempty>
|
||||
void setempty(bool val)
|
||||
{ _isempty = val;}
|
||||
|
||||
// @cmember Ritorna il contenuto del campo <p fieldname> (non tipizzata)
|
||||
virtual const TString& get_str(const char* fieldname) const;
|
||||
// @cmember Setta il contenuto del campo <p fieldname> al valore <p val> (non tipizzata)
|
||||
virtual void put_str(const char* fieldname, const char* val);
|
||||
// @cmember Ritorna il contenuto del campo <p nf>-esimo
|
||||
|
||||
// @access Public Member
|
||||
public: // TObject
|
||||
// @cmember Duplica il tipo di record
|
||||
@ -179,9 +185,6 @@ public: // TObject
|
||||
virtual int remove(TBaseisamfile& f) const;
|
||||
// @cmember Cambia il campo <p field> della chiave principale con il valore <p val>
|
||||
virtual void renum_key(const char* field, const char* val);
|
||||
|
||||
// @access Public Member
|
||||
public:
|
||||
// @cmember Ritorna il numero di campi del record
|
||||
int items() const;
|
||||
// @cmember Setta il record come non suoto (chiama <mf TRectype::setempty>
|
||||
@ -206,13 +209,13 @@ public:
|
||||
int len() const
|
||||
{ return _length;}
|
||||
// @cmember Ritorna il tipo del campo <p fieldname>
|
||||
TFieldtypes type(const char* fieldname) const;
|
||||
virtual TFieldtypes type(const char* fieldname) const;
|
||||
// @cmember Ritorna la lunghezza del campo <p fieldname>
|
||||
int length(const char* fieldname) const;
|
||||
virtual int length(const char* fieldname) const;
|
||||
// @cmember Ritorna numero di decimali del campo <p fieldname>
|
||||
int ndec(const char* fieldname) const;
|
||||
virtual int ndec(const char* fieldname) const;
|
||||
// @cmember Indica se esiste il campo <p fieldname>
|
||||
bool exist(const char* fieldname) const;
|
||||
virtual bool exist(const char* fieldname) const;
|
||||
// @cmember Ritorna il nome del campo <p i>-esimo
|
||||
const char* fieldname(int i) const;
|
||||
|
||||
@ -224,8 +227,6 @@ public:
|
||||
bool same_key(const TRectype& rec, int key = 1, int skip_last = 0) const
|
||||
{ return compare_key(rec, key, skip_last) == 0; }
|
||||
|
||||
// @cmember Ritorna il contenuto del campo <p fieldname> (non tipizzata)
|
||||
const char* get_str(const char* fieldname) const ;
|
||||
#ifndef FOXPRO
|
||||
// @cmember Ritorna il reference al contenuto del campo <p fieldname>
|
||||
const TString& get(const char* fieldname) const ;
|
||||
@ -264,27 +265,23 @@ public:
|
||||
void put(const char* fieldname, const real& val);
|
||||
// @cmember Setta il contenuto del campo <p fieldname> in formato memo
|
||||
void put(const char* fieldname, TTextfile& txt);
|
||||
// @cmember Setta il contenuto del campo <p fieldname> (non tipizzata)
|
||||
void put(const char* fieldname, const char* val) { put_str(fieldname, val); }
|
||||
#endif
|
||||
|
||||
// @cmember Setta il contenuto del campo <p fieldname> (non tipizzata)
|
||||
void put(const char* fieldname, const char* val);
|
||||
// void put(const char* fieldname, TString& val);
|
||||
|
||||
// @cmember Vuota il campo puntato da <p fieldname>
|
||||
void zero(const char * fieldname);
|
||||
// @cmember Vuota tutto il record
|
||||
void zero();
|
||||
virtual void zero(const char * fieldname);
|
||||
// @cmember Vuota tutto il record usando il carattere <p c>
|
||||
void zero(char c);
|
||||
virtual void zero(char c = '\0');
|
||||
|
||||
// @cmember Riempie il campo <p fieldname> di spazi
|
||||
void blank(const char * fieldname)
|
||||
{ put(fieldname, " "); }
|
||||
|
||||
// @cmember Assegnazione tra TRectype
|
||||
TRectype& operator =(const TRectype& rec);
|
||||
virtual TRectype& operator =(const TRectype& rec);
|
||||
// @cmember Assegnazione tra TRectype
|
||||
TRectype& operator =(const char* rec);
|
||||
virtual TRectype& operator =(const char* rec);
|
||||
// @cmember Assegnazione tra TRectype
|
||||
TRectype& operator =(const TBaseisamfile& f);
|
||||
|
||||
@ -305,6 +302,17 @@ public:
|
||||
bool ok() const
|
||||
{ return _rec != NULL; }
|
||||
|
||||
// @cmember Inizializza la struttura di <c TMemo_info>
|
||||
void init_memo(const TRecnotype recno = RECORD_NON_FISICO );
|
||||
// @cmember Scrive le informazioni contenute in <c TMemo_info>
|
||||
void write_memo(isdef * file, const TRecnotype recno );
|
||||
// @cmember Ritorna il refernce alla <c TMemo_info>
|
||||
TMemo_info& memo_info( ) const
|
||||
{ CHECK( _memoinfo, "Tentativo di accesso ad una memoinfo vuota!" ); return *_memoinfo; }
|
||||
// @cmember Indica se il record possiede un campo memo
|
||||
bool has_memo() const
|
||||
{ return _memoinfo != NULL; }
|
||||
|
||||
// @cmember Costruttore Costruisce un record staccato da un file.
|
||||
// Sarebbe meglio utilizzare una delle altre due
|
||||
TRectype(int logicnum);
|
||||
@ -314,20 +322,7 @@ public:
|
||||
TRectype(const TRectype& r);
|
||||
|
||||
// @cmember Distruttore
|
||||
virtual ~TRectype();
|
||||
|
||||
// @cmember Inizializza la struttura di <c TMemo_info>
|
||||
void init_memo_info(const TRecnotype recnum );
|
||||
// @cmember Ritora il refernce alla <c TMemo_info>
|
||||
TMemo_info& memo_info( ) const
|
||||
{ CHECK( _memoinfo, "Tentativo di accesso ad una memoinfo vuota!" ); return *_memoinfo; }
|
||||
// @cmember Scrive le iunformazioni contenute in <c TMemo_info>
|
||||
void write_memo_info( isdef * def ) const;
|
||||
// @cmember Indica se il record possiede un campo memo
|
||||
bool has_memo() const
|
||||
{ return _memoinfo != NULL; }
|
||||
|
||||
|
||||
virtual ~TRectype();
|
||||
};
|
||||
|
||||
// @doc EXTERNAL
|
||||
@ -416,6 +411,8 @@ protected:
|
||||
|
||||
// @access Public Member
|
||||
public:
|
||||
// @cmember Sostituisce il record corrente del file
|
||||
void set_curr(TRectype * curr);
|
||||
// @cmember Attiva la chiave <p nkey> sul file aperto
|
||||
void setkey(int nkey);
|
||||
// @cmember Ritorna la chiave attiva sul file aperto
|
||||
@ -575,9 +572,9 @@ public:
|
||||
void put(const char* fieldname, TTextfile& txt)
|
||||
{ curr().put(fieldname, txt); }
|
||||
#else
|
||||
// @cmember Ritorna una strinag con il contenuto del campo <p fieldname>
|
||||
// @cmember Ritorna una stringa con il contenuto del campo <p fieldname>
|
||||
const char* get_str(const char* fieldname) const
|
||||
{ return curr().get_str(fieldname);}
|
||||
{ return (const char *) curr().get_str(fieldname);}
|
||||
#endif
|
||||
|
||||
// @cmember Setta il contenuto del campo <p filedname> (non tipizzata)
|
||||
|
Loading…
x
Reference in New Issue
Block a user