Home » Community » Newbie corner » best method of saving users settings?
best method of saving users settings? [message #33314] |
Sun, 24 July 2011 11:43  |
dave
Messages: 14 Registered: July 2011
|
Promising Member |
|
|
hi,
just wondering what is the best method of saving users settings as presets in a GUI app such that the user can load one's personal settings when the need arises.
is binary method(serialize stream) better or the text based method(ini/xml)?
global app configuration is best when serialized, but if one wants to save user's choices in various GUI forms as in drop lists, switches, options, edit fields etc ,what should one do?
serialize or parse c/XML?
use vector maps?
or anything else?
regards
dave
|
|
|
Re: best method of saving users settings? [message #33319 is a reply to message #33314] |
Sun, 24 July 2011 19:09  |
|
Hi dave,
This is quite common question... I wish there was a simple answer, so we could put it in FAQ section 
It depends a lot on what you want to do. If you want to store some internal information (e.g. GUI state), binary serialization is a good choice. XML is good choice when you store information you want to be easily accessible from other applications or human readable. For storing application configuration, which should be human editable, text based config file is appropriate.
Both Serialize() and Xmlize() have quite similar semantics and working with them is rather simple in U++. For reading/writing the ".ini" like text files, there exist a class that handles this as well.
Using a serialization of map should work in general, but it will make you do more work in case you wan't to store more than just one type. So I would recommend to stay with one of the three methods mentioned above.
Also, nothing stops you from combining these methods. You can save part of the information in serialized form, while the rest is in text file. I personally prefer to have it split, so user only reads what is intended for him to read 
Best regards,
Honza
|
|
|
Goto Forum:
Current Time: Tue Apr 29 05:46:32 CEST 2025
Total time taken to generate the page: 0.00414 seconds
|