Patch level :2.2 282

Files correlati     :cg7.exe
Ricompilazione Demo : [ ]
Commento            :modificata la write dei TFiletext per gestire eventuali record con 'buchi' nei valori dei campi


git-svn-id: svn://10.65.10.50/trunk@13641 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
luca 2005-12-22 13:48:32 +00:00
parent 46a28b4028
commit d832dfd5f9

View File

@ -143,8 +143,11 @@ TTracciato_campo& TTracciato_record::get(int n)
} }
//////////////////////////////////////// TRecord_text //////////////////////////////////////// //////////////////////////////////////// TRecord_text ////////////////////////////////////////
const TString& TRecord_text::row(int pos) const const TString& TRecord_text::row(int pos) const
{ {
return _array.row(pos); const TString* str = (const TString*)_array.objptr(pos);
if (str != NULL)
return *str;
return EMPTY_STRING;
} }
TString& TRecord_text::row(int pos) TString& TRecord_text::row(int pos)
@ -573,15 +576,19 @@ int TFile_text::write(TRecord_text& rec)
const TString& type = rec.type(); const TString& type = rec.type();
TTracciato_record& tr = *t_rec(type); TTracciato_record& tr = *t_rec(type);
const int items = rec.items(); const int items = rec.items();
if (_typepos>=0) if (_typepos>=0)
rec.add(type,_typepos); rec.add(type,_typepos);
const TArray& tac = tr.tracciati_campo();
if (_fixedlen) // campi a lunghezza fissa if (_fixedlen) // campi a lunghezza fissa
{ {
for (int i = 0; i < items; i++) FOR_EACH_ARRAY_ITEM(tac, i, obj)
{ {
TTracciato_campo& tc = tr.get(i); const TTracciato_campo& tc = tr.get(i);
campo = rec.row(i); campo = rec.get(i);
format_textfield(tc, campo); format_textfield(tc, campo);
buffer.overwrite(campo, tc.position()); buffer.overwrite(campo, tc.position());
} }
@ -606,10 +613,11 @@ int TFile_text::write(TRecord_text& rec)
else else
{ {
buffer.separator(_fieldsep); buffer.separator(_fieldsep);
for (int i = 0; i < items; i++) FOR_EACH_ARRAY_ITEM(tac, i, obj)
{ {
TTracciato_campo& tc = tr.get(i); const TTracciato_campo& tc = tr.get(i);
campo = format_textfield(tc, rec.row(i)); campo = rec.get(i);
format_textfield(tc, campo);
buffer.add(campo); buffer.add(campo);
} }
CHECK(_write_file, "Impossibile scrivere su un file chiuso."); CHECK(_write_file, "Impossibile scrivere su un file chiuso.");