d100bb385b
git-svn-id: svn://10.65.10.50/trunk@810 c028cbd2-c16b-5b4b-a496-9718f37d4682
85 lines
2.6 KiB
C++
Executable File
85 lines
2.6 KiB
C++
Executable File
#ifndef __CONFIG_H
|
|
#define __CONFIG_H
|
|
|
|
#ifndef XVT_INCL
|
|
#include <xvt.h>
|
|
#endif
|
|
|
|
#ifndef __ASSOC_H
|
|
#include <assoc.h>
|
|
#endif
|
|
|
|
#ifndef __STRINGS_H
|
|
#include <strings.h>
|
|
#endif
|
|
|
|
class ofstream;
|
|
|
|
// questo sara' il principale, per ora non c'e'
|
|
#define CONFIG_GENERAL 0
|
|
// file parametri studio (uno per studio, per ora e' il principale)
|
|
#define CONFIG_STUDIO 1
|
|
// file parametri ditta (uno per ditta)
|
|
#define CONFIG_DITTA 2
|
|
// file conversioni archivi
|
|
#define CONFIG_FCONV 3
|
|
|
|
|
|
class TConfig : public TObject
|
|
{
|
|
TAssoc_array _data;
|
|
TFilename _file;
|
|
bool _dirty, _ispresent;
|
|
TString _paragraph;
|
|
|
|
bool _read_paragraph();
|
|
void _write_paragraph(ofstream&);
|
|
void _write_file();
|
|
void _check_paragraph(const char*);
|
|
void init(const char *fn, const char* pa);
|
|
|
|
public:
|
|
|
|
// ritorna valore di variabile nella sezione corrente o in
|
|
// quella specificata; se non c'e' ritorna ""
|
|
// passando index >=0 viene appeso al nome variabile per
|
|
// implementare un mezzo cazzo di array
|
|
TString& get(const char* var, const char* section = NULL, int index = -1, const char* def = "");
|
|
|
|
// questa ritorna 0 se non c'e', il che e' un po' sfigotto
|
|
long get_long(const char* var, const char* section = NULL, int index = -1, long def = 0L);
|
|
|
|
// questa ritorna FALSE se non c'e', il che e' ancora piu' sfigotto
|
|
bool get_bool(const char* var, const char* section = NULL, int index = -1, bool def = FALSE);
|
|
|
|
COLOR get_color(const char* var, const char* section = NULL, int index = -1, COLOR def = 0);
|
|
|
|
// setta variabile nella sezione corrente o specificata
|
|
// se force == TRUE crea la sezione/variabile se non esiste; altrimenti
|
|
// da' errore; ritorna TRUE se la sezione/var c'era, FALSE diversamente
|
|
// index come per get()
|
|
bool set(const char* var, const char* value, const char* section = NULL,
|
|
bool force = TRUE, int index = -1);
|
|
bool set(const char* var, long value, const char* section = NULL,
|
|
bool force = TRUE, int index = -1);
|
|
|
|
bool exist(const char* var, int index = -1);
|
|
|
|
// TRUE se il paragrafo corrente e' nuovo
|
|
bool new_paragraph() { return !_ispresent; }
|
|
|
|
// items ritorna quanti elementi dell'array nominato sono
|
|
// presenti nella sezione indicata
|
|
// non si risponde di eventuali "buchi" causati da set() errate
|
|
word items(const char* var, const char* section);
|
|
|
|
// il paragrafo iniziale e' il modulo corrente salvo diversa indicazione
|
|
TConfig(int which_config = CONFIG_GENERAL, const char* paragraph = NULL);
|
|
TConfig(const char* file, const char* paragraph = NULL);
|
|
|
|
// il distruttore riscrive il file con le modifiche se necessrio,
|
|
virtual ~TConfig();
|
|
};
|
|
|
|
#endif
|