MOdifiche di Matteo all classe Config per gestire un file di configurazione
qualsiasi (non codificato con un intero) git-svn-id: svn://10.65.10.50/trunk@279 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
5f655ece6d
commit
1accdb22cf
@ -18,35 +18,35 @@ extern "C"
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool TConfig::_read_paragraph()
|
bool TConfig::_read_paragraph()
|
||||||
// ritorna TRUE se il paragrafo c'era, FALSE altrimenti
|
// ritorna TRUE se il paragrafo c'era, FALSE altrimenti
|
||||||
{
|
{
|
||||||
bool itwas = FALSE;
|
bool itwas = FALSE;
|
||||||
_data.destroy();
|
_data.destroy();
|
||||||
TScanner scan(_file);
|
TScanner scan(_file);
|
||||||
if (scan.paragraph(_paragraph))
|
if (scan.paragraph(_paragraph))
|
||||||
|
{
|
||||||
|
itwas = TRUE;
|
||||||
|
// populate array
|
||||||
|
TString l, key, val;
|
||||||
|
for (;;)
|
||||||
{
|
{
|
||||||
itwas = TRUE;
|
l = scan.line();
|
||||||
// populate array
|
if (l[0] == '#') continue;
|
||||||
TString l, key, val;
|
if (l == "" || l[0] == '[') break;
|
||||||
for (;;)
|
int ind = l.find('=');
|
||||||
{
|
if (ind == -1)
|
||||||
l = scan.line();
|
{
|
||||||
if (l[0] == '#') continue;
|
warning_box("Errore configurazione: file %s, vicino a riga %ud",
|
||||||
if (l == "" || l[0] == '[') break;
|
(const char*)_file, scan.linenum());
|
||||||
int ind = l.find('=');
|
continue;
|
||||||
if (ind == -1)
|
}
|
||||||
{
|
|
||||||
warning_box("Errore configurazione: file %s, vicino a riga %ud",
|
key = l.left(ind); key.trim();
|
||||||
(const char*)_file, scan.linenum());
|
val = l.mid(ind+1); val.trim();
|
||||||
continue;
|
// sostituzione abilitata
|
||||||
}
|
_data.add(key,val,TRUE);
|
||||||
|
|
||||||
key = l.left(ind); key.trim();
|
|
||||||
val = l.mid(ind+1); val.trim();
|
|
||||||
// sostituzione abilitata
|
|
||||||
_data.add(key,val,TRUE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return itwas;
|
return itwas;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,10 +57,10 @@ void TConfig::_write_paragraph(ofstream& out)
|
|||||||
cnf << '[' << _paragraph << ']';
|
cnf << '[' << _paragraph << ']';
|
||||||
out << cnf << '\n';
|
out << cnf << '\n';
|
||||||
for (int i = 0; i < _data.items(); i++)
|
for (int i = 0; i < _data.items(); i++)
|
||||||
{
|
{
|
||||||
THash_object* o = _data.get_hashobj();
|
THash_object* o = _data.get_hashobj();
|
||||||
out << o->key() << "\t= " << (TString&)(o->obj()) << '\n';
|
out << o->key() << "\t= " << (TString&)(o->obj()) << '\n';
|
||||||
}
|
}
|
||||||
out << '\n';
|
out << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,22 +77,22 @@ void TConfig::_write_file()
|
|||||||
bool skip = FALSE, done = FALSE;
|
bool skip = FALSE, done = FALSE;
|
||||||
|
|
||||||
while (!in.eof())
|
while (!in.eof())
|
||||||
{
|
{
|
||||||
in.getline(__tmp_string,sizeof(__tmp_string)-1);
|
in.getline(__tmp_string,sizeof(__tmp_string)-1);
|
||||||
l.trim();
|
l.trim();
|
||||||
|
|
||||||
if (cnf == l)
|
if (cnf == l)
|
||||||
{
|
{
|
||||||
// write paragraph and all variables
|
// write paragraph and all variables
|
||||||
_write_paragraph(out);
|
_write_paragraph(out);
|
||||||
skip = TRUE; done = TRUE;
|
skip = TRUE; done = TRUE;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (skip) skip = l[0] != '[';
|
|
||||||
if (!skip) out << l << '\n';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (skip) skip = l[0] != '[';
|
||||||
|
if (!skip) out << l << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
// new paragraph
|
// new paragraph
|
||||||
if (!done) _write_paragraph(out);
|
if (!done) _write_paragraph(out);
|
||||||
|
|
||||||
@ -106,13 +106,13 @@ void TConfig::_write_file()
|
|||||||
|
|
||||||
void TConfig::_check_paragraph(const char* section)
|
void TConfig::_check_paragraph(const char* section)
|
||||||
{
|
{
|
||||||
if (section != NULL && section != _paragraph)
|
if (section != NULL && section != _paragraph)
|
||||||
{
|
{
|
||||||
if (_dirty) _write_file();
|
if (_dirty) _write_file();
|
||||||
_paragraph = section;
|
_paragraph = section;
|
||||||
_dirty = FALSE;
|
_dirty = FALSE;
|
||||||
_read_paragraph();
|
_read_paragraph();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TString& TConfig::get(const char* var, const char* section, int index)
|
TString& TConfig::get(const char* var, const char* section, int index)
|
||||||
@ -121,8 +121,8 @@ TString& TConfig::get(const char* var, const char* section, int index)
|
|||||||
// quella specificata
|
// quella specificata
|
||||||
static TFixed_string s(__tmp_string, 256);
|
static TFixed_string s(__tmp_string, 256);
|
||||||
TString vvar(var); if (index != -1) vvar << '(' << index << ')';
|
TString vvar(var); if (index != -1) vvar << '(' << index << ')';
|
||||||
|
|
||||||
_check_paragraph(section);
|
_check_paragraph(section);
|
||||||
|
|
||||||
if (_data.is_key(vvar))
|
if (_data.is_key(vvar))
|
||||||
s = (TString&)_data[vvar];
|
s = (TString&)_data[vvar];
|
||||||
@ -151,29 +151,29 @@ bool TConfig::get_bool(const char* var, const char* section, int index)
|
|||||||
|
|
||||||
|
|
||||||
bool TConfig::set(const char* var, const char* value, const char* section,
|
bool TConfig::set(const char* var, const char* value, const char* section,
|
||||||
bool force, int index)
|
bool force, int index)
|
||||||
{
|
{
|
||||||
// setta variabile nella sezione corrente o specificata
|
// setta variabile nella sezione corrente o specificata
|
||||||
// se force == TRUE crea la variabile se non esiste; altrimenti
|
// se force == TRUE crea la variabile se non esiste; altrimenti
|
||||||
// da' errore; ritorna TRUE se la variabile c'era, FALSE diversamente
|
// da' errore; ritorna TRUE se la variabile c'era, FALSE diversamente
|
||||||
|
|
||||||
_check_paragraph(section);
|
_check_paragraph(section);
|
||||||
TString vvar(var); if (index != -1) vvar << '(' << index << ')';
|
TString vvar(var); if (index != -1) vvar << '(' << index << ')';
|
||||||
|
|
||||||
bool itwas = _data.is_key(vvar);
|
bool itwas = _data.is_key(vvar);
|
||||||
|
|
||||||
if (itwas && !force)
|
if (itwas && !force)
|
||||||
warning_box("Tentativo di ridefinizione simbolo: %s", (const char*)vvar);
|
warning_box("Tentativo di ridefinizione simbolo: %s", (const char*)vvar);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_dirty = TRUE;
|
_dirty = TRUE;
|
||||||
_data.add(vvar, new TString(value), force);
|
_data.add(vvar, new TString(value), force);
|
||||||
}
|
}
|
||||||
return itwas;
|
return itwas;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TConfig::set(const char* var, long value, const char* section,
|
bool TConfig::set(const char* var, long value, const char* section,
|
||||||
bool force, int index)
|
bool force, int index)
|
||||||
{
|
{
|
||||||
TString t; t << value;
|
TString t; t << value;
|
||||||
return set(var,t,section,force,index);
|
return set(var,t,section,force,index);
|
||||||
@ -184,41 +184,57 @@ word TConfig::items(const char* var, const char* section)
|
|||||||
_check_paragraph(section);
|
_check_paragraph(section);
|
||||||
TString vvar(16);
|
TString vvar(16);
|
||||||
for (int cnt = 0; /* uncazzo */ ;cnt++)
|
for (int cnt = 0; /* uncazzo */ ;cnt++)
|
||||||
{
|
{
|
||||||
vvar = var; vvar << '(' << cnt << ')';
|
vvar = var; vvar << '(' << cnt << ')';
|
||||||
if (!_data.is_key(var))
|
if (!_data.is_key(var))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
TConfig::TConfig(int which_config, const char* paragraph) :
|
|
||||||
_paragraph(paragraph), _dirty(FALSE), _ispresent(FALSE)
|
void TConfig::init(const char *fn, const char* pa)
|
||||||
|
{
|
||||||
|
_file = fn;
|
||||||
|
_paragraph = pa;
|
||||||
|
_dirty = FALSE;
|
||||||
|
|
||||||
|
if (!fexist(_file))
|
||||||
|
fatal_box("Impossibile aprire il file di configurazione %s", fn );
|
||||||
|
|
||||||
|
if (_paragraph.empty())
|
||||||
|
{
|
||||||
|
_paragraph = main_app().name();
|
||||||
|
_paragraph.cut(2);
|
||||||
|
}
|
||||||
|
_ispresent = _read_paragraph();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TConfig::TConfig(int which_config, const char* paragraph)
|
||||||
{
|
{
|
||||||
if (which_config < CONFIG_STUDIO) _file = CONFIG_FILE;
|
if (which_config < CONFIG_STUDIO) _file = CONFIG_FILE;
|
||||||
else
|
else
|
||||||
if (which_config == CONFIG_STUDIO) _file = CONFIG_FILE_STUDIO;
|
if (which_config == CONFIG_STUDIO) _file = CONFIG_FILE_STUDIO;
|
||||||
else
|
else
|
||||||
{
|
|
||||||
_file.format("%s/%s", MainApp()->get_firm_dir(), CONFIG_FILE_DITTA);
|
|
||||||
if (!fexist(_file))
|
|
||||||
{
|
|
||||||
fcopy(CONFIG_FILE_DITTA, _file);
|
|
||||||
if (!fexist(_file))
|
|
||||||
fatal_box("Impossibile aprire la configurazione %s",
|
|
||||||
which_config < CONFIG_STUDIO ? "generale" :
|
|
||||||
which_config == CONFIG_STUDIO ? "di studio" : "della ditta");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (_paragraph.empty())
|
|
||||||
{
|
{
|
||||||
_paragraph = MainApp()->name();
|
_file.format("%s/%s", main_app().get_firm_dir(), CONFIG_FILE_DITTA);
|
||||||
_paragraph.cut(2);
|
if (!fexist(_file))
|
||||||
}
|
fcopy(CONFIG_FILE_DITTA, _file);
|
||||||
_ispresent = _read_paragraph();
|
}
|
||||||
|
|
||||||
|
if (!fexist(_file))
|
||||||
|
fatal_box("Impossibile aprire la configurazione %s",
|
||||||
|
which_config < CONFIG_STUDIO ? "generale" :
|
||||||
|
which_config == CONFIG_STUDIO ? "di studio" : "della ditta");
|
||||||
|
|
||||||
|
init( _file, paragraph );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TConfig::TConfig(const char *fn, const char* pa)
|
||||||
|
{ init(fn, pa); }
|
||||||
|
|
||||||
|
|
||||||
TConfig::~TConfig()
|
TConfig::~TConfig()
|
||||||
{
|
{
|
||||||
// il distruttore riscrive il file con le modifiche se necessario
|
// il distruttore riscrive il file con le modifiche se necessario
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
class ofstream;
|
class ofstream;
|
||||||
|
|
||||||
// questo sara' il principale, per ora non c'e'
|
// questo sara' il principale, per ora non c'e'
|
||||||
#define CONFIG_GENERAL -1
|
#define CONFIG_GENERAL -1
|
||||||
// file parametri studio (uno per studio, per ora e' il principale)
|
// file parametri studio (uno per studio, per ora e' il principale)
|
||||||
#define CONFIG_STUDIO 0
|
#define CONFIG_STUDIO 0
|
||||||
// file parametri ditta (uno per ditta)
|
// file parametri ditta (uno per ditta)
|
||||||
@ -30,8 +30,9 @@ class TConfig : public TObject
|
|||||||
void _write_paragraph(ofstream&);
|
void _write_paragraph(ofstream&);
|
||||||
void _write_file();
|
void _write_file();
|
||||||
void _check_paragraph(const char*);
|
void _check_paragraph(const char*);
|
||||||
|
void init(const char *fn, const char* pa);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// ritorna valore di variabile nella sezione corrente o in
|
// ritorna valore di variabile nella sezione corrente o in
|
||||||
// quella specificata; se non c'e' ritorna ""
|
// quella specificata; se non c'e' ritorna ""
|
||||||
@ -50,9 +51,9 @@ class TConfig : public TObject
|
|||||||
// da' errore; ritorna TRUE se la sezione/var c'era, FALSE diversamente
|
// da' errore; ritorna TRUE se la sezione/var c'era, FALSE diversamente
|
||||||
// index come per get()
|
// index come per get()
|
||||||
bool set(const char* var, const char* value, const char* section = NULL,
|
bool set(const char* var, const char* value, const char* section = NULL,
|
||||||
bool force = TRUE, int index = -1);
|
bool force = TRUE, int index = -1);
|
||||||
bool set(const char* var, long value, const char* section = NULL,
|
bool set(const char* var, long value, const char* section = NULL,
|
||||||
bool force = TRUE, int index = -1);
|
bool force = TRUE, int index = -1);
|
||||||
|
|
||||||
// TRUE se il paragrafo corrente e' nuovo
|
// TRUE se il paragrafo corrente e' nuovo
|
||||||
bool new_paragraph() { return !_ispresent; }
|
bool new_paragraph() { return !_ispresent; }
|
||||||
@ -64,6 +65,8 @@ class TConfig : public TObject
|
|||||||
|
|
||||||
// il paragrafo iniziale e' il modulo corrente salvo diversa indicazione
|
// il paragrafo iniziale e' il modulo corrente salvo diversa indicazione
|
||||||
TConfig(int which_config = CONFIG_GENERAL, const char* paragraph = NULL);
|
TConfig(int which_config = CONFIG_GENERAL, const char* paragraph = NULL);
|
||||||
|
TConfig(const char* file, const char* paragraph = NULL);
|
||||||
|
|
||||||
// il distruttore riscrive il file con le modifiche se necessrio,
|
// il distruttore riscrive il file con le modifiche se necessrio,
|
||||||
virtual ~TConfig();
|
virtual ~TConfig();
|
||||||
};
|
};
|
||||||
|
@ -10,35 +10,35 @@
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
/* @DPUB */
|
/* @DPUB */
|
||||||
extern SecDef fdir[2], rdir[2];
|
extern SecDef fdir[2], rdir[2];
|
||||||
extern int dirfl[2], recfl[2];
|
extern int dirfl[2], recfl[2];
|
||||||
extern short formflag;
|
extern short formflag;
|
||||||
extern int SerNo;
|
extern int SerNo;
|
||||||
extern word ModAd;
|
extern word ModAd;
|
||||||
extern char __ptprf[80];
|
extern char __ptprf[80];
|
||||||
|
|
||||||
// Guy moved these outside extern
|
// Guy moved these outside extern
|
||||||
extern isfdptr* openf;
|
extern isfdptr* openf;
|
||||||
extern Str80 cprefix;
|
extern Str80 cprefix;
|
||||||
|
|
||||||
#ifdef __STDTYPES_CPP
|
#ifdef __STDTYPES_CPP
|
||||||
#define extern
|
#define extern
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// extern TDitta cditta;
|
// extern TDitta cditta;
|
||||||
// extern short flprassi;
|
// extern short flprassi;
|
||||||
// extern short flaltmodins;
|
// extern short flaltmodins;
|
||||||
|
|
||||||
extern short isjournal;
|
extern short isjournal;
|
||||||
|
|
||||||
#ifdef __STDTYPES_CPP
|
#ifdef __STDTYPES_CPP
|
||||||
#undef extern
|
#undef extern
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* @END */
|
/* @END */
|
||||||
|
|
||||||
/* @FPUB */
|
/* @FPUB */
|
||||||
short cverdata(char *);
|
short cverdata(char *);
|
||||||
TrDate cpackdata(char *);
|
TrDate cpackdata(char *);
|
||||||
void ceditdata(TrDate ,char *);
|
void ceditdata(TrDate ,char *);
|
||||||
@ -60,10 +60,11 @@ extern short isjournal;
|
|||||||
void CChsize(SecDef *,char *,unsigned ,unsigned ,RecNoType);
|
void CChsize(SecDef *,char *,unsigned ,unsigned ,RecNoType);
|
||||||
void CClose(SecDef *);
|
void CClose(SecDef *);
|
||||||
void CDelete(SecDef *,char *);
|
void CDelete(SecDef *,char *);
|
||||||
void CRead(SecDef *,RecType,RecNoType ,unsigned );
|
void CRead(SecDef *, RecType, RecNoType, unsigned );
|
||||||
|
void CLockRec(SecDef *, RecNoType, unsigned);
|
||||||
void CWrite(SecDef *,RecType,RecNoType ,unsigned );
|
void CWrite(SecDef *,RecType,RecNoType ,unsigned );
|
||||||
int excllock(char *, short);
|
int excllock(char *, short);
|
||||||
int exclunlock(char *, short);
|
int exclunlock(char *, short);
|
||||||
void COpenDir(int, int);
|
void COpenDir(int, int);
|
||||||
void CCloseDir(int);
|
void CCloseDir(int);
|
||||||
void COpenFile(int, FileDes *, int, int);
|
void COpenFile(int, FileDes *, int, int);
|
||||||
@ -94,9 +95,9 @@ extern short isjournal;
|
|||||||
int CZeroField(char *, RecDes *, RecType);
|
int CZeroField(char *, RecDes *, RecType);
|
||||||
void CZeroRec(RecDes *, RecType);
|
void CZeroRec(RecDes *, RecType);
|
||||||
int CBuildKey(RecDes *,int ,RecType, char *);
|
int CBuildKey(RecDes *,int ,RecType, char *);
|
||||||
void CBOpenFile(FilCtrl *,char *,unsigned int, int *);
|
void CBOpenFile(FilCtrl *,char *,unsigned int, int *);
|
||||||
void CBCloseFile(FilCtrl *,int *);
|
void CBCloseFile(FilCtrl *,int *);
|
||||||
void GetHead(FilCtrl *, int, int *);
|
void GetHead(FilCtrl *, int, int *);
|
||||||
int GetAPage(FilCtrl *, Page *,RecNoType ,int *);
|
int GetAPage(FilCtrl *, Page *,RecNoType ,int *);
|
||||||
void GetAKey( Page ,int ,int ,char *,RecNoType *);
|
void GetAKey( Page ,int ,int ,char *,RecNoType *);
|
||||||
void BTrRead(FilCtrl *,char *,char *,RecNoType *,int *);
|
void BTrRead(FilCtrl *,char *,char *,RecNoType *,int *);
|
||||||
@ -141,7 +142,7 @@ extern short isjournal;
|
|||||||
char *sort_op(void);
|
char *sort_op(void);
|
||||||
void sort_stats(void);
|
void sort_stats(void);
|
||||||
|
|
||||||
/* @END */
|
/* @END */
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __EXTCDECL_H
|
#endif // __EXTCDECL_H
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// $Id: maskfld.cpp,v 1.22 1994-09-22 07:47:53 guy Exp $
|
// $Id: maskfld.cpp,v 1.23 1994-09-22 16:47:41 guy Exp $
|
||||||
#include <xvt.h>
|
#include <xvt.h>
|
||||||
|
|
||||||
#include <applicat.h>
|
#include <applicat.h>
|
||||||
@ -2773,23 +2773,31 @@ word TRadio_field::class_id() const
|
|||||||
void TRadio_field::create(WINDOW parent)
|
void TRadio_field::create(WINDOW parent)
|
||||||
{
|
{
|
||||||
const short id = dlg(); // Salva il control id
|
const short id = dlg(); // Salva il control id
|
||||||
|
const int items = _codes.items();
|
||||||
|
|
||||||
if (_prompt.not_empty())
|
if (_prompt.not_empty())
|
||||||
{
|
{
|
||||||
const int dy = _codes.items()+2;
|
const int dy = _flags.persistent ? 3 : items+2;
|
||||||
create_prompt(parent, _width, dy);
|
create_prompt(parent, _width, dy);
|
||||||
}
|
}
|
||||||
_x++; _y++;
|
_x++; _y++;
|
||||||
_values.restart();
|
_values.restart();
|
||||||
|
|
||||||
const char* s;
|
const char* s;
|
||||||
for(_nitems = 0; (s = _values.get()) != NULL; _nitems++, _y++)
|
|
||||||
|
const int width = _flags.persistent ? (_width-2)/items-1 : _width-2;
|
||||||
|
for(_nitems = 0; (s = _values.get()) != NULL; _nitems++)
|
||||||
{
|
{
|
||||||
CHECKD(_nitems < MAX_RADIO, "Too many items in radio button ", id);
|
CHECKD(_nitems < MAX_RADIO, "Too many items in radio button ", id);
|
||||||
|
|
||||||
wincreate(WC_RADIOBUTTON, _width-2, 1, s, parent,0);
|
wincreate(WC_RADIOBUTTON, width, 1, s, parent,0);
|
||||||
_radio_ctl_win[_nitems] = _win;
|
_radio_ctl_win[_nitems] = _win;
|
||||||
_dlg += 1000;
|
_dlg += 1000;
|
||||||
|
|
||||||
|
if (_flags.persistent)
|
||||||
|
_x += width+1;
|
||||||
|
else
|
||||||
|
_y++;
|
||||||
}
|
}
|
||||||
_radio_ctl_win[_nitems] = NULL_WIN; // Comodo per debug
|
_radio_ctl_win[_nitems] = NULL_WIN; // Comodo per debug
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// $Id: relation.cpp,v 1.10 1994-09-22 07:48:05 guy Exp $
|
// $Id: relation.cpp,v 1.11 1994-09-22 16:47:45 guy Exp $
|
||||||
// relation.cpp
|
// relation.cpp
|
||||||
// fv 12/8/93
|
// fv 12/8/93
|
||||||
// relation class for isam files
|
// relation class for isam files
|
||||||
@ -1074,64 +1074,34 @@ TRecnotype TCursor::readrec()
|
|||||||
return nrec;
|
return nrec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TCursor::lock(TReclock l)
|
||||||
|
{
|
||||||
|
CLockRec(&file().filehnd()->f, _pos, l);
|
||||||
|
return file().filehnd()->f.IOR;
|
||||||
|
}
|
||||||
|
|
||||||
TRecnotype TCursor::operator =(const TRecnotype pos)
|
TRecnotype TCursor::operator =(const TRecnotype pos)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (changed())
|
if (changed())
|
||||||
_totrec = update();
|
_totrec = update();
|
||||||
CHECKD(pos >= 0 && pos <= _totrec, "Bad cursor position : ", pos);
|
CHECKD(pos >= 0 && pos <= _totrec, "Bad cursor position : ", pos);
|
||||||
_pos = pos;
|
_pos = pos;
|
||||||
if (_pos > _totrec) _pos = _totrec;
|
|
||||||
readrec();
|
readrec();
|
||||||
return _pos;
|
return _pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRecnotype TCursor::operator +=(const TRecnotype npos)
|
||||||
TCursor& TCursor::operator +=(const TRecnotype npos)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
if (changed())
|
if (changed())
|
||||||
_totrec = update();
|
_totrec = update();
|
||||||
|
|
||||||
_pos += npos;
|
_pos += npos;
|
||||||
if (_pos > _totrec) _pos = _totrec;
|
if (_pos > _totrec) _pos = _totrec;
|
||||||
|
else
|
||||||
|
if (_pos < 0) _pos = 0;
|
||||||
readrec();
|
readrec();
|
||||||
return *this;
|
|
||||||
}
|
return _pos;
|
||||||
|
|
||||||
|
|
||||||
TCursor& TCursor::operator -=(const TRecnotype npos)
|
|
||||||
|
|
||||||
{
|
|
||||||
if (changed())
|
|
||||||
_totrec = update();
|
|
||||||
_pos -= npos;
|
|
||||||
if (_pos < 0) _pos = 0;
|
|
||||||
readrec();
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TCursor& TCursor::operator ++()
|
|
||||||
|
|
||||||
{
|
|
||||||
if (changed())
|
|
||||||
_totrec = update();
|
|
||||||
_pos++;
|
|
||||||
if (_pos > _totrec) _pos = _totrec;
|
|
||||||
readrec();
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TCursor& TCursor::operator --()
|
|
||||||
|
|
||||||
{
|
|
||||||
if (changed())
|
|
||||||
_totrec = update();
|
|
||||||
if (_pos) _pos--;
|
|
||||||
readrec();
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: relation.h,v 1.5 1994-09-22 07:48:07 guy Exp $ */
|
/* $Id: relation.h,v 1.6 1994-09-22 16:47:47 guy Exp $ */
|
||||||
// join.h
|
// join.h
|
||||||
// fv 12/8/93
|
// fv 12/8/93
|
||||||
// join class for isam files
|
// join class for isam files
|
||||||
@ -182,21 +182,24 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// @FPUB
|
// @FPUB
|
||||||
TRecnotype operator =(const TRecnotype nr); // Assegnazione
|
TRecnotype operator =(const TRecnotype nr); // Va alla posizione nr
|
||||||
TCursor& operator +=(const TRecnotype nr); // Scorri avanti
|
TRecnotype operator +=(const TRecnotype nr);
|
||||||
TCursor& operator -=(const TRecnotype nr); // Scorri indietro
|
TRecnotype operator -=(const TRecnotype npos) { return operator +=(-npos); }
|
||||||
TCursor& operator ++(); // Avanti di un record
|
TRecnotype operator ++() { return operator +=(1); }
|
||||||
TCursor& operator --(); // Indietro di un record
|
TRecnotype operator --() { return operator -=(1); }
|
||||||
TRecnotype pos() const { return _pos; }
|
TRecnotype pos() const { return _pos; }
|
||||||
TRecnotype items();
|
TRecnotype items();
|
||||||
TRecnotype size() const { return file().eod(); }
|
TRecnotype size() const { return file().eod(); }
|
||||||
|
|
||||||
const TString& from() const { return _keyfrom; }
|
const TString& from() const { return _keyfrom; }
|
||||||
const TString& to() const { return _keyto; }
|
const TString& to() const { return _keyto; }
|
||||||
|
|
||||||
TRectype& curr(int log = 0) const { return _if->curr(log); }
|
TRectype& curr(int log = 0) const { return _if->curr(log); }
|
||||||
TRectype& curr(const char * tab) const
|
TRectype& curr(const char * tab) const { return _if->lfile(tab).curr(); }
|
||||||
{ return _if->lfile(tab).curr(); }
|
|
||||||
TRecnotype read(TIsamop op = _isgteq, TReclock lockop = _nolock, TDate& atdate = (TDate&)botime);
|
TRecnotype read(TIsamop op = _isgteq, TReclock lockop = _nolock, TDate& atdate = (TDate&)botime);
|
||||||
|
int lock(TReclock = _lock);
|
||||||
|
int unlock() { return lock(_unlock); }
|
||||||
|
|
||||||
virtual bool ok() const;
|
virtual bool ok() const;
|
||||||
|
|
||||||
const char* filter() const { return _filter; }
|
const char* filter() const { return _filter; }
|
||||||
|
@ -56,7 +56,11 @@ public:
|
|||||||
|
|
||||||
// @FPUB
|
// @FPUB
|
||||||
operator const char*() const { return (const char*)_str; } // *(TString) -> _str
|
operator const char*() const { return (const char*)_str; } // *(TString) -> _str
|
||||||
char& operator[](int i) const { return _str[i]; } // TString[i] -> _str[i]
|
char& operator[](int i) // TString[i] -> _str[i]
|
||||||
|
{
|
||||||
|
CHECKD(i >= 0 && i < _size, "Bad string subscript: ", i);
|
||||||
|
return _str[i];
|
||||||
|
}
|
||||||
|
|
||||||
int size() const { return _size; }
|
int size() const { return _size; }
|
||||||
int len() const { return strlen(_str); }
|
int len() const { return strlen(_str); }
|
||||||
@ -216,7 +220,7 @@ class TToken_string : public TString
|
|||||||
protected:
|
protected:
|
||||||
// @FPROT
|
// @FPROT
|
||||||
|
|
||||||
TObject* dup() const; // Crea un duplicato della token string
|
virtual TObject* dup() const; // Crea un duplicato della token string
|
||||||
bool set_item(const char* v, int n);
|
bool set_item(const char* v, int n);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -241,7 +245,7 @@ public:
|
|||||||
char get_char(int n = -1); // Ritorna un carattere
|
char get_char(int n = -1); // Ritorna un carattere
|
||||||
int get_int(int n = -1); // Ritorna un intero
|
int get_int(int n = -1); // Ritorna un intero
|
||||||
long get_long(int n = -1); // Ritorna un intero esteso
|
long get_long(int n = -1); // Ritorna un intero esteso
|
||||||
int get_pos(const char* s); // Ritorna la posizione dell'item s
|
int get_pos(const char* s); // Ritorna la posizione dell'item s
|
||||||
int items() const; // Ritorna il numero di token presenti
|
int items() const; // Ritorna il numero di token presenti
|
||||||
bool empty_items() const; // Controlla se tutti i token sono nulli
|
bool empty_items() const; // Controlla se tutti i token sono nulli
|
||||||
};
|
};
|
||||||
|
@ -484,7 +484,7 @@ HIDDEN bool _autoexit_val(TEdit_field& f, KEY key)
|
|||||||
HIDDEN bool _numcalc_val(TEdit_field& f, KEY k)
|
HIDDEN bool _numcalc_val(TEdit_field& f, KEY k)
|
||||||
{
|
{
|
||||||
if (k != K_TAB) return TRUE;
|
if (k != K_TAB) return TRUE;
|
||||||
TExpression e(get_val_param(0), _numexpr);
|
TExpression e(get_val_param(0), _numexpr);
|
||||||
|
|
||||||
for (int i = 0 ; i < e.numvar(); i++)
|
for (int i = 0 ; i < e.numvar(); i++)
|
||||||
{
|
{
|
||||||
@ -498,7 +498,7 @@ HIDDEN bool _numcalc_val(TEdit_field& f, KEY k)
|
|||||||
const int fldid = atoi(s);
|
const int fldid = atoi(s);
|
||||||
e.setvar(i, fldid == 0 ? f.get() : f.mask().get(fldid));
|
e.setvar(i, fldid == 0 ? f.get() : f.mask().get(fldid));
|
||||||
}
|
}
|
||||||
TFixed_string s((const char*) e);
|
const TFixed_string s((const char*)e);
|
||||||
f.set(s);
|
f.set(s);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user