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,33 +192,49 @@ word TConfig::items(const char* var, const char* section)
|
||||
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;
|
||||
else
|
||||
if (which_config == CONFIG_STUDIO) _file = CONFIG_FILE_STUDIO;
|
||||
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))
|
||||
{
|
||||
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();
|
||||
_paragraph.cut(2);
|
||||
}
|
||||
_ispresent = _read_paragraph();
|
||||
|
||||
init( _file, paragraph );
|
||||
}
|
||||
|
||||
TConfig::TConfig(const char *fn, const char* pa)
|
||||
{ init(fn, pa); }
|
||||
|
||||
|
||||
TConfig::~TConfig()
|
||||
{
|
||||
// il distruttore riscrive il file con le modifiche se necessario
|
||||
|
@ -30,8 +30,9 @@ class TConfig : public TObject
|
||||
void _write_paragraph(ofstream&);
|
||||
void _write_file();
|
||||
void _check_paragraph(const char*);
|
||||
void init(const char *fn, const char* pa);
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
// ritorna valore di variabile nella sezione corrente o in
|
||||
// quella specificata; se non c'e' ritorna ""
|
||||
@ -64,6 +65,8 @@ class TConfig : public TObject
|
||||
|
||||
// il paragrafo iniziale e' il modulo corrente salvo diversa indicazione
|
||||
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,
|
||||
virtual ~TConfig();
|
||||
};
|
||||
|
@ -10,35 +10,35 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
/* @DPUB */
|
||||
extern SecDef fdir[2], rdir[2];
|
||||
extern int dirfl[2], recfl[2];
|
||||
extern short formflag;
|
||||
extern int SerNo;
|
||||
extern word ModAd;
|
||||
extern char __ptprf[80];
|
||||
/* @DPUB */
|
||||
extern SecDef fdir[2], rdir[2];
|
||||
extern int dirfl[2], recfl[2];
|
||||
extern short formflag;
|
||||
extern int SerNo;
|
||||
extern word ModAd;
|
||||
extern char __ptprf[80];
|
||||
|
||||
// Guy moved these outside extern
|
||||
extern isfdptr* openf;
|
||||
extern Str80 cprefix;
|
||||
// Guy moved these outside extern
|
||||
extern isfdptr* openf;
|
||||
extern Str80 cprefix;
|
||||
|
||||
#ifdef __STDTYPES_CPP
|
||||
#define extern
|
||||
#endif
|
||||
|
||||
// extern TDitta cditta;
|
||||
// extern short flprassi;
|
||||
// extern short flaltmodins;
|
||||
// extern TDitta cditta;
|
||||
// extern short flprassi;
|
||||
// extern short flaltmodins;
|
||||
|
||||
extern short isjournal;
|
||||
extern short isjournal;
|
||||
|
||||
#ifdef __STDTYPES_CPP
|
||||
#undef extern
|
||||
#endif
|
||||
|
||||
/* @END */
|
||||
/* @END */
|
||||
|
||||
/* @FPUB */
|
||||
/* @FPUB */
|
||||
short cverdata(char *);
|
||||
TrDate cpackdata(char *);
|
||||
void ceditdata(TrDate ,char *);
|
||||
@ -60,7 +60,8 @@ extern short isjournal;
|
||||
void CChsize(SecDef *,char *,unsigned ,unsigned ,RecNoType);
|
||||
void CClose(SecDef *);
|
||||
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 );
|
||||
int excllock(char *, short);
|
||||
int exclunlock(char *, short);
|
||||
@ -141,7 +142,7 @@ extern short isjournal;
|
||||
char *sort_op(void);
|
||||
void sort_stats(void);
|
||||
|
||||
/* @END */
|
||||
/* @END */
|
||||
};
|
||||
|
||||
#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 <applicat.h>
|
||||
@ -2773,23 +2773,31 @@ word TRadio_field::class_id() const
|
||||
void TRadio_field::create(WINDOW parent)
|
||||
{
|
||||
const short id = dlg(); // Salva il control id
|
||||
const int items = _codes.items();
|
||||
|
||||
if (_prompt.not_empty())
|
||||
{
|
||||
const int dy = _codes.items()+2;
|
||||
const int dy = _flags.persistent ? 3 : items+2;
|
||||
create_prompt(parent, _width, dy);
|
||||
}
|
||||
_x++; _y++;
|
||||
_values.restart();
|
||||
|
||||
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);
|
||||
|
||||
wincreate(WC_RADIOBUTTON, _width-2, 1, s, parent,0);
|
||||
wincreate(WC_RADIOBUTTON, width, 1, s, parent,0);
|
||||
_radio_ctl_win[_nitems] = _win;
|
||||
_dlg += 1000;
|
||||
|
||||
if (_flags.persistent)
|
||||
_x += width+1;
|
||||
else
|
||||
_y++;
|
||||
}
|
||||
_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
|
||||
// fv 12/8/93
|
||||
// relation class for isam files
|
||||
@ -1074,64 +1074,34 @@ TRecnotype TCursor::readrec()
|
||||
return nrec;
|
||||
}
|
||||
|
||||
int TCursor::lock(TReclock l)
|
||||
{
|
||||
CLockRec(&file().filehnd()->f, _pos, l);
|
||||
return file().filehnd()->f.IOR;
|
||||
}
|
||||
|
||||
TRecnotype TCursor::operator =(const TRecnotype pos)
|
||||
|
||||
{
|
||||
if (changed())
|
||||
_totrec = update();
|
||||
CHECKD(pos >= 0 && pos <= _totrec, "Bad cursor position : ", pos);
|
||||
_pos = pos;
|
||||
if (_pos > _totrec) _pos = _totrec;
|
||||
readrec();
|
||||
return _pos;
|
||||
}
|
||||
|
||||
|
||||
TCursor& TCursor::operator +=(const TRecnotype npos)
|
||||
|
||||
TRecnotype TCursor::operator +=(const TRecnotype npos)
|
||||
{
|
||||
if (changed())
|
||||
_totrec = update();
|
||||
|
||||
_pos += npos;
|
||||
if (_pos > _totrec) _pos = _totrec;
|
||||
readrec();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
TCursor& TCursor::operator -=(const TRecnotype npos)
|
||||
|
||||
{
|
||||
if (changed())
|
||||
_totrec = update();
|
||||
_pos -= npos;
|
||||
else
|
||||
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;
|
||||
return _pos;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
// fv 12/8/93
|
||||
// join class for isam files
|
||||
@ -182,21 +182,24 @@ protected:
|
||||
|
||||
public:
|
||||
// @FPUB
|
||||
TRecnotype operator =(const TRecnotype nr); // Assegnazione
|
||||
TCursor& operator +=(const TRecnotype nr); // Scorri avanti
|
||||
TCursor& operator -=(const TRecnotype nr); // Scorri indietro
|
||||
TCursor& operator ++(); // Avanti di un record
|
||||
TCursor& operator --(); // Indietro di un record
|
||||
TRecnotype operator =(const TRecnotype nr); // Va alla posizione nr
|
||||
TRecnotype operator +=(const TRecnotype nr);
|
||||
TRecnotype operator -=(const TRecnotype npos) { return operator +=(-npos); }
|
||||
TRecnotype operator ++() { return operator +=(1); }
|
||||
TRecnotype operator --() { return operator -=(1); }
|
||||
TRecnotype pos() const { return _pos; }
|
||||
TRecnotype items();
|
||||
TRecnotype size() const { return file().eod(); }
|
||||
|
||||
const TString& from() const { return _keyfrom; }
|
||||
const TString& to() const { return _keyto; }
|
||||
|
||||
TRectype& curr(int log = 0) const { return _if->curr(log); }
|
||||
TRectype& curr(const char * tab) const
|
||||
{ return _if->lfile(tab).curr(); }
|
||||
TRectype& curr(const char * tab) const { return _if->lfile(tab).curr(); }
|
||||
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;
|
||||
|
||||
const char* filter() const { return _filter; }
|
||||
|
@ -56,7 +56,11 @@ public:
|
||||
|
||||
// @FPUB
|
||||
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 len() const { return strlen(_str); }
|
||||
@ -216,7 +220,7 @@ class TToken_string : public TString
|
||||
protected:
|
||||
// @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);
|
||||
|
||||
public:
|
||||
|
@ -498,7 +498,7 @@ HIDDEN bool _numcalc_val(TEdit_field& f, KEY k)
|
||||
const int fldid = atoi(s);
|
||||
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);
|
||||
return TRUE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user