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 » Configurations [Solved]
Re: Configurations [message #55066 is a reply to message #55060] Wed, 07 October 2020 23:10 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
jimlef wrote on Wed, 07 October 2020 19:27
I'm almost there Smile My last hurdle is to work out the configuration for my program. I've looked around here and found information on configfile etc, but can't seem to get it right.

This part works well enough:
Configs::Configs()
{
	configfile = ConfigFile("Invoices.ini");

	if (!FileExists(configfile))
	{
		cfg = "OutputDirectory=/home/james/Desktop/\n";
		cfg << "Companyname=Company Name\n";
		cfg << "Companyowner=James Lefavour\n";
		cfg << "Companyaddress=Home\n";
		cfg << "Companycity=My City\n";
		cfg << "Companystate=My State\n";
		cfg << "Companyzip=MyZip\n";
		cfg << "Companyphone=(555) 555 - 1212\n";
		cfg << "Companyemail=jim@myemail.com\n";
		cfg << "DBFile=/home/james/upp/MyApps/Invoices/sample.db\n";
		
		SaveSettings();
	}
	VectorMap<String, String> mycfg = LoadIniFile(configfile);
	OutputDirectory = mycfg.Get("OutputDirectory", Null);
	companyname = mycfg.Get("Companyname", Null);
	companyowner = mycfg.Get("Companyowne", Null);
	companyaddress = mycfg.Get("Companyaddress", Null);
	companycity = mycfg.Get("Companycity", Null);;
	companystate = mycfg.Get("Companystate", Null);
	companyzip = mycfg.Get("Companyzip", Null);
	companyphone = mycfg.Get("Companyphone", Null);
	companyemail = mycfg.Get("Companyemail", Null);
	DBFile = mycfg.Get("DBFile", Null);
}


Of course, hard-coded things like my home directory need to be changed for the public version Smile Here's my issue though.
Do I have to load the entire config each time I change one item (not a big deal, as it's not large but...) or is there a way to udpate one single value and store that?

If there is a better/simpler configuration method for this, I'd appreciate that info - I've learned a lot but I have a lot to learn Smile It's just simple key/value pairs as you can see.

And I'm sorry if this is in the wrong spot - didn't see something specific to app config issues/questions?

Thank you!

Jim


Usually you just load config on program start, so why that matters?

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Big issue with Visual Studio 2019 (some versions)
Next Topic: How to construct a struct to get data from this XML?
Goto Forum:
  


Current Time: Mon Jun 17 13:35:12 CEST 2024

Total time taken to generate the page: 0.01517 seconds