Cambiato padre ed uso dei TIsamtempfile
git-svn-id: svn://10.65.10.50/trunk@990 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
3d7dd11af5
commit
abfb189183
@ -1,7 +1,7 @@
|
|||||||
#ifndef APPNAME
|
#ifndef APPNAME
|
||||||
#define APPNAME PRASSI
|
#define APPNAME PRASSI
|
||||||
#define QAPPNAME "PRASSI"
|
#define QAPPNAME "PRASSI"
|
||||||
#define LIBDIR c:\xvt.322\xvtwin\lib
|
#define LIBDIR f:\xvt.322\xvtwin\lib
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NO_STD_EDIT_MENU
|
#define NO_STD_EDIT_MENU
|
||||||
|
@ -42,6 +42,10 @@ void set_autoload_new_files(bool on)
|
|||||||
__autoload = on;
|
__autoload = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TExtrectype
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class TExtrectype : public TRectype
|
class TExtrectype : public TRectype
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -69,6 +73,10 @@ TExtrectype::~TExtrectype()
|
|||||||
delete _i;
|
delete _i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TBaseisamfile
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TBaseisamfile::TBaseisamfile(int logicnum, bool linkrecinst)
|
TBaseisamfile::TBaseisamfile(int logicnum, bool linkrecinst)
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -634,13 +642,21 @@ int TBaseisamfile::_close()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TLocalisamfile
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TLocalisamfile::TLocalisamfile(int logicnum, bool linkrecinst)
|
TLocalisamfile::TLocalisamfile(int logicnum, bool linkrecinst)
|
||||||
: TBaseisamfile(logicnum, linkrecinst)
|
: TBaseisamfile(logicnum, linkrecinst)
|
||||||
{
|
{
|
||||||
open();
|
if (linkrecinst <= TRUE)
|
||||||
if (_was_open)
|
{
|
||||||
_oldkey = getkey();
|
open();
|
||||||
setkey(1);
|
if (_was_open)
|
||||||
|
_oldkey = getkey();
|
||||||
|
setkey(1);
|
||||||
|
}
|
||||||
|
else _was_open = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -745,30 +761,57 @@ int TIsamfile::flags(bool updateeod)
|
|||||||
return cisupdflags(filehnd(), &err, updateeod);
|
return cisupdflags(filehnd(), &err, updateeod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TIsamtempfile
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TIsamtempfile::TIsamtempfile(int logicnum, bool linkrecinst) : TBaseisamfile(logicnum, linkrecinst) {}
|
TIsamtempfile::TIsamtempfile(int logicnum, const char* radix, bool create)
|
||||||
|
: TLocalisamfile(logicnum, 2)
|
||||||
|
{
|
||||||
|
TRecnotype eod = 0;
|
||||||
|
TRecnotype eox = 100;
|
||||||
|
|
||||||
|
TFilename n; n.tempdir();
|
||||||
|
n.insert("%", 0);
|
||||||
|
n << '/' << radix;
|
||||||
|
n.ext("dta");
|
||||||
|
|
||||||
|
if (!create)
|
||||||
|
{
|
||||||
|
TDir dir; dir.get(logicnum);
|
||||||
|
const word& len = dir.len();
|
||||||
|
|
||||||
|
FILE* f = fopen(n, "r");
|
||||||
|
CHECKS(f, "Can't open temporary file ", (const char*)n);
|
||||||
|
fseek(f, 0, SEEK_END);
|
||||||
|
eod = eox = ftell(f) / len;
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
_autodel = create > TRUE;
|
||||||
|
|
||||||
|
open(n, create, eod, eox);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TIsamtempfile::~TIsamtempfile()
|
TIsamtempfile::~TIsamtempfile()
|
||||||
|
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int TIsamtempfile::open(char* radix, bool create, TRecnotype eod, TRecnotype eox)
|
int TIsamtempfile::open(const char* radix, bool create, TRecnotype eod, TRecnotype eox)
|
||||||
|
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (filehnd() != NULL)
|
if (filehnd() != NULL)
|
||||||
fatal_box("File %s already open", filename());
|
fatal_box("File %s already open", filename());
|
||||||
if ((cisopentemp(ptrfilehnd(), _logicnum, radix, NOALLOC, create, eod, eox, &err) == NOERR) &&
|
if ((cisopentemp(ptrfilehnd(), _logicnum, (char*)radix, NOALLOC, create, eod, eox, &err) == NOERR) &&
|
||||||
(_historicfile))
|
(_historicfile))
|
||||||
{
|
{
|
||||||
TFilename s(filename());
|
TFilename s(filename()); s.ext("hst");
|
||||||
|
|
||||||
s.ext("hst");
|
|
||||||
_hf.len() = filehnd()->d->LenR;
|
_hf.len() = filehnd()->d->LenR;
|
||||||
_hf.base() = 1;
|
_hf.base() = 1;
|
||||||
_hf.open(s);
|
_hf.open(s);
|
||||||
@ -790,14 +833,13 @@ int TIsamtempfile::open(char* radix, bool create, TRecnotype eod, TRecnotype eox
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int TIsamtempfile::close(bool flagdel)
|
int TIsamtempfile::close()
|
||||||
|
|
||||||
{
|
{
|
||||||
int err;
|
int err = NOERR;
|
||||||
|
|
||||||
if (filehnd() != NULL)
|
if (filehnd() != NULL)
|
||||||
{
|
{
|
||||||
cisclosetemp(ptrfilehnd(), NULL, flagdel, &err);
|
cisclosetemp(ptrfilehnd(), NULL, _autodel, &err);
|
||||||
clearfilehnd();
|
clearfilehnd();
|
||||||
}
|
}
|
||||||
_current->_i = NULL;
|
_current->_i = NULL;
|
||||||
@ -805,6 +847,9 @@ int TIsamtempfile::close(bool flagdel)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TSystemsamfile
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int TSystemisamfile::build(TRecnotype eox)
|
int TSystemisamfile::build(TRecnotype eox)
|
||||||
|
|
||||||
|
@ -311,30 +311,10 @@ public:
|
|||||||
int flags(bool updateeod = FALSE);
|
int flags(bool updateeod = FALSE);
|
||||||
int open(unsigned int mode = _manulock) { return _open(mode);} // Apre isam file con lock
|
int open(unsigned int mode = _manulock) { return _open(mode);} // Apre isam file con lock
|
||||||
int close() { return _close();}
|
int close() { return _close();}
|
||||||
TIsamfile(int logicnum, bool linkrecinst = TRUE);
|
TIsamfile(int logicnum, bool linkrecinst);
|
||||||
virtual ~TIsamfile();
|
virtual ~TIsamfile();
|
||||||
};
|
};
|
||||||
|
|
||||||
// @C
|
|
||||||
// Classe TIsamtempfile : public TBaseisamfile
|
|
||||||
//
|
|
||||||
// File isam temporaneo
|
|
||||||
//
|
|
||||||
// @END
|
|
||||||
|
|
||||||
class TIsamtempfile : public TBaseisamfile
|
|
||||||
{
|
|
||||||
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
|
|
||||||
|
|
||||||
int close(bool flagdel = TRUE); // Chiude il file e se e' vero flagdel lo cancella
|
|
||||||
|
|
||||||
TIsamtempfile(int logicnum, bool linkrecinst = FALSE);
|
|
||||||
virtual ~TIsamtempfile();
|
|
||||||
};
|
|
||||||
|
|
||||||
// @C
|
// @C
|
||||||
// Classe TSystemisamfile : public TBaseisamfile
|
// Classe TSystemisamfile : public TBaseisamfile
|
||||||
//
|
//
|
||||||
@ -381,6 +361,10 @@ class TLocalisamfile : public TBaseisamfile
|
|||||||
bool _was_open; // Vero se il file e' stato aperto come Localisamfile
|
bool _was_open; // Vero se il file e' stato aperto come Localisamfile
|
||||||
int _oldkey; // Old key if already open
|
int _oldkey; // Old key if already open
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int open(unsigned int mode = _manulock);
|
||||||
|
int close() ;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// @FPUB
|
// @FPUB
|
||||||
virtual int operator +=(const TRecnotype npos); // Avanza npos record
|
virtual int operator +=(const TRecnotype npos); // Avanza npos record
|
||||||
@ -389,13 +373,34 @@ public:
|
|||||||
virtual int operator --(); // record precedente
|
virtual int operator --(); // record precedente
|
||||||
virtual bool tab() const { return FALSE;} // Ritorna vero se tabella
|
virtual bool tab() const { return FALSE;} // Ritorna vero se tabella
|
||||||
|
|
||||||
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);
|
TLocalisamfile(int logicnum, bool linkrecinst = TRUE);
|
||||||
virtual ~TLocalisamfile();
|
virtual ~TLocalisamfile();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// @C
|
||||||
|
// Classe TIsamtempfile : public TLocalisamfile
|
||||||
|
//
|
||||||
|
// File isam temporaneo
|
||||||
|
//
|
||||||
|
// @END
|
||||||
|
|
||||||
|
class TIsamtempfile : public TLocalisamfile
|
||||||
|
{
|
||||||
|
bool _autodel; // Settato a true se create = 2: cancella il file in chiusura
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// 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 open(const char* radix, bool create, TRecnotype eod, TRecnotype eox);
|
||||||
|
int close();
|
||||||
|
|
||||||
|
public:
|
||||||
|
TIsamtempfile(int logicnum, const char* radix, bool create);
|
||||||
|
virtual ~TIsamtempfile();
|
||||||
|
};
|
||||||
|
|
||||||
// @C
|
// @C
|
||||||
// Classe TRec_array : public TArray
|
// Classe TRec_array : public TArray
|
||||||
//
|
//
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// $Id: maskfld.cpp,v 1.77 1995-02-09 14:47:20 guy Exp $
|
// $Id: maskfld.cpp,v 1.78 1995-02-10 17:42:23 guy Exp $
|
||||||
#include <xvt.h>
|
#include <xvt.h>
|
||||||
|
|
||||||
#include <applicat.h>
|
#include <applicat.h>
|
||||||
@ -41,10 +41,9 @@ TMask_field::TField_Flags::TField_Flags()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Certified 100%
|
// Certified 100%
|
||||||
char TMask_field::TField_Flags::update(const char* s)
|
char TMask_field::TField_Flags::update(const char* f)
|
||||||
{
|
{
|
||||||
const char* kk = s;
|
for (const char* s = f; *s; s++)
|
||||||
for (; *s; s++)
|
|
||||||
switch(toupper(*s))
|
switch(toupper(*s))
|
||||||
{
|
{
|
||||||
case ' ':
|
case ' ':
|
||||||
@ -75,9 +74,7 @@ char TMask_field::TField_Flags::update(const char* s)
|
|||||||
case 'Z':
|
case 'Z':
|
||||||
zerofilled = TRUE; break;
|
zerofilled = TRUE; break;
|
||||||
default :
|
default :
|
||||||
#ifdef DBG
|
CHECKS(0, "FLAG sconosciuto in ", f);
|
||||||
yesnofatal_box("FLAG sconosciuto in %s: %c", kk, *s);
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return *s;
|
return *s;
|
||||||
|
@ -1 +1 @@
|
|||||||
#define VERSION "1.1.5"
|
#define VERSION "1.1.6"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// $Id: relation.cpp,v 1.31 1995-01-16 15:10:49 guy Exp $
|
// $Id: relation.cpp,v 1.32 1995-02-10 17:42:31 guy Exp $
|
||||||
// relation.cpp
|
// relation.cpp
|
||||||
// fv 12/8/93
|
// fv 12/8/93
|
||||||
// relation class for isam files
|
// relation class for isam files
|
||||||
@ -230,6 +230,13 @@ TRelation::TRelation(const char* tabname, bool linkrecinst)
|
|||||||
_files.add(t);
|
_files.add(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRelation::TRelation(TLocalisamfile* f)
|
||||||
|
: _files(4) , _reldefs(4), _errors(NOERR)
|
||||||
|
{
|
||||||
|
_files.add(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TRelation::~TRelation()
|
TRelation::~TRelation()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -375,49 +382,47 @@ void TRelation::write_enable(const char* name, const bool on)
|
|||||||
reldef(idx).write_enable(on);
|
reldef(idx).write_enable(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TRelation::add(int logicnum, const char* relexprs, int key,
|
|
||||||
|
bool TRelation::add(TLocalisamfile* f, const char* relexprs, int key,
|
||||||
int linkto, int alias, bool allow_lock)
|
int linkto, int alias, bool allow_lock)
|
||||||
{
|
{
|
||||||
const int idxto = log2ind(linkto);
|
const int idxto = log2ind(linkto);
|
||||||
if (idxto == NOTFOUND)
|
if (idxto == NOTFOUND)
|
||||||
fatal_box("Can't join file %d to %d", logicnum, linkto);
|
fatal_box("Can't join file %d to %d", f->num(), linkto);
|
||||||
|
|
||||||
int idx = log2ind(logicnum);
|
const int idx = _files.add(f);
|
||||||
TLocalisamfile* f = new TLocalisamfile(logicnum, idx == NOTFOUND);
|
|
||||||
idx = _files.add(f);
|
|
||||||
|
|
||||||
if (relexprs && *relexprs)
|
CHECK(relexprs && *relexprs, "Mancano le espressioni di collegamento");
|
||||||
{
|
|
||||||
TRelationdef* r = new TRelationdef(this, idx, key, idxto,
|
TRelationdef* r = new TRelationdef(this, idx, key, idxto,
|
||||||
relexprs, alias, allow_lock);
|
relexprs, alias, allow_lock);
|
||||||
_reldefs.add(r);
|
_reldefs.add(r);
|
||||||
}
|
|
||||||
return _errors;
|
return _errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool TRelation::add(int logicnum, const char* relexprs, int key,
|
||||||
|
int linkto, int alias, bool allow_lock)
|
||||||
|
{
|
||||||
|
TLocalisamfile* f = new TLocalisamfile(logicnum);
|
||||||
|
return add(f, relexprs, key, linkto, alias, allow_lock);
|
||||||
|
}
|
||||||
|
|
||||||
bool TRelation::add(const char* tabname, const char* relexprs, int key,
|
bool TRelation::add(const char* tabname, const char* relexprs, int key,
|
||||||
int linkto, int alias, bool allow_lock)
|
int linkto, int alias, bool allow_lock)
|
||||||
|
|
||||||
{
|
{
|
||||||
// look for <to> file
|
TTable* t = new TTable(tabname);
|
||||||
const int idxto = log2ind(linkto);
|
return add(t, relexprs, key, linkto, alias, allow_lock);
|
||||||
if (idxto == NOTFOUND)
|
|
||||||
fatal_box("Can't link to file no. %d", linkto);
|
|
||||||
|
|
||||||
int idx = name2ind(tabname);
|
|
||||||
TTable* f = new TTable(tabname, FALSE);
|
|
||||||
idx = _files.add(f);
|
|
||||||
|
|
||||||
if (relexprs && *relexprs)
|
|
||||||
{
|
|
||||||
TRelationdef* r = new TRelationdef(this, idx, key, idxto,
|
|
||||||
relexprs, alias, allow_lock);
|
|
||||||
_reldefs.add(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
return _errors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TRelation::replace(TLocalisamfile* f, int index)
|
||||||
|
{
|
||||||
|
const TLocalisamfile* p = (const TLocalisamfile*)_files.objptr(index);
|
||||||
|
CHECK(p && p->num() == f->num(), "Can't replace a file with different logic number");
|
||||||
|
_files.add(f, index);
|
||||||
|
}
|
||||||
|
|
||||||
TRectype& TRelationdef::load_rec(TRectype& r, const TBaseisamfile& from) const
|
TRectype& TRelationdef::load_rec(TRectype& r, const TBaseisamfile& from) const
|
||||||
{
|
{
|
||||||
r.zero();
|
r.zero();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: relation.h,v 1.11 1995-01-26 13:57:51 guy Exp $ */
|
/* $Id: relation.h,v 1.12 1995-02-10 17:42:33 guy Exp $ */
|
||||||
// join.h
|
// join.h
|
||||||
// fv 12/8/93
|
// fv 12/8/93
|
||||||
// join class for isam files
|
// join class for isam files
|
||||||
@ -75,11 +75,14 @@ public:
|
|||||||
|
|
||||||
// @DES add relation
|
// @DES add relation
|
||||||
// @FPUB
|
// @FPUB
|
||||||
|
|
||||||
|
bool add(TLocalisamfile* f, const char* relexprs, int key,
|
||||||
|
int linkto, int alias, bool allow_lock);
|
||||||
bool add(int logicnum, const char* relexprs, int key = 1,
|
bool add(int logicnum, const char* relexprs, int key = 1,
|
||||||
int linkto = 0, int alias = 0, bool allow_lock = FALSE);
|
int linkto = 0, int alias = 0, bool allow_lock = FALSE);
|
||||||
bool add(const char* tabname, const char* relexprs, int key = 1,
|
bool add(const char* tabname, const char* relexprs, int key = 1,
|
||||||
int linkto = 0, int alias = 0, bool allow_lock = FALSE);
|
int linkto = 0, int alias = 0, bool allow_lock = FALSE);
|
||||||
|
void replace(TLocalisamfile* f, int index = 0);
|
||||||
|
|
||||||
// @DES write methods
|
// @DES write methods
|
||||||
// @FPUB
|
// @FPUB
|
||||||
@ -133,6 +136,8 @@ public:
|
|||||||
|
|
||||||
TRelation(int logicnum, bool linkrecinst = FALSE);
|
TRelation(int logicnum, bool linkrecinst = FALSE);
|
||||||
TRelation(const char* tabname, bool linkrecinst = FALSE);
|
TRelation(const char* tabname, bool linkrecinst = FALSE);
|
||||||
|
TRelation(TLocalisamfile* f);
|
||||||
|
|
||||||
virtual ~TRelation();
|
virtual ~TRelation();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user