Opened 11 years ago

Last modified 11 years ago

#6106 new Patches

New map[] directive to augment qi::symbols when doing binary parsing

Reported by: oakad@… Owned by: Joel de Guzman
Milestone: To Be Determined Component: spirit
Version: Boost Release Branch Severity: Not Applicable
Keywords: Cc:

Description

qi::symbols is an exceptionally useful parser, but it is strongly tied to character strings as its input type. When doing binary parsing, one of the common tasks is de-serializing objects from the binary stream, an activity which can strongly benefit from Nabialek trick (http://boost-spirit.com/home/articles/qi-example/nabialek-trick/). Another common use case are extensible enum types, a feat which is somewhat cumbersome to handle with attribute transformations.

This is my first attempt at implementing a qi directive, so it's probably far from perfect. One of the immediate shortcomings I want to resolve is direct dependency on std::map which is also passed by value between instances.

The implementation and a short example demonstrating Nabialek trick is attached.

Attachments (2)

map.hpp (3.0 KB ) - added by oakad@… 11 years ago.
Implementation of the map[] directive in the repository::qi namespace
test_map1.cpp (1.3 KB ) - added by oakad@… 11 years ago.
Example showing use of map[] to implement Nabialek trick

Download all attachments as: .zip

Change History (5)

by oakad@…, 11 years ago

Attachment: map.hpp added

Implementation of the map[] directive in the repository::qi namespace

by oakad@…, 11 years ago

Attachment: test_map1.cpp added

Example showing use of map[] to implement Nabialek trick

comment:1 by Joel de Guzman, 11 years ago

That's very interesting!

We deal with feature submissions like this through the Spirit mailing list. I suggest you post a message there.

in reply to:  1 comment:2 by oakad@…, 11 years ago

Replying to djowel:

We deal with feature submissions like this through the Spirit mailing list. I suggest you post a message there.

Of course I posted a message there, with a link here. But I suppose, ticket is a good place to keep everything related together. Or isn't it?

comment:3 by Joel de Guzman, 11 years ago

Yes, this is good.

Note: See TracTickets for help on using tickets.