1994-09-19 09:50:07 +00:00
|
|
|
#ifndef __CONFIG_H
|
1995-01-02 09:33:00 +00:00
|
|
|
#define __CONFIG_H
|
|
|
|
|
1995-02-28 10:25:02 +00:00
|
|
|
#ifndef INCL_XVTH
|
1995-01-02 09:33:00 +00:00
|
|
|
#include <xvt.h>
|
|
|
|
#endif
|
1994-09-19 09:50:07 +00:00
|
|
|
|
|
|
|
#ifndef __ASSOC_H
|
|
|
|
#include <assoc.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class ofstream;
|
|
|
|
|
|
|
|
// questo sara' il principale, per ora non c'e'
|
1994-09-27 10:07:50 +00:00
|
|
|
#define CONFIG_GENERAL 0
|
1994-09-19 09:50:07 +00:00
|
|
|
// file parametri studio (uno per studio, per ora e' il principale)
|
1994-09-27 10:07:50 +00:00
|
|
|
#define CONFIG_STUDIO 1
|
1994-09-19 09:50:07 +00:00
|
|
|
// file parametri ditta (uno per ditta)
|
1994-09-27 10:07:50 +00:00
|
|
|
#define CONFIG_DITTA 2
|
|
|
|
// file conversioni archivi
|
|
|
|
#define CONFIG_FCONV 3
|
1995-02-28 10:25:02 +00:00
|
|
|
// file parametri utente
|
|
|
|
#define CONFIG_USER 4
|
1995-05-12 09:24:47 +00:00
|
|
|
// file parametri stampe
|
|
|
|
#define CONFIG_STAMPE 5
|
1995-05-16 09:35:12 +00:00
|
|
|
// file parametri golem
|
|
|
|
#define CONFIG_GOLEM 6
|
1994-09-19 09:50:07 +00:00
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @doc EXTERNAL
|
|
|
|
|
1995-05-26 10:16:03 +00:00
|
|
|
// @class TConfig | Classe per la gestione dei file di configurazione in formato
|
|
|
|
// Windows
|
|
|
|
//
|
|
|
|
// @base public | TObject
|
1994-09-19 09:50:07 +00:00
|
|
|
class TConfig : public TObject
|
1996-02-05 19:00:53 +00:00
|
|
|
|
|
|
|
// @author:(INTERNAL) Villa
|
1994-09-19 09:50:07 +00:00
|
|
|
|
1995-05-26 10:16:03 +00:00
|
|
|
// @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
|
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @access:(INTERNAL) Private Member
|
|
|
|
{
|
1995-05-26 10:16:03 +00:00
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @cmember:(INTERNAL) Contenuto del paragrafo
|
1995-05-26 10:16:03 +00:00
|
|
|
TAssoc_array _data;
|
1996-02-05 19:00:53 +00:00
|
|
|
// @cmember:(INTERNAL) Nome del file di configurazione
|
1995-05-26 10:16:03 +00:00
|
|
|
TFilename _file;
|
1996-02-05 19:00:53 +00:00
|
|
|
// @cmember:(INTERNAL) Indica se il paragrafo e' stato modificato (TRUE se esiste)
|
1995-05-26 10:16:03 +00:00
|
|
|
bool _dirty;
|
1996-02-05 19:00:53 +00:00
|
|
|
// @cmember:(INTERNAL) Indica se il paragrafo e' presente (TRUE se esiste)
|
1995-05-26 10:16:03 +00:00
|
|
|
bool _ispresent;
|
1996-02-05 19:00:53 +00:00
|
|
|
// @cmember:(INTERNAL) Nome del paragrafo attivo
|
1995-05-26 10:16:03 +00:00
|
|
|
TString _paragraph;
|
|
|
|
|
|
|
|
// @access Protected Member
|
1995-05-16 09:35:12 +00:00
|
|
|
protected:
|
1995-05-26 10:16:03 +00:00
|
|
|
// @cmember Legge i dati del paragrafo
|
1994-09-19 09:50:07 +00:00
|
|
|
bool _read_paragraph();
|
1995-05-26 10:16:03 +00:00
|
|
|
// @cmember Scrive i dati del paragrafo
|
1994-09-19 09:50:07 +00:00
|
|
|
void _write_paragraph(ofstream&);
|
1995-05-26 10:16:03 +00:00
|
|
|
// @cmember Scrive il file di configurazione
|
1994-09-19 09:50:07 +00:00
|
|
|
void _write_file();
|
1995-05-26 10:16:03 +00:00
|
|
|
// @cmember Inizializza il paragrafo leggendo dal file i dati
|
1994-09-22 16:47:50 +00:00
|
|
|
void init(const char *fn, const char* pa);
|
1994-09-19 09:50:07 +00:00
|
|
|
|
1995-05-26 10:16:03 +00:00
|
|
|
// @access Public Memeber
|
1994-09-22 16:47:50 +00:00
|
|
|
public:
|
1994-09-19 09:50:07 +00:00
|
|
|
|
1995-05-26 10:16:03 +00:00
|
|
|
// @cmember Ritorna il valore della variabile nella sezione corrente o in
|
|
|
|
// quella specificata
|
1995-01-02 09:33:00 +00:00
|
|
|
TString& get(const char* var, const char* section = NULL, int index = -1, const char* def = "");
|
1994-09-19 09:50:07 +00:00
|
|
|
|
1995-05-26 10:16:03 +00:00
|
|
|
// @cmember Ritorna il valore della variabile nella sezione corrente o in
|
|
|
|
// quella specificata (se la variabile contiene un long)
|
1995-01-02 09:33:00 +00:00
|
|
|
long get_long(const char* var, const char* section = NULL, int index = -1, long def = 0L);
|
1995-01-24 08:52:49 +00:00
|
|
|
|
1995-11-22 13:40:15 +00:00
|
|
|
// @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 = ' ' );
|
|
|
|
|
1995-05-26 10:16:03 +00:00
|
|
|
// @cmember Ritorna il valore della variabile nella sezione corrente o in
|
|
|
|
// quella specificata (se la variabile contiene un int)
|
1995-01-24 08:52:49 +00:00
|
|
|
int get_int(const char* var, const char* section = NULL, int index = -1, int def = 0);
|
1994-09-19 09:50:07 +00:00
|
|
|
|
1995-05-26 10:16:03 +00:00
|
|
|
// @cmember Ritorna il valore della variabile nella sezione corrente o in
|
|
|
|
// quella specificata (se la variabile contiene un bool)
|
1995-01-02 09:33:00 +00:00
|
|
|
bool get_bool(const char* var, const char* section = NULL, int index = -1, bool def = FALSE);
|
|
|
|
|
1995-05-26 10:16:03 +00:00
|
|
|
// @cmember Ritorna il valore del colore settato nella variabile nella
|
|
|
|
// sezione corrente o in quella specificata
|
1995-01-02 09:33:00 +00:00
|
|
|
COLOR get_color(const char* var, const char* section = NULL, int index = -1, COLOR def = 0);
|
1994-09-19 09:50:07 +00:00
|
|
|
|
1995-05-26 10:16:03 +00:00
|
|
|
// @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);
|
1994-10-26 12:23:12 +00:00
|
|
|
|
1995-05-26 10:16:03 +00:00
|
|
|
// @cmember Controlla se esite una variabile nel paragrafo attivo
|
1994-10-26 12:23:12 +00:00
|
|
|
bool exist(const char* var, int index = -1);
|
1994-09-19 09:50:07 +00:00
|
|
|
|
1995-05-26 10:16:03 +00:00
|
|
|
// @cmember Controlla se il paragrafo corrente e' nuovo (TRUE se nuovo)
|
|
|
|
bool new_paragraph()
|
|
|
|
{ return !_ispresent; }
|
1994-09-19 09:50:07 +00:00
|
|
|
|
1995-05-26 10:16:03 +00:00
|
|
|
// @cmember Ritorna quanti elementi dell'array nominato sono presenti nella
|
|
|
|
// sezione indicata.
|
1994-09-19 09:50:07 +00:00
|
|
|
word items(const char* var, const char* section);
|
|
|
|
|
1995-05-26 10:16:03 +00:00
|
|
|
// @cmember Setta il paragrafo passato come quello attivo
|
1995-05-16 09:35:12 +00:00
|
|
|
void set_paragraph(const char* par);
|
|
|
|
|
1995-06-28 16:35:30 +00:00
|
|
|
// @cmember Riempie pl con la lista dei paragrafi
|
|
|
|
int list_paragraphs(TString_array& pl);
|
1995-11-14 10:28:24 +00:00
|
|
|
|
1995-12-29 12:09:48 +00:00
|
|
|
// @cmember Riempie <p vl> con la lista dei nomi delle variabili
|
1995-11-14 10:28:24 +00:00
|
|
|
// nella sezione corrente o in quella indicata; se
|
1995-12-29 12:09:48 +00:00
|
|
|
// add_value e' TRUE ci mette "variabile<pipe>valore"
|
1995-11-14 10:28:24 +00:00
|
|
|
// ACHTUNG: l'array e' in ordine HASH (CAZZ)
|
|
|
|
int list_variables(TString_array& vl, bool add_value = FALSE, const char* section = NULL);
|
1996-06-18 13:33:27 +00:00
|
|
|
|
|
|
|
// @cmember Ritorna l'intero array delle variabili della sezione
|
|
|
|
// eventualmente specificata da <p section>
|
|
|
|
const TAssoc_array& list_variables(const char* section = NULL);
|
1995-11-14 10:28:24 +00:00
|
|
|
|
1996-08-21 10:38:27 +00:00
|
|
|
// @cmember Ritorna il nome del file di configurazione
|
|
|
|
const TFilename & name() { return _file; }
|
|
|
|
|
1995-05-26 10:16:03 +00:00
|
|
|
// @cmember Costruttore (il paragrafo iniziale e' il modulo corrente
|
|
|
|
// salvo diversa indicazione)
|
1994-09-19 09:50:07 +00:00
|
|
|
TConfig(int which_config = CONFIG_GENERAL, const char* paragraph = NULL);
|
1995-05-26 10:16:03 +00:00
|
|
|
// @cmember Costruttore (il paragrafo iniziale e' il modulo corrente
|
|
|
|
// salvo diversa indicazione)
|
1994-09-22 16:47:50 +00:00
|
|
|
TConfig(const char* file, const char* paragraph = NULL);
|
|
|
|
|
1995-05-26 10:16:03 +00:00
|
|
|
// @ cmember Distruttore. Riscrive il file con le modifiche se necessrio,
|
1994-09-19 09:50:07 +00:00
|
|
|
virtual ~TConfig();
|
|
|
|
};
|
|
|
|
|
1996-07-26 15:41:29 +00:00
|
|
|
COLOR RGB2COLOR(unsigned char red, unsigned char green, unsigned char blue);
|
|
|
|
|
1994-09-19 09:50:07 +00:00
|
|
|
#endif
|