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
|
||||
#define APPNAME PRASSI
|
||||
#define QAPPNAME "PRASSI"
|
||||
#define LIBDIR c:\xvt.322\xvtwin\lib
|
||||
#define LIBDIR f:\xvt.322\xvtwin\lib
|
||||
#endif
|
||||
|
||||
#define NO_STD_EDIT_MENU
|
||||
|
@ -42,6 +42,10 @@ void set_autoload_new_files(bool on)
|
||||
__autoload = on;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TExtrectype
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TExtrectype : public TRectype
|
||||
{
|
||||
public:
|
||||
@ -69,6 +73,10 @@ TExtrectype::~TExtrectype()
|
||||
delete _i;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TBaseisamfile
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TBaseisamfile::TBaseisamfile(int logicnum, bool linkrecinst)
|
||||
|
||||
{
|
||||
@ -634,13 +642,21 @@ int TBaseisamfile::_close()
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TLocalisamfile
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TLocalisamfile::TLocalisamfile(int logicnum, bool linkrecinst)
|
||||
: TBaseisamfile(logicnum, linkrecinst)
|
||||
{
|
||||
open();
|
||||
if (_was_open)
|
||||
_oldkey = getkey();
|
||||
setkey(1);
|
||||
{
|
||||
if (linkrecinst <= TRUE)
|
||||
{
|
||||
open();
|
||||
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);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// 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()
|
||||
|
||||
{
|
||||
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;
|
||||
|
||||
if (filehnd() != NULL)
|
||||
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))
|
||||
{
|
||||
TFilename s(filename());
|
||||
TFilename s(filename()); s.ext("hst");
|
||||
|
||||
s.ext("hst");
|
||||
_hf.len() = filehnd()->d->LenR;
|
||||
_hf.base() = 1;
|
||||
_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)
|
||||
{
|
||||
cisclosetemp(ptrfilehnd(), NULL, flagdel, &err);
|
||||
cisclosetemp(ptrfilehnd(), NULL, _autodel, &err);
|
||||
clearfilehnd();
|
||||
}
|
||||
_current->_i = NULL;
|
||||
@ -805,6 +847,9 @@ int TIsamtempfile::close(bool flagdel)
|
||||
return err;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TSystemsamfile
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
int TSystemisamfile::build(TRecnotype eox)
|
||||
|
||||
|
@ -311,30 +311,10 @@ public:
|
||||
int flags(bool updateeod = FALSE);
|
||||
int open(unsigned int mode = _manulock) { return _open(mode);} // Apre isam file con lock
|
||||
int close() { return _close();}
|
||||
TIsamfile(int logicnum, bool linkrecinst = TRUE);
|
||||
TIsamfile(int logicnum, bool linkrecinst);
|
||||
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
|
||||
// Classe TSystemisamfile : public TBaseisamfile
|
||||
//
|
||||
@ -381,6 +361,10 @@ class TLocalisamfile : public TBaseisamfile
|
||||
bool _was_open; // Vero se il file e' stato aperto come Localisamfile
|
||||
int _oldkey; // Old key if already open
|
||||
|
||||
protected:
|
||||
int open(unsigned int mode = _manulock);
|
||||
int close() ;
|
||||
|
||||
public:
|
||||
// @FPUB
|
||||
virtual int operator +=(const TRecnotype npos); // Avanza npos record
|
||||
@ -389,13 +373,34 @@ public:
|
||||
virtual int operator --(); // record precedente
|
||||
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.
|
||||
TLocalisamfile(int logicnum, bool linkrecinst = TRUE);
|
||||
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
|
||||
// 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 <applicat.h>
|
||||
@ -41,10 +41,9 @@ TMask_field::TField_Flags::TField_Flags()
|
||||
}
|
||||
|
||||
// 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 (; *s; s++)
|
||||
for (const char* s = f; *s; s++)
|
||||
switch(toupper(*s))
|
||||
{
|
||||
case ' ':
|
||||
@ -75,9 +74,7 @@ char TMask_field::TField_Flags::update(const char* s)
|
||||
case 'Z':
|
||||
zerofilled = TRUE; break;
|
||||
default :
|
||||
#ifdef DBG
|
||||
yesnofatal_box("FLAG sconosciuto in %s: %c", kk, *s);
|
||||
#endif
|
||||
CHECKS(0, "FLAG sconosciuto in ", f);
|
||||
break;
|
||||
}
|
||||
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
|
||||
// fv 12/8/93
|
||||
// relation class for isam files
|
||||
@ -230,6 +230,13 @@ TRelation::TRelation(const char* tabname, bool linkrecinst)
|
||||
_files.add(t);
|
||||
}
|
||||
|
||||
TRelation::TRelation(TLocalisamfile* f)
|
||||
: _files(4) , _reldefs(4), _errors(NOERR)
|
||||
{
|
||||
_files.add(f);
|
||||
}
|
||||
|
||||
|
||||
TRelation::~TRelation()
|
||||
{}
|
||||
|
||||
@ -375,49 +382,47 @@ void TRelation::write_enable(const char* name, const bool 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)
|
||||
{
|
||||
const int idxto = log2ind(linkto);
|
||||
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);
|
||||
TLocalisamfile* f = new TLocalisamfile(logicnum, idx == NOTFOUND);
|
||||
idx = _files.add(f);
|
||||
const int idx = _files.add(f);
|
||||
|
||||
if (relexprs && *relexprs)
|
||||
{
|
||||
TRelationdef* r = new TRelationdef(this, idx, key, idxto,
|
||||
relexprs, alias, allow_lock);
|
||||
_reldefs.add(r);
|
||||
}
|
||||
CHECK(relexprs && *relexprs, "Mancano le espressioni di collegamento");
|
||||
|
||||
TRelationdef* r = new TRelationdef(this, idx, key, idxto,
|
||||
relexprs, alias, allow_lock);
|
||||
_reldefs.add(r);
|
||||
|
||||
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,
|
||||
int linkto, int alias, bool allow_lock)
|
||||
|
||||
{
|
||||
// look for <to> file
|
||||
const int idxto = log2ind(linkto);
|
||||
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;
|
||||
TTable* t = new TTable(tabname);
|
||||
return add(t, relexprs, key, linkto, alias, allow_lock);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
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
|
||||
// fv 12/8/93
|
||||
// join class for isam files
|
||||
@ -75,11 +75,14 @@ public:
|
||||
|
||||
// @DES add relation
|
||||
// @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,
|
||||
int linkto = 0, int alias = 0, bool allow_lock = FALSE);
|
||||
bool add(const char* tabname, const char* relexprs, int key = 1,
|
||||
int linkto = 0, int alias = 0, bool allow_lock = FALSE);
|
||||
|
||||
void replace(TLocalisamfile* f, int index = 0);
|
||||
|
||||
// @DES write methods
|
||||
// @FPUB
|
||||
@ -133,6 +136,8 @@ public:
|
||||
|
||||
TRelation(int logicnum, bool linkrecinst = FALSE);
|
||||
TRelation(const char* tabname, bool linkrecinst = FALSE);
|
||||
TRelation(TLocalisamfile* f);
|
||||
|
||||
virtual ~TRelation();
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user