Home » U++ Library support » U++ Core » TextSettings update
TextSettings update [message #19976] |
Fri, 06 February 2009 19:29 |
cbpporter
Messages: 1401 Registered: September 2007
|
Ultimate Contributor |
|
|
TextSettings is fairly useless right now. There is no way to handle an INI file without knowing what is inside.
I propose these changes:
class TextSettings {
VectorMap< String, VectorMap< String, String > > settings;
public:
String Get(const char *group, const char *key) const;
String Get(const char *key) const { return Get("", key); }
String Get(int groupIndex, const char *key) const;
String Get(int groupIndex, int keyIndex) const;
String operator()(const char *group, const char *key) const { return Get(group, key); }
String operator()(const char *key) const { return Get(key); }
void Clear() { settings.Clear(); }
void Load(const char *filename);
int GetGroupCount() { return settings.GetCount(); }
int GetKeyCount(int group) { return settings[group].GetCount(); }
String GetGroupName(int groupIndex) { return settings.GetKey(groupIndex); }
String GetKey(int groupIndex, int keyIndex) { return settings[groupIndex].GetKey(keyIndex); }
};
String TextSettings::Get(const char *group, const char *key) const
{
int itemi = settings.Find(group);
return itemi < 0 ? Null : settings.Get(group).Get(key, Null);
}
String TextSettings::Get(int groupIndex, const char *key) const
{
return groupIndex >= 0 && groupIndex < settings.GetCount() ? settings[groupIndex].Get(key, Null) : Null;
}
String TextSettings::Get(int groupIndex, int keyIndex) const
{
if (groupIndex >= 0 && groupIndex < settings.GetCount())
return keyIndex >= 0 && keyIndex < settings[groupIndex].GetCount() ? settings[groupIndex][keyIndex] : Null;
else
return Null;
}
|
|
|
|
|
|
|
Goto Forum:
Current Time: Wed Apr 24 17:37:18 CEST 2024
Total time taken to generate the page: 2.92222 seconds
|