Boost logo

Boost Users :

Subject: [Boost-users] [spirit] qi pheonix struct adaptation
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2013-09-06 17:05:50


Hello,

Need a little guidance when it comes to adapting structs.

Let's say I've got a simple struct:

struct data_t {
  int a;
  int b;
  int c;
};

When I adapt it, I need to specify the fields into which the values
are being consumed and subsequently synthesized?

What happens for optional consumers, in one use-case?

In another use-case, what happens if one value or another value or a
third value can be consumed for that field?

So, something like this, pardoning the pseudo-code:

using qi::int_;
using qi::lit;
qi::rule<Iterator, data_t()> rule_;
//a is optional, followed by b is mandatory, followed by c can be 1 | 2 | 3
rule_ %= -( int_ ) >> lit(',') >> int_ >> lit('.') >> ( int_(1) |
int_(2) | int_(3) );

This is applying into a GPS NMEA parser domain, so along these lines
for things like geo-spacial-coordinates, latitude/longitude, time,
etc.

Thank you...

Regards,

Michael Powell


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