Home » U++ Library support » U++ Core » Configurations [Solved]
Configurations [Solved] [message #55060] |
Wed, 07 October 2020 19:27 |
jimlef
Messages: 90 Registered: September 2020 Location: US
|
Member |
|
|
I'm almost there 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 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 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
[Updated on: Thu, 08 October 2020 15:03] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Mon May 06 04:54:45 CEST 2024
Total time taken to generate the page: 0.01469 seconds
|