Boost logo

Boost Users :

Subject: Re: [Boost-users] tokenize string delimiter
From: Brian O'Kennedy (brokenn_at_[hidden])
Date: 2010-02-12 03:57:53


The first argument to qi::parse is a non-const reference (which fails on the
temporary you're passing in).
Try:

  std::string::iterator ii = str.begin();
  boost::spirit::qi::parse(ii, str.end(),
           raw[+~string(delim)] % lit(delim), result);

Spirit uses the first parameter to return how far it got in the parsing of
your string.

hth,
 Brian

On 12 February 2010 05:53, Matthias Vallentin
<vallentin_at_[hidden]>wrote:

> On Thu, Feb 11, 2010 at 03:22:53PM -0700, OvermindDL1 wrote:
> > std::string result;
> > parse(str.begin(),str.end(), raw[+~char_(delim)]%lit(delim), result);
>
> This fails in the first argument of qi::parse:
>
> using boost::spirit::qi::lit;
> using boost::spirit::qi::raw;
> using boost::spirit::qi::string;
>
> std::string str("foo---bar---baz");
> std::string delim("---");
> std::string result;
> boost::spirit::qi::parse(str.begin(), str.end(),
> raw[+~string(delim)] % lit(delim), result);
>
> Any ideas why?
>
> Matthias
> --
> Matthias Vallentin
> vallentin_at_[hidden]
> http://www.icir.org/matthias
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net