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 » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » Trouble iterrating over VectorMap<String, String> - general StoreIniFile
Trouble iterrating over VectorMap<String, String> - general StoreIniFile [message #18548] Tue, 07 October 2008 21:22 Go to previous message
blueapples is currently offline  blueapples
Messages: 10
Registered: October 2008
Promising Member
I am trying to make a general StoreIniFile function that will take a VectorMap<String, String> and save it's contents as a INI formatted string.

This is what I have so far, which fails on the call to cfg.Get() with a failed assert like "i > 0 && i < size"...

int StoreIniFile(VectorMap<String, String> cfg, const char *filename) {
	int i = 0;
	String cfgstring;
	Vector<String> keys = cfg.GetKeys();
	
	if(cfg.GetCount() > 0) {
		PromptOK(Format("found %i items", cfg.GetCount()));
		for(i = 0; i < cfg.GetCount(); i++)
		{
			PromptOK(Format("Key %i: %s Value: %s", i, keys[i], cfg.Get(keys[i])));
			// cfgstring << keys[i] << "=" << cfg.Get(keys[i]) << "\n";
		}
	}
	//SaveFile(filename, cfgstring);
	return true;
}


The particular map that I am trying to save is loaded like this:

VectorMap<String, String> cfg;
String cfgfile;
cfgfile = ConfigFile();

PromptOK(Format("Config file: %s", cfgfile));

if(FileExists(cfgfile))
{
	//LoadFromFile(cfg, cfgfile);
	cfg = LoadIniFile(cfgfile);
	PromptOK(Format("Loaded testsetting = %s", cfg.Get("testsetting")));
} else {
	// Set default settings
	cfg.Add("testsetting", "test setting value");
}



Any help would be appreciated. I have used C++ in the past but not really extensively. I'm looking for a new development platform and trying to convert some of my projects over to Upp to see if it will be a good solution. So far, it seems like it has everything, but I seem to have some gaps in my C++ knowledge, and struggle with the relatively light documentation for Upp... it still might be the solution for me though as I really like reading library code Wink.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Collaborative U++ Projects
Next Topic: Drawing raw data to an Image / Draw object?
Goto Forum:
  


Current Time: Fri Apr 26 18:58:41 CEST 2024

Total time taken to generate the page: 0.03528 seconds