run*_*ead 13 c++ configuration-files
我正在寻找一个具有非限制性许可证的跨平台C++轻量级配置库.我需要比标准属性文件更复杂的部分,但我不想使用XML(写得太多:-)).
我想用这种方式编写配置:
render =
{
window =
{
width = 800,
height = 600
}
}
Run Code Online (Sandbox Code Playgroud)
Kar*_*oor 15
有boost的property_tree.该许可证允许商业用途.
你的例子:
ptree pt;
pt.put("render.window.width", 800);
pt.put("render.window.height", 600);
Run Code Online (Sandbox Code Playgroud)
这可以例如导出到JSON
write_json("my_config.json", pt);
Run Code Online (Sandbox Code Playgroud)
然后看起来像
{
"render":
{
"window":
{
"width": 800;
"height": 600;
}
}
}
Run Code Online (Sandbox Code Playgroud)
与导出为XML,INI和INFO的方式相同.
您也可以尝试JsonCpp并在中写入配置文件Json,该语法与您喜欢的语法非常相似:
// Configuration options
{
// Default encoding for text
"encoding" : "UTF-8",
// Plug-ins loaded at start-up
"plug-ins" : [
"python",
"c++",
"ruby"
],
// Tab indent size
"indent" : { "length" : 3, "use_space": true }
}
Run Code Online (Sandbox Code Playgroud)
在下,MIT License因此非常宽松。
| 归档时间: |
|
| 查看次数: |
15158 次 |
| 最近记录: |