boost-spirit-karma

How to access data of nested objects in boost::spirit::karma?

回眸只為那壹抹淺笑 提交于 2019-12-11 03:45:30
问题 In an ItemList containing lists of Item objects, how do I access the Item objects in the generator? The following sample code compiles on VC9 (with boost include and link directories set apropriately). I don't know how to set up list_generator::item . #include <boost/config/warning_disable.hpp> #include <boost/foreach.hpp> #include <boost/assign/list_of.hpp> #include <boost/range/adaptors.hpp> #include <boost/range/algorithm.hpp> #include <boost/spirit/include/qi.hpp> #include <boost/spirit

Boost karma: how does this implicit call to transform_attribute work? (or doesn't?)

那年仲夏 提交于 2019-12-10 10:25:14
问题 I have the following piece of code that seems to work fine (I based the semantic actions on reuse parsed variable with boost karma). #include <iostream> #include <iterator> #include <memory> #include <string> #include <vector> #include <boost/fusion/include/adapt_struct.hpp> #include <boost/fusion/include/sequence.hpp> #include <boost/spirit/include/karma.hpp> #include <boost/spirit/include/phoenix_core.hpp> #include <boost/spirit/include/phoenix_operator.hpp> #include <boost/spirit/include

Generate string if boolean attribute is true (karma counterpart to qi::matches)

好久不见. 提交于 2019-12-05 19:32:36
Imagine we want to parse and generate simple C++ member function declarations with Boost.Spirit. The Qi grammar might look like this: function_ %= type_ > id_ > "()" > matches["const"]; That means, whether the function is const is stored in a bool . How to write the corresponding generator with Karma? function_ %= type_ << ' ' << id_ << "()" << XXX[" const"]; Here, we want a directive that consumes a boolean attribute, executes the embedded generator if the attribute is true and does nothing otherwise. We want something that makes the following tests succeed. test_generator_attr("abc", XXX[

boost::spirit::karma output of string in quotation marks

落花浮王杯 提交于 2019-12-02 02:21:42
问题 I am trying to escape a string in quotation marks using boost::spirit::karma. This works fine if it's just a string. However, for a string in a boost::variant in a std::vector, it does not. Just printing the string does work however, I do not quite understand why. Line (1) works fine, but doesn't do what I want. Line (2) should do it, but doesn't. #include <iostream> #include <string> #include <boost/variant.hpp> #include <boost/spirit/include/karma.hpp> namespace karma = boost::spirit::karma

boost::spirit::karma output of string in quotation marks

此生再无相见时 提交于 2019-12-02 02:18:45
I am trying to escape a string in quotation marks using boost::spirit::karma. This works fine if it's just a string. However, for a string in a boost::variant in a std::vector, it does not. Just printing the string does work however, I do not quite understand why. Line (1) works fine, but doesn't do what I want. Line (2) should do it, but doesn't. #include <iostream> #include <string> #include <boost/variant.hpp> #include <boost/spirit/include/karma.hpp> namespace karma = boost::spirit::karma; typedef std::vector<boost::variant<int, std::string>> ParameterList; typedef boost::variant<int, std:

Inconsistent Generator directive column behavior in boost karma

不打扰是莪最后的温柔 提交于 2019-12-02 01:56:10
I am writing a karma generator to generate a HTML page and I am experiencing inconsistent behavior while using column directive. It could very well be my understanding of how it works. Basically I am generating a grid which requires me to insert some delimiters after every 2 occurrences of the data. The below is a basic program I adopted to do a test run. #include <boost/config/warning_disable.hpp> #include <boost/spirit/include/karma.hpp> #include <boost/fusion/include/struct.hpp> #include <boost/fusion/include/nview.hpp> #include <boost/assign/std/vector.hpp> namespace fusion = boost::fusion

Is it possible to reuse a Spirit Qi grammar as a Spirit Karma grammar?

∥☆過路亽.° 提交于 2019-12-01 10:36:30
I have a Qi grammar definition that I use to parse an input. Later I have a Karma generator to output in a way that should be similar to the input. Is this possible at all? It seem that a parser grammar can be transformed into a generator grammar automatically (??). #include <boost/config/warning_disable.hpp> #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/karma.hpp> #include <iostream> int main(){ //test input std::string s = "Xx 1.233 pseudo"; //input variables std::string element; double mass; std::string pseudo; auto GRAMMAR = boost::spirit::qi::lexeme[+(boost::spirit

Is it possible to reuse a Spirit Qi grammar as a Spirit Karma grammar?

做~自己de王妃 提交于 2019-12-01 07:48:49
问题 I have a Qi grammar definition that I use to parse an input. Later I have a Karma generator to output in a way that should be similar to the input. Is this possible at all? It seem that a parser grammar can be transformed into a generator grammar automatically (??). #include <boost/config/warning_disable.hpp> #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/karma.hpp> #include <iostream> int main(){ //test input std::string s = "Xx 1.233 pseudo"; //input variables std: