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
@ -192,32 +192,48 @@ word TConfig::items(const char* var, const char* section)
|
|||||||
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);
|
_file.format("%s/%s", main_app().get_firm_dir(), CONFIG_FILE_DITTA);
|
||||||
if (!fexist(_file))
|
if (!fexist(_file))
|
||||||
{
|
|
||||||
fcopy(CONFIG_FILE_DITTA, _file);
|
fcopy(CONFIG_FILE_DITTA, _file);
|
||||||
|
}
|
||||||
|
|
||||||
if (!fexist(_file))
|
if (!fexist(_file))
|
||||||
fatal_box("Impossibile aprire la configurazione %s",
|
fatal_box("Impossibile aprire la configurazione %s",
|
||||||
which_config < CONFIG_STUDIO ? "generale" :
|
which_config < CONFIG_STUDIO ? "generale" :
|
||||||
which_config == CONFIG_STUDIO ? "di studio" : "della ditta");
|
which_config == CONFIG_STUDIO ? "di studio" : "della ditta");
|
||||||
|
|
||||||
|
init( _file, paragraph );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (_paragraph.empty())
|
TConfig::TConfig(const char *fn, const char* pa)
|
||||||
{
|
{ init(fn, pa); }
|
||||||
_paragraph = MainApp()->name();
|
|
||||||
_paragraph.cut(2);
|
|
||||||
}
|
|
||||||
_ispresent = _read_paragraph();
|
|
||||||
}
|
|
||||||
|
|
||||||
TConfig::~TConfig()
|
TConfig::~TConfig()
|
||||||
{
|
{
|
||||||
|
@ -30,6 +30,7 @@ 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:
|
||||||
|
|
||||||
@ -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();
|
||||||
};
|
};
|
||||||
|
@ -61,6 +61,7 @@ extern short isjournal;
|
|||||||
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);
|
||||||
|
@ -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;
|
||||||
readrec();
|
else
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TCursor& TCursor::operator -=(const TRecnotype npos)
|
|
||||||
|
|
||||||
{
|
|
||||||
if (changed())
|
|
||||||
_totrec = update();
|
|
||||||
_pos -= npos;
|
|
||||||
if (_pos < 0) _pos = 0;
|
if (_pos < 0) _pos = 0;
|
||||||
readrec();
|
readrec();
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return _pos;
|
||||||
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:
|
||||||
|
@ -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