如何在我的Qt应用程序中简单地解析CSS(!)文件? [英] How can I simply parse a CSS like (!) file in my Qt application?
问题描述
我有一个* .css(Cascading Style Sheets)格式的文档,但它有自己的关键字。实际上它是一个个性化的CSS(我称之为* .pss),具有自己的标签和属性。这里我有一个摘录:
I have a document in a *.css (Cascading Style Sheets) like format, but it has its own keywords. Actually it is a personalized css (I call it *.pss), with own tags and properties. here I have an excerpt:
/* CSS like style sheet file *.pss */
@include "otherStyleSheet.pss";
/* comment */
[propertyID="1230000"] {
fillColor : #f3f1ed;
minSize : 5;
lineWidth : 3;
}
/* sphere */
[propertyID="124???|123000"] {
lineType : dotted;
}
/* square */
[propertyID="125???"] {
lineType : thinline;
}
/* ring */
[propertyID="133???"] {
lineType : thickline;
[hasInnerRing=true] {
innerLineType : thinline;
}
}
我想解析很容易,已经有东西从Qt准备使用?
I would like to parse it very easily, is there already something Ready-To-Use from Qt? What would be the easiest way?
由于* .css有自己的关键字,所以我不会在CSS解析器中使用。
Since *.css has its own keywords, I am NOT interessted in CSS parsers.
我的进一步的意图,在解析后,* .pss是将其属性存储在模型结构。
My further intention after parsing that *.pss is to store its properties in a Model structure .
推荐答案
我知道两种可能性:
- boost :: spirit 和在这里你可以找到一个很好的介绍boost :: spirit解析器框架
- 我会建议写你自己的 recursive descent parser
- boost::spirit and here you can find a good introduction to the boost::spirit parser framework
- I would recommend to write your own recursive descent parser
* .pss不像CSS那样复杂(简单包围等),我推荐2。
Due to the fact, that your personalized *.pss is not that complex as a CSS (simple bracketing etc.), I would recommend 2.
这篇关于如何在我的Qt应用程序中简单地解析CSS(!)文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!