Patch level : 2.0 secret patch
Files correlati : ba0.exe Ricompilazione Demo : [ ] Commento : Tolto sh_read dai config git-svn-id: svn://10.65.10.50/trunk@11743 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
a267dfa713
commit
0598cf6162
@ -117,7 +117,8 @@ void TConfig::_write_file()
|
||||
|
||||
if (_file.exist())
|
||||
{
|
||||
ifstream in(_file, ios::in | ios::nocreate, filebuf::sh_read);
|
||||
// ifstream in(_file, ios::in | ios::nocreate, filebuf::sh_read); // PARKED
|
||||
ifstream in(_file, ios::in | ios::nocreate);
|
||||
if (in.good())
|
||||
{
|
||||
TString l(1024);
|
||||
@ -183,6 +184,17 @@ bool TConfig::set_paragraph(const char* section)
|
||||
return ok;
|
||||
}
|
||||
|
||||
const char* TConfig::get_varkey(const char* var, int index) const
|
||||
{
|
||||
if (index >= 0)
|
||||
{
|
||||
TString& tmp = get_tmp_string();
|
||||
tmp << var << '(' << index << ')';
|
||||
return tmp;
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
|
||||
// @mfunc Controlla se esite una variabile nel paragrafo attivo
|
||||
@ -199,13 +211,8 @@ bool TConfig::exist(
|
||||
// dell'array da cercare, diversamente viene cercata la variabile
|
||||
// normale passata in <p var>.
|
||||
{
|
||||
if (index >= 0)
|
||||
{
|
||||
TString key(80);
|
||||
key << var << '(' << index << ')';
|
||||
return _data.is_key(key);
|
||||
}
|
||||
return _data.is_key(var);
|
||||
const char* key = get_varkey(var, index);
|
||||
return _data.is_key(key);
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
@ -224,9 +231,7 @@ bool TConfig::remove(
|
||||
// dell'array da cercare, diversamente viene cercata la variabile
|
||||
// normale passata in <p var>.
|
||||
{
|
||||
TString key(var);
|
||||
if (index >= 0)
|
||||
key << '(' << index << ')';
|
||||
const char* key = get_varkey(var, index);
|
||||
const bool ok = _data.remove(key);
|
||||
if (ok) _dirty = TRUE;
|
||||
return ok;
|
||||
@ -266,15 +271,8 @@ const TString& TConfig::get(
|
||||
if (section && *section) // Cambia paragrafo se necessario
|
||||
set_paragraph(section);
|
||||
|
||||
const TString* val;
|
||||
if (index >= 0)
|
||||
{
|
||||
TString v(80);
|
||||
v << var << '(' << index << ')';
|
||||
val = (TString*)_data.objptr(v);
|
||||
}
|
||||
else
|
||||
val = (TString*)_data.objptr(var);
|
||||
const char* key = get_varkey(var, index);
|
||||
const TString* val = (TString*)_data.objptr(key);
|
||||
|
||||
if (val == NULL) // Se non la trova inserisci il default
|
||||
{
|
||||
@ -475,21 +473,7 @@ bool TConfig::set(
|
||||
if (section && *section)
|
||||
set_paragraph(section);
|
||||
|
||||
/*
|
||||
const bool itwas = exist(var, index);
|
||||
|
||||
if (itwas && !force)
|
||||
error_box("Tentativo di ridefinizione simbolo: %s(%d)", var, index);
|
||||
else
|
||||
{
|
||||
TString256 vvar(var); if (index >= 0) vvar << '(' << index << ')';
|
||||
_data.add(vvar, new TString(value), force);
|
||||
_dirty = TRUE;
|
||||
}
|
||||
*/
|
||||
TString256 key(var);
|
||||
if (index >= 0)
|
||||
key << '(' << index << ')';
|
||||
const char* key = get_varkey(var, index);
|
||||
TString* val = (TString*)_data.objptr(key);
|
||||
const bool itwas = val != NULL;
|
||||
|
||||
@ -547,7 +531,8 @@ word TConfig::items(
|
||||
// @comm Il paragrafo passato in <p section> diventa quello attivo.
|
||||
// <nl>Possono esserci dei "buchi" causati da set() errate
|
||||
{
|
||||
if (section) set_paragraph(section);
|
||||
if (section && *section)
|
||||
set_paragraph(section);
|
||||
for (int cnt = 0; exist(var, cnt); cnt++);
|
||||
return cnt;
|
||||
}
|
||||
|
@ -77,6 +77,8 @@ protected:
|
||||
void _write_file();
|
||||
// @cmember Inizializza il paragrafo leggendo dal file di nome <p fn > i dati
|
||||
void init(const char *fn, const char* pa);
|
||||
|
||||
const char* get_varkey(const char* var, int index) const;
|
||||
|
||||
// @access Public Memeber
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user