|
Boost Users : |
Subject: Re: [Boost-users] How to write an IP address parser with actions to fill-in a simple struct?
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2010-03-28 22:42:23
On Wed, Mar 24, 2010 at 9:07 AM, Lars Rohwedder <L.Rohwedder_at_[hidden]> wrote:
> I have a rule like this:
>
> rule<> IP_Parser =
> Â int_p>>'.'>>int_p >>'.'>>int_p >>'.'>>int_p >>
> Â !( ('/'>>int_p)|(':'>>int_p));
>
> Now I want to extend it that the user can use that parser to fill a
> simple struct:
>
> struct IP_address {
> Â std::string host;
> Â int port;
> Â int netmask;
> };
>
> and use it this way:
>
> IP_address src;
> rule<> Source = str_p("source") >> +space_p >> IP_Parser(src) >>
> Â *space_p >> ';';
>
> Any ideas how to do that with the old boost::spirit
> (boost version 1.35)?
With the old version you will have to parse things out and convert
them individually in the usual nasty way. Why can you not just bcp
the new version into your project? It would *VASTLY* simplify the
code, and run faster.
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