Files correlati : agalib, mg3 Ricompilazione Demo : [ ] Commento : 0001561: 002177 Pharmatex - excel da mastrini Con la patch 634 l'esportazione mastrini in excell non ha più l'intestazione colonne git-svn-id: svn://10.65.10.50/trunk@20177 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			199 lines
		
	
	
		
			8.6 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			199 lines
		
	
	
		
			8.6 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #ifndef __CONFIG_H
 | ||
| #define __CONFIG_H 
 | ||
| 
 | ||
| #ifndef __ASSOC_H
 | ||
| #include <assoc.h>
 | ||
| #endif
 | ||
| 
 | ||
| class TConfig;
 | ||
| 
 | ||
| // file lista moduli installati (install.ini)
 | ||
| #define CONFIG_GENERAL  0
 | ||
| // file campo.ini
 | ||
| #define CONFIG_INSTALL  1
 | ||
| // file parametri studio (uno per studio, per ora e' il principale)
 | ||
| #define CONFIG_STUDIO   2
 | ||
| // file parametri ditta (uno per ditta)
 | ||
| #define CONFIG_DITTA    3
 | ||
| // file conversioni archivi
 | ||
| #define CONFIG_FCONV    4
 | ||
| // file parametri utente
 | ||
| #define CONFIG_USER     5
 | ||
| // file parametri stampe
 | ||
| #define CONFIG_STAMPE   6
 | ||
| // file parametri GUI (nel senso di Graphic User Interface)
 | ||
| #define CONFIG_GUI      7
 | ||
| // file parametri workstation
 | ||
| #define CONFIG_WST      8
 | ||
| // file parametri OEM (setup/oem.ini)
 | ||
| #define CONFIG_OEM      9
 | ||
| 
 | ||
| // Callback per for_each_paragraph
 | ||
| typedef int (*CONFIG_CALLBACK)(TConfig& cfg, void* jolly);
 | ||
| 
 | ||
| // @doc EXTERNAL
 | ||
| 
 | ||
| // @class TConfig | Classe per la gestione dei file di configurazione in formato
 | ||
| //                  Windows
 | ||
| //
 | ||
| // @base public | TObject
 | ||
| class TConfig : public TObject
 | ||
| 
 | ||
| // @author:(INTERNAL) Villa
 | ||
| 
 | ||
|   // @comm Sono definite alcune costanti per l'individuazione immediata di
 | ||
|   //       alcuni file particolari e di frequente uso. Tali file sono:
 | ||
|   //
 | ||
|   // @flag CONFIG_GENERAL | Questo sara' il principale, per ora non c'e'
 | ||
|   // @flag CONFIG_STUDIO | File parametri studio (uno per studio, per ora e'
 | ||
|   //                       il principale)
 | ||
|   // @flag CONFIG_DITTA | File parametri ditta (uno per ditta)
 | ||
|   // @flag CONFIG_FCONV | File conversioni archivi
 | ||
|   // @flag CONFIG_USER | File parametri utente
 | ||
|   // @flag CONFIG_STAMPE | File parametri stampe
 | ||
|   // @flag CONFIG_GOLEM | File parametri golem
 | ||
| 
 | ||
|   // @access:(INTERNAL) Private Member
 | ||
| {
 | ||
|   // @cmember:(INTERNAL) Contenuto del paragrafo
 | ||
|   TAssoc_array _data;
 | ||
|   // @cmember:(INTERNAL) Nome del file di configurazione
 | ||
|   TFilename _file;
 | ||
|   // @cmember:(INTERNAL) Indica se il paragrafo e' stato modificato (TRUE se esiste)
 | ||
|   bool _dirty;
 | ||
|   // @cmember:(INTERNAL) Indica se proteggere il TConfig da scrittura
 | ||
|   bool _write_protected;
 | ||
|   // @cmember:(INTERNAL) Indica se il paragrafo e' presente (TRUE se esiste)
 | ||
|   bool _ispresent;
 | ||
|   // @cmember:(INTERNAL) Nome del paragrafo attivo
 | ||
|   TString _paragraph;
 | ||
| 
 | ||
|   // @access Protected Member
 | ||
| protected:
 | ||
|   // @cmember Legge una riga del paragrafo
 | ||
|   bool add_line(const TString& line);
 | ||
|   // @cmember Legge i dati del paragrafo
 | ||
|   bool _read_paragraph();
 | ||
|   // @cmember Scrive i dati del paragrafo
 | ||
|   void _write_paragraph(ofstream&);
 | ||
|   // @cmember Scrive il file di configurazione
 | ||
|   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:
 | ||
| 
 | ||
|   // @cmember Ritorna il valore della variabile nella sezione corrente o in
 | ||
|   //          quella specificata
 | ||
|   virtual const TString& get(const char* var, const char* section = NULL, int index = -1, const char* def = "");
 | ||
| 
 | ||
|   // @cmember Ritorna il valore della variabile nella sezione corrente o in
 | ||
|   //          quella specificata (se la variabile contiene un long)
 | ||
|   long get_long(const char* var, const char* section = NULL, int index = -1, long def = 0L);
 | ||
| 
 | ||
|   // @cmember Ritorna il valore della variabile nella sezione corrente o in
 | ||
|   //          quella specificata (se la variabile contiene un long)
 | ||
|   char get_char(const char* var, const char* section = NULL, int index = -1, char def = ' ' );
 | ||
| 
 | ||
|   // @cmember Ritorna il valore della variabile nella sezione corrente o in
 | ||
|   //          quella specificata (se la variabile contiene un int)
 | ||
|   int get_int(const char* var, const char* section = NULL, int index = -1, int def = 0);
 | ||
|   
 | ||
|   // @cmember Ritorna il valore della variabile nella sezione corrente o in
 | ||
|   //          quella specificata (se la variabile contiene un bool)
 | ||
|   bool get_bool(const char* var, const char* section = NULL, int index = -1, bool def = FALSE);
 | ||
|   
 | ||
|   // @cmember Ritorna il valore del colore settato nella variabile nella
 | ||
|   //          sezione corrente o in quella specificata (COLOR = unsigned long)
 | ||
|   unsigned long get_color(const char* var, const char* section = NULL, int index = -1, unsigned long def = 0);
 | ||
|   
 | ||
|   // @cmember Setta il colore nella sezione corrente o specificata
 | ||
|   bool set_color(const char* var, unsigned long col, const char* section = NULL, bool force = TRUE, int index = -1);
 | ||
| 
 | ||
|   // @cmember Setta la variabile nella sezione corrente o specificata
 | ||
|   bool set(const char* var, const char* value, const char* section = NULL, bool force = TRUE, int index = -1);
 | ||
|   // @cmember Setta la variabile nella sezione corrente o specificata
 | ||
|   bool set(const char* var, long value, const char* section = NULL, bool force = TRUE, int index = -1);
 | ||
|   
 | ||
|   // @cmember Controlla se esite una variabile nel paragrafo attivo
 | ||
|   bool exist(const char* var, int index = -1);         
 | ||
|   
 | ||
|   // @cmember Elimina una variabile nel paragrafo attivo
 | ||
|   bool remove(const char* var, int index = -1);         
 | ||
|   
 | ||
|   // @cmember Elimina tutte le variabili nel paragrafo attivo
 | ||
|   void remove_all();
 | ||
| 
 | ||
|   // @cmember Controlla se il paragrafo corrente e' nuovo (TRUE se nuovo)
 | ||
|   bool new_paragraph() const
 | ||
|   { return !_ispresent; }
 | ||
| 
 | ||
|   // @cmember Ritorna quanti elementi dell'array nominato sono presenti nella
 | ||
|   //          sezione indicata.
 | ||
|   word items(const char* var, const char* section);
 | ||
|   
 | ||
|   // @cmember Ritorna il nome del paragrafo attivo
 | ||
|   const TString& get_paragraph() const { return _paragraph; }
 | ||
|   // @cmember Setta il paragrafo passato come quello attivo
 | ||
|   bool set_paragraph(const char* par);
 | ||
| 
 | ||
|   // @cmember Riempie pl con la lista dei paragrafi
 | ||
|   int list_paragraphs(TString_array& pl);
 | ||
|   
 | ||
|   // @cmember Riempie <p vl> con la lista dei nomi delle variabili 
 | ||
|   //          nella sezione corrente o in quella indicata; se 
 | ||
|   //          add_value e' TRUE ci mette "variabile<pipe>valore" 
 | ||
|   //          se sort=TRUE, l'array <20> ordinato per nomevar(i), altrimenti <20> in ordine HASH
 | ||
|   int list_variables(TString_array& vl, bool add_value = FALSE, const char* section = NULL, const bool sort=FALSE);
 | ||
| 
 | ||
|   // @cmember Ritorna l'intero array delle variabili della sezione 
 | ||
|   //          eventualmente specificata da <p section>
 | ||
|   TAssoc_array& list_variables(const char* section = NULL);
 | ||
|                             
 | ||
|   // @cmember Chiama cfgcb per ogni paragrafo
 | ||
|   int for_each_paragraph(CONFIG_CALLBACK cfgcb, void* jolly);
 | ||
|   
 | ||
|   // @cmember Ritorna il nome del file di configurazione
 | ||
|   const TFilename& name() const { return _file; }
 | ||
| 
 | ||
|   // @cmember Setta il valore del flag di protezione da scrittura
 | ||
|   void write_protect(const bool b = TRUE) { _write_protected = b; }
 | ||
| 
 | ||
|   // @cmember Ritorna il valore del flag di protezione da scrittura
 | ||
|   const bool is_write_protected() const { return _write_protected; }
 | ||
|   
 | ||
|   // @cmember Costruttore (il paragrafo iniziale e' il modulo corrente
 | ||
|   //          salvo diversa indicazione)
 | ||
|   TConfig(int which_config, const char* paragraph = NULL);
 | ||
|   // @cmember Costruttore (il paragrafo iniziale e' il modulo corrente
 | ||
|   //          salvo diversa indicazione)
 | ||
|   TConfig(const char* file, const char* paragraph = NULL);
 | ||
| 
 | ||
|   // @ cmember Distruttore. Riscrive il file con le modifiche se necessrio,
 | ||
|   virtual ~TConfig();
 | ||
| };
 | ||
| 
 | ||
| // Low level utilities
 | ||
| bool           ini_get_bool  (const char* file, const char* para, const char* name, bool defval = false, int idx = -1);
 | ||
| int            ini_get_int   (const char* file, const char* para, const char* name, int defval = 0, int idx = -1);
 | ||
| const TString& ini_get_string(const char* file, const char* para, const char* name, const char* defval = "", int idx = -1);
 | ||
| bool           ini_set_bool  (const char* file, const char* para, const char* name, bool val, int idx = -1);
 | ||
| bool           ini_set_int   (const char* file, const char* para, const char* name, int val, int idx = -1);
 | ||
| bool           ini_set_string(const char* file, const char* para, const char* name, const char* val, int idx = -1);
 | ||
| 
 | ||
| // High level utilities
 | ||
| bool           ini_get_bool  (int cfg, const char* para, const char* name, bool defval = false, int idx = -1);
 | ||
| int            ini_get_int   (int cfg, const char* para, const char* name, int defval = 0, int idx = -1);
 | ||
| const TString& ini_get_string(int cfg, const char* para, const char* name, const char* defval = "", int idx = -1);
 | ||
| bool           ini_set_bool  (int cfg, const char* para, const char* name, bool val, int idx = -1);
 | ||
| bool           ini_set_int   (int cfg, const char* para, const char* name, int val, int idx = -1);
 | ||
| bool           ini_set_string(int cfg, const char* para, const char* name, const char* val, int idx = -1);
 | ||
| 
 | ||
| const TString& get_oem_info(const char* varname, const char* defval = ""); // ini_get_string(CONFIG_OEM, "OEM_?", varname, defval);
 | ||
| bool           is_aga_version(bool power_user_only = false);
 | ||
| 
 | ||
| #endif
 |