Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef INI_TYPE_H
00013 #define INI_TYPE_H
00014
00015 #include "fileio_type.h"
00016
00018 enum IniGroupType {
00019 IGT_VARIABLES = 0,
00020 IGT_LIST = 1,
00021 IGT_SEQUENCE = 2,
00022 };
00023
00025 struct IniItem {
00026 IniItem *next;
00027 char *name;
00028 char *value;
00029 char *comment;
00030
00031 IniItem(struct IniGroup *parent, const char *name, size_t len = 0);
00032 ~IniItem();
00033
00034 void SetValue(const char *value);
00035 };
00036
00038 struct IniGroup {
00039 IniGroup *next;
00040 IniGroupType type;
00041 IniItem *item;
00042 IniItem **last_item;
00043 char *name;
00044 char *comment;
00045
00046 IniGroup(struct IniLoadFile *parent, const char *name, size_t len = 0);
00047 ~IniGroup();
00048
00049 IniItem *GetItem(const char *name, bool create);
00050 void Clear();
00051 };
00052
00054 struct IniLoadFile {
00055 IniGroup *group;
00056 IniGroup **last_group;
00057 char *comment;
00058 const char * const *list_group_names;
00059 const char * const *seq_group_names;
00060
00061 IniLoadFile(const char * const *list_group_names = NULL, const char * const *seq_group_names = NULL);
00062 virtual ~IniLoadFile();
00063
00064 IniGroup *GetGroup(const char *name, size_t len = 0, bool create_new = true);
00065 void RemoveGroup(const char *name);
00066
00067 void LoadFromDisk(const char *filename, Subdirectory subdir);
00068
00076 virtual FILE *OpenFile(const char *filename, Subdirectory subdir, size_t *size) = 0;
00077
00084 virtual void ReportFileError(const char * const pre, const char * const buffer, const char * const post) = 0;
00085 };
00086
00088 struct IniFile : IniLoadFile {
00089 IniFile(const char * const *list_group_names = NULL);
00090
00091 bool SaveToDisk(const char *filename);
00092
00093 virtual FILE *OpenFile(const char *filename, Subdirectory subdir, size_t *size);
00094 virtual void ReportFileError(const char * const pre, const char * const buffer, const char * const post);
00095 };
00096
00097 #endif