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?
What about "::" in LoadIniFile? [message #15122] Tue, 01 April 2008 18:49 Go to next message
Sc0rch is currently offline  Sc0rch
Messages: 99
Registered: February 2008
Location: Russia, Rubtsovsk
Member

Sorry for my English. I need in a such pairs in my ini: MAIN::Fullscreen=true. But LoadIniFile-function returns key "MAIN" with "::Fullscreen=true" value. Does anybody know why? And how I can fix it?

Thank you,
Anton
Re: What about "::" in LoadIniFile? [message #15132 is a reply to message #15122] Wed, 02 April 2008 11:41 Go to previous messageGo to next message
Oblivion is currently offline  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 Smile

Regards.




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

Report message to a moderator

Re: What about "::" in LoadIniFile? [message #15135 is a reply to message #15122] Wed, 02 April 2008 12:48 Go to previous message
Sc0rch is currently offline  Sc0rch
Messages: 99
Registered: February 2008
Location: Russia, Rubtsovsk
Member

Thank you. Probably, I can fix it or write my own method.

Anton
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 Apr 29 01:21:57 CEST 2024

Total time taken to generate the page: 0.03866 seconds