是否有一些常见的方式来写和读配置文件? [英] Is there some common way to write and read config files?

查看:92
本文介绍了是否有一些常见的方式来写和读配置文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要我的程序来创建和编辑一个配置文件,它将包含关于对象集的信息,而不是在每次执行时读取它。

I need my program to create and edit a config file, which would contain information about set of objects, and than read it at every execution. Is there some sort of guideline for config style that i can use?

我在Windows上使用C ++。

I'm using C++ on windows.

推荐答案

这在很大程度上取决于语言,平台和配置文件的范围。例如,Java世界中用于配置的属性文件,以及此处已提及的其他文件(例如YAML)。

It largely depends on the language, platform and the scope of your config files. There's for example the properties files in Java world for configuration, and others already mentioned here such as YAML.

XML通常被配置为皱眉,因为它很冗长。你仍然在许多应用程序,Web框架等中找到它。

XML is generally frowned upon for configuration, since it's very verbose. You still find it in many applications, Web frameworks, etc.

我认为最好的做法是为手头的工作选择正确的配置格式。您可以自己评估和尝试,同时考虑这些指标:

I think the best practice would be to choose the right configuration format for the job at hand. You can evaluate and try them for yourself, while considering these pointers:


  1. 什么标准? (例如Windows中的ini文件,Java中的属性文件)

  2. 是否使用我的语言提供原生支持,还是必须自行实现?

  3. 我的配置格式可以很容易地描述我要作为配置存储什么吗?

我相信你可以考虑其他注意事项。如果您更新问题以澄清范围,您会得到更有用的答案。

I'm sure you could think of other considerations. If you update your question to clarify the scope, you'll get more useful answers.

这篇关于是否有一些常见的方式来写和读配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆