00001 /* $Id: ini_type.h 15085 2009-01-14 20:23:45Z peter1138 $ */ 00002 00005 #ifndef INI_TYPE_H 00006 #define INI_TYPE_H 00007 00009 enum IniGroupType { 00010 IGT_VARIABLES = 0, 00011 IGT_LIST = 1, 00012 }; 00013 00015 struct IniItem { 00016 IniItem *next; 00017 char *name; 00018 char *value; 00019 char *comment; 00020 00027 IniItem(struct IniGroup *parent, const char *name, size_t len = 0); 00028 00030 ~IniItem(); 00031 00036 void SetValue(const char *value); 00037 }; 00038 00040 struct IniGroup { 00041 IniGroup *next; 00042 IniGroupType type; 00043 IniItem *item; 00044 IniItem **last_item; 00045 char *name; 00046 char *comment; 00047 00054 IniGroup(struct IniFile *parent, const char *name, size_t len = 0); 00055 00057 ~IniGroup(); 00058 00066 IniItem *GetItem(const char *name, bool create); 00067 00071 void Clear(); 00072 }; 00073 00075 struct IniFile { 00076 IniGroup *group; 00077 IniGroup **last_group; 00078 char *comment; 00079 const char **list_group_names; 00080 00086 IniFile(const char **list_group_names = NULL); 00087 00089 ~IniFile(); 00090 00098 IniGroup *GetGroup(const char *name, size_t len = 0); 00099 00104 void RemoveGroup(const char *name); 00105 00111 void LoadFromDisk(const char *filename); 00112 00118 bool SaveToDisk(const char *filename); 00119 }; 00120 00121 #endif /* INI_TYPE_H */