简体   繁体   English

是否有C ++的C ++跨平台键/值API或库?

[英]Is there a C++ cross platform key/value API or library for C++?

We want to persist some user settings int he GUI part of our code. 我们希望在代码的GUI部分中保留一些用户设置。 I used to do Win32 programming exclusively and the typical way this was done was with registry settings. 我以前只使用Win32编程,这种方式的典型方法是使用注册表设置。

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. 我假设这应该用配置文件完成,但是想知道是否有一个库或跨平台包装器使得键/值对持久性非常容易。

Qt's QSettings class handles this: Qt的QSettings类处理这个:

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

Boost.PropertyTree支持XML,JSON,INI配置文件。

There is also JSON for a lighter alternative of XML. 还有JSON可以替代XML。 Lots of implementations on that page too. 该页面上的大量实现也是如此。

Qt 4 has a class for it, named QSettings . Qt 4有一个类,名为QSettings Looks exactly like what you need. 看起来完全像你需要的。

Why not use an XML as the configuration file. 为什么不使用XML作为配置文件。 Then you only have to find a cross platform XML library which is easier IMO. 然后你只需要找到一个更容易IMO的跨平台XML库。 Here is a list of nice XML parsing solutions for C++. 以下列出了适用于C ++的优秀XML解析解决方案。

想到老派Berkley DB

In the old days we used .ini files in windows. 在过去,我们在Windows中使用.ini文件。 Here is a portable version of an ini file read/write library 这是一个ini文件读/写库的可移植版本
It will work on Windows as well as Linux. 它可以在Windows和Linux上运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM