提升精神:如何序列化qi :: grammar和qi :: rule对象?

时间:2014-08-23 13:13:29

标签: c++ serialization boost-spirit-qi

我正在使用Boost库1.55版。

第1个问题

我有以下对象myRule

#include <boost/spirit/include/qi.hpp>
namespace qi = boost::spirit::qi;

typedef qi::rule<std::string::iterator, qi::blank_type>     Rule;

Rule myRule %= qi::string("Hello world");

如何将其序列化为字符串对象?

第二个问题

我有以下对象myGrammar

#include <boost/spirit/include/qi.hpp>
namespace qi = boost::spirit::qi;

typedef qi::rule<std::string::iterator, qi::blank_type>     Rule;
typedef qi::grammar<std::string::iterator, qi::blank_type>  Grammar;    

class MyGrammar : Grammar
{
     // Constructor/Destructor
     MyGrammar()::base_type(myRule)
     {
         myRule %= qi::string("Hello world");
     }
     ~MyGrammar() { }

     // Attributes
     Rule myRule;
};

MyGrammar myGrammar;

如何将其序列化为字符串对象?

0 个答案:

没有答案