跨平台的方式来获得,其中给定的选项被发现INI文件的行号 [英] Cross-platform way to get line number of an INI file where given option was found

查看:249
本文介绍了跨平台的方式来获得,其中给定的选项被发现INI文件的行号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找一些C ++库(如升压:: program_options),它能够返回一个INI文件,其中给定的选项或部分被发现的行号。

Looking for some C++ library (like boost::program_options) that is able to return line number of an INI file, where the given option or section was found.

使用情况:


  1. 我问这个图书馆找到一节值VVV[SSS]。图书馆返回行号VVV一节[SSS]被发现,或-1。它给我说55行:VVV必须< 256的能力。

  1. I ask that library to find value "vvv" in a section "[SSS]". Library returns line number where "vvv" in section "[SSS]" is found, or -1. It gives me an ability to say "line 55: vvv must be < 256".

我对重复部分INI文件并验证他们的名字。当一些野生secsion被发现,我告诉:行55:节[哈哈哈]是未知的。

I iterate INI file for sections and validate their names. When some wild secsion is found, i tell: "line 55: section [Hahaha] is unknown".

更新:我知道INI比猛犸前辈,但目前我有到港大窗户工程跨平台,并且不能得到尽快摆脱.ini文件

update: i know about "INI is older than mammoth", but currently i have to port large windows project to cross-platform and cannot get rid of .ini files soon.

推荐答案

再一次,趁机用升压精神的发挥。这一次,我玩<一个href=\"http://www.boost.org/doc/libs/1_48_0/libs/spirit/doc/html/spirit/support/line_pos_iterator.html\"><$c$c>line_pos_iterator.

Once again, took the opportunity to play with Boost Spirit. This time I got to play with line_pos_iterator.

下面是我的劳动成果: https://gist.github.com/1425972

Here is the fruit of my labour: https://gist.github.com/1425972

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