is there any function in ice to save properties?

in Help Center
we can use "properties->load("config");" to load properties from file.
but is there any function in ice to save properties into file?
but is there any function in ice to save properties into file?
0
Comments
Mark, could you please provide a sample code how one can save the list of props from config file in C++ and then reuse them? Is the storage in that case the config file or just txt?
Thanks
Yuri
(Please also update your signature, as explained in this thread: http://www.zeroc.com/vbulletin/showthread.php?t=1697)
you may want to look at getCommandLineOptions() functions.
see sec. 27.8.3 in the manual. It returns a StringSeq in the form "key=value". These are easy to save into a format from which you can load again later.
alex
Here is some code that writes our properties. It uses a property to define
which properties get written to the file.
Hi,
Thanks for pointing this out. I did change the code above to initialize the buffer to zero. I think this should take care of any problem, since the buffer won't overflow (limited by the maxsize argument), but it could be undefined (strftime returns zero).
Really, I can't think of any cases which would cause strftime to fill the buffer with anything other than the number of bytes specified by the format string.
Cheers,
I agree, and have fixed the code accordingly. You don't have to pass maxlen - 1. At least my man page says that maxlen takes the terminating NULL byte into account.
Still, this is pretty much a nit. If strftime returns more characters than are specified by the format string, then it is broken, and you can't do much to protect against broken code. A buffer sized sufficiently large should really make this a non-issue.
Thanks again,
That being said, not to beat the horse too much, but the problem is that since parts of the strftime format string are locale dependent you don't really know ahead of time (as this code tries to do) how long to make the buffer. For example, perhaps in Hawaiian the month name is some obscenely long thing.
Of course, you are correct. Locale is one of those things that I don't think about much because I know the environment in which my code will run. On the other hand, I'm sure that you guys at ZeroC have to take that kind of thing into account all the time, since you could might be run by anyone, anywhere.
Thanks for all the good feedback.