【问题标题】:Good libraries to store config settings in C/C++? (that allows commenting and hand editing) [closed]在 C/C++ 中存储配置设置的好库? (允许评论和手动编辑)[关闭]
【发布时间】:2013-07-09 20:18:04
【问题描述】:

配置文件应该与此类似:

此行被忽略,因为它不在一个部分中

[第 1 节]

KeyNameInt = 9 //在这里评论
KeyNameString = 字符串
KeyNameFloat = 15.32

[第 2 节]

我尝试使用内置的注册表功能,但问题是保存设置很慢

【问题讨论】:

  • 我没用过,但看起来Boost's configuration file parser 可能适合你的需求。
  • 抱歉,关于库推荐的问题在 stackoverflow 上是题外话。
  • 在 user2510575:我一直在尝试,直到我找到了一个更简单的,称为 SimpleIni,但无论如何谢谢 :)。如果有人想要,这里是链接:[link]code.jellycan.com/simpleini.

标签: c++ c file class config


【解决方案1】:

我推荐POCO XML

 /*
+-------------------------------------------------------------------------------+
| Pros:                                                                         |
| * It's a lightweight cross platform library.<br/>                             |
| * It takes 5-10 minutes to compile **vs** boosts 2-3 hours compilation.       |
| * It is self-explanatory.<br/> It is written in modern C++.                   |
| * You can make pretty and understandable configs using the proper indentation.|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| Cons:<br/>                                                                    |
| * Not as advanced as boosts xml library.                                      |
+-------------------------------------------------------------------------------+
*/

【讨论】:

  • 除非我遗漏了什么,否则这只是一个 XML 解析器。 XML 看起来不像询问者想要的格式。
  • @DavidBrown 这是一个 XML 解析器/编写器。例如,iphone 的配置文件是用类似 XML 的标记语言编写的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2010-11-24
  • 2017-02-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-02-23
相关资源
最近更新 更多