Home » U++ Library support » U++ Core » What about "::" in LoadIniFile?
|
Re: What about "::" in LoadIniFile? [message #15132 is a reply to message #15122] |
Wed, 02 April 2008 11:41 |
Oblivion
Messages: 1093 Registered: August 2007
|
Senior Contributor |
|
|
Below is the actual LoadIniFile code.
VectorMap<String, String> LoadIniFile(const char *filename) {
VectorMap<String, String> key;
FileIn in(filename);
if(!in) return key;
int c;
if((c = in.Get()) < 0) return key;
for(;;) {
String k, v;
for(;;) {
if(IsAlNum(c) || c == '_')
k.Cat(c);
else
break;
if((c = in.Get()) < 0) return key;
}
for(;;) {
if(c != '=' && c != ' ') break;
if((c = in.Get()) < 0) return key;
}
for(;;) {
if(c < ' ') break;
v.Cat(c);
if((c = in.Get()) < 0) break;
}
if(!k.IsEmpty())
key.Add(k, v);
if(k == "LINK") {
in.Close();
if(!in.Open(v) || (c = in.Get()) < 0) return key;
}
else
for(;;) {
if(IsAlNum(c)) break;
if((c = in.Get()) < 0) return key;
}
}
}
Since "::" is neither "Alphanumeric" nor the char "_" , it will treat "Main" as a key.
The "problem" is that Load and Save ini file functions seem to allow simple text configurations (as is stated in Upp docs. See "About Storing Configuration" section.) And It seems that it's intentional.
You can use,
Main_Fullscreen=true
Main_xxx=true/false
instead. This will return "Main FullScreen" as the key (then you can easily parse the key string to extract "main" or other optional "keys" such as "FullScreen" you provide within the actual key). Actually this can bu used for quiet complex configruation savings. For, using "_" char allows you to save many keywords in a single key:
e.g.
"Key1_Key2_Key3=true" will give you a key which is composed of "Key1 Key2 Key3". You can iterate through them...
Or if you need smething more complex, use the XML parser
Regards.
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Wed, 02 April 2008 11:53] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Sat May 04 13:33:01 CEST 2024
Total time taken to generate the page: 0.03565 seconds
|