views:

264

answers:

8

We want to persist some user settings int he GUI part of our code. I used to do Win32 programming exclusively and the typical way this was done was with registry settings.

I assume that this should be done with configuration files, but was wondering if there was a library or cross platform wrapper that made key/value pair persistence very easy.

+1  A: 

Why not use an XML as the configuration file. Then you only have to find a cross platform XML library which is easier IMO. Here is a list of nice XML parsing solutions for C++.

nc3b
I am not a fan of XML - it is far too heavyweight and I find it pretty unreadable. I try not to propagate this standard if I can help it.
Tim
+2  A: 

There is also JSON for a lighter alternative of XML. Lots of implementations on that page too.

DanDan
Sounds good to me. I will check it out. Thanks
Tim
+4  A: 

Qt's QSettings class handles this:

http://doc.qt.nokia.com/4.6/qsettings.html

Pieter
+2  A: 

Qt 4 has a class for it, named QSettings. Looks exactly like what you need.

SigTerm
+1  A: 

Old school Berkley DB comes to mind.

msw
+6  A: 

Boost.PropertyTree supports XML, JSON, INI config files.

J.F. Sebastian
I'll look at it - thanks
Tim
+1  A: 

Have a look at Tokyo Cabinet or at Embedded InnoDB.

Jonas
+1  A: 

In the old days we used .ini files in windows. Here is a portable version of an ini file read/write library
It will work on Windows as well as Linux.

Romain Hippeau
This looks pretty good.
Tim