From 6f7b90061ed7af47bd7b99b1867d898a029c670b Mon Sep 17 00:00:00 2001 From: angelo Date: Fri, 24 May 1996 13:11:23 +0000 Subject: [PATCH] Modificate la TTrec::read_from e la TTrec::print_on per salvare/leggere anche le descrizioni del tracciato record. git-svn-id: svn://10.65.10.50/trunk@2904 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/files.cpp | 36 +++++++++++++++++++++++++++++++++--- include/files.h | 9 +++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/include/files.cpp b/include/files.cpp index ef452d537..1628a7d03 100755 --- a/include/files.cpp +++ b/include/files.cpp @@ -299,6 +299,8 @@ int TDir::items ( TTrec::TTrec () { + _des = NULL; + _tab = ""; _rec = new RecDes; zero (); _num = -1; @@ -483,7 +485,11 @@ void TTrec::update_keydef (int key, const char *desc) void TTrec::print_on (ostream & out) const { - out << num () << '\n'; + const int n = num(); + out << n; + if (_des && n>=3 && n<=5) // Solo se e' una tabella... + out << "|" << _tab; + out << '\n'; const int nfields = fields (); TToken_string s (80); @@ -491,7 +497,10 @@ void TTrec::print_on (ostream & out) const for (int i = 0; i < nfields; i++) { s = fielddef (i); - out << s << '\n'; + out << s ; + if (_des) + out << "|" << _des->get(_rec->Fd[i].Name); + out << '\n'; } const int nkeys = keys (); @@ -507,19 +516,38 @@ void TTrec::read_from (istream & in) { int ln; + const int n = num(); in.getline (_files_tmp_string, sizeof (_files_tmp_string), '\n'); + if (_des && n>=3 && n<=5) + { + TString t(_files_tmp_string); + + if (t.find('|')>-1) + { + TString tabname(t.right(3)); + strcpy(_files_tmp_string,t.left(t.len()-4)); // Toglie il nome della tabella + if (_tab != tabname && !yesno_box("Descrizione relativa alla tabella %s.\n Continuo ?",(const char*) tabname)) + return; + } + } ln = atoi (_files_tmp_string); - if (ln != num () && !yesno_box ("Descrizione relativa al file n.ro %d.\n Continuo ?", ln)) + if (ln != n && !yesno_box ("Descrizione relativa al file n.ro %d.\n Continuo ?", ln)) return; int nfields; in.getline (_files_tmp_string, sizeof (_files_tmp_string), '\n'); nfields = atoi (_files_tmp_string); set_fields (nfields); + TToken_string t; for (int i = 0; i < nfields; i++) { in.getline (_files_tmp_string, sizeof (_files_tmp_string), '\n'); + t = _files_tmp_string; + const int itms = t.items(); + + if (_des && itms == 5) // La descrizione viene caricata solo se esiste + _des->set(_rec->Fd[i].Name, t.get(itms-1)); update_fielddef (i, _files_tmp_string); } int nkeys; @@ -533,6 +561,8 @@ void TTrec::read_from (istream & in) update_keydef (i, _files_tmp_string); } rehash (); + _des = NULL; + _tab = ""; } #endif // FOXPRO diff --git a/include/files.h b/include/files.h index 56228a23e..2699329f9 100755 --- a/include/files.h +++ b/include/files.h @@ -13,6 +13,10 @@ #include #endif +#ifndef __CONFIG_H +#include +#endif + #define DESCPAR "FieldDescr" #define DESCTAB "TabDescr" #define DESCDIR "recdesc" @@ -181,6 +185,10 @@ class TTrec : public TSortable RecDes* _rec; // @cmember:(INTERNAL) Numero del file di appartenenza int _num; + // @cmember:(INTERNAL) Puntatore al TConfig delle descrizioni + TConfig* _des; + // @cmember:(INTERNAL) Nome della tabella + TString _tab; // @access Protected Member protected: @@ -238,6 +246,7 @@ public: virtual void print_on(ostream& out) const; // @cmember Legge il tracciato record da input selezionato virtual void read_from(istream& in); + void set_des(TConfig* c = NULL, const char* tab = "") { _des = c; _tab = tab;} #endif // @cmember Costruttore