Boost logo

Boost Users :

Subject: [Boost-users] How to write an IP address parser with actions to fill-in a simple struct?
From: Lars Rohwedder (l.rohwedder_at_[hidden])
Date: 2010-03-25 03:54:10


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)?

Lars R.


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