开发者

Is there any standard way to load parameters from a file in C++ on Linux?

Imaging that a program needs to know quite a lot of parameters to do its tasks properly, such as 'Port = 2323' this kind of things.

now I want to save these parameters in a plain text file, similar to Unix' system variables such as users and groups.

Is there any standard way/lib开发者_运维知识库raries that can help me to do this? Does anyone ever used them before? thanks


Boost.Program_options library. Is this you are looking for?

The program_options library allows program developers to obtain program options, that is (name, value) pairs from the user, via conventional methods such as command line and config file.


Qt offers this by default, and in a cross-platform way. Checkout out QSettings


You can also create an alias or shell script that executes your program with given parameters. To conviniently get these parameters there's "getopt"


Link here for a cross platform ini handler.

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜