-
Notifications
You must be signed in to change notification settings - Fork 2
/
ConfigData.h
116 lines (98 loc) · 3.42 KB
/
ConfigData.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#ifndef __CONFIGDATA
#define __CONFIGDATA
// wxWindows includes
#include <wx/datetime.h>
#include <wx/string.h>
#include <wx/dynarray.h>
#include <wx/confbase.h>
#include <wx/fileconf.h>
// Statsgen Includes
#include "ConfigItem.h"
#define CONFIG_EXPORT_SET_ONLY 0
#define CONFIG_EXPORT_ALL 1
#define CONFIG_ANSWER_TYPE_ASK 0
#define CONFIG_ANSWER_TYPE_USE_LAST 1
#define UPGRADE_TYPE_CONFIG "Configuration File"
#define UPGRADE_TYPE_DATABASE "Database Contents"
#define UPGRADE_TYPE_UNKNOWN "Unknown"
#define CONFIG_WEAPON_GROUP_PREFIX "weapongroup_"
class WeaponGroupCache
{
public:
WeaponGroupCache();
~WeaponGroupCache();
void Open();
void Close();
bool WeaponMatches(wxString &weaponKey,wxString &weaponGroupOrKey);
wxArrayString *ReadWeaponGroup(wxString &weaponGroupOrKey);
private:
bool cacheOpen;
wxArrayString weaponGroups;
wxArrayPtrVoid weaponGroupsContents;
};
class ConfigData
{
public:
ConfigData();
void Initiate();
void Initiate(wxFileName &iniFilename);
virtual ~ConfigData();
void UpgradeDetails(wxString &description,wxString &upgradeType);
void Export(wxArrayString &upgradeList,
ConfigData &sourceConfig,
char *description,
char *group,
int exportType,
int exportAnswerType,
char *recommendation);
void CommitChanges();
void RollbackChanges();
void EmptyCache();
bool ReadTextValue(char *key,wxString *value);
bool ReadTextValue(wxString &key,wxString *value);
bool ReadTextValue(char *key,wxString *value,char *defaultValue);
bool ReadTextValue(wxString &key,wxString *value,char *defaultValue);
void WriteTextValue(wxString &key,wxString &value);
void WriteTextValue(char *key,wxString &value);
void WriteTextValue(wxString &key,char *value);
void WriteTextValue(char *key,char *value);
bool ReadList(char *group,wxArrayString &list);
bool ReadList(wxString &group,wxArrayString &list);
bool ReadList(char *group,wxString &subGroup,wxArrayString &list);
bool ReadList(wxString &group,wxString &subGroup,wxArrayString &list);
bool ReadList(char *group,char *subGroup,wxArrayString &list);
bool ReadList(wxString &group,char *subGroup,wxArrayString &list);
bool WriteList(char *group,wxArrayString &list);
bool WriteList(wxString &group,wxArrayString &list);
bool WriteList(char *group,char *subGroup,wxArrayString &list);
bool WriteList(wxString &group,char *subGroup,wxArrayString &list);
bool WriteList(char *group,wxString &subGroup,wxArrayString &list);
bool WriteList(wxString &group,wxString &subGroup,wxArrayString &list);
bool ReadGroup(char *group,
wxArrayString &keys,
wxArrayString &values);
bool ReadGroup(wxString &group,
wxArrayString &keys,
wxArrayString &values);
bool DeleteGroup(wxString &group);
bool DeleteGroup(char *group);
void ReadGroupList(wxArrayString &listOfGroups);
wxArrayString ReadWeaponGroups();
wxArrayString ReadWeaponGroup(wxString &weaponGroup);
bool WeaponMatches(wxString &weaponKey,wxString &weaponGroupOrKey);
bool IsWeaponGroupKey(wxString &key);
wxArrayString WeaponGroupKeys(wxString &key);
void Close();
void OpenWeaponGroupCache();
void CloseWeaponGroupCache();
private:
int FindConfigCacheEntry(wxString &key);
private:
void PurgeDeletedEntry(wxString &configKey);
ArrayOfConfigItem configKeys;
wxArrayString groupsDeleted;
wxFileConfig *configFile;
wxFileName iniFilename;
WeaponGroupCache weaponGroupCache;
};
#endif