Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1214
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 Smile

Regards.




[Updated on: Wed, 02 April 2008 11:53]

Report message to a moderator

 
Read Message
Read Message
Read Message
Previous Topic: what is the largest Array size please? ("out of memory" error)
Next Topic: Convert upp Font size to LOGFONT size
Goto Forum:
  


Current Time: Mon Jul 14 12:40:40 CEST 2025

Total time taken to generate the page: 0.03345 seconds