[Boost-users] How to skip leading characters

1 view
Skip to first unread message

Al Gambardella

unread,
Nov 23, 2009, 4:50:22 PM11/23/09
to boost...@lists.boost.org

I have an input text file that I read line by line into a standard string.

 

Each line has the following format:

Name1  00 12 3a 4c ff …

Name2  33 55 5c dd ee …

 

How do create the grammer to skip the leading NameX on each line and put the hex digits into a vector?

 

If the lines had a more complex format such that anything could appear before NameX for example:

 

Bla bla bla : 0a .bb cc  NameX 01 22 aa dd 33 44 50 00 …

 

How could I once again get the hex digits after the name into a vector?

OvermindDL1

unread,
Nov 23, 2009, 10:43:59 PM11/23/09
to boost...@lists.boost.org

This is all easy and fast to do using Spirit2.1 (Boost.Spirit). Look
at it, if you need help with it, ask on the boost-spirit mailing list.

This is not it, but with Spirit2.1, perhaps something like:
omit[(char_-("Name">>int_)) >> "Name" >> int_ >> blank] >> +(blank >> hex_)
Which would fill up a vector, and you can specialize the int_parser of
hex for a specific type as well, like char, then you could fill up a
string. Ask on the Spirit mailing list for more info.
_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Al Gambardella

unread,
Nov 23, 2009, 9:04:07 PM11/23/09
to boost...@lists.boost.org
I'm sorry, I should have mentioned that I am using the Boost Spirit library and I am asking for help with the grammer for the parser.

OvermindDL1

unread,
Nov 24, 2009, 12:32:48 AM11/24/09
to boost...@lists.boost.org
On Mon, Nov 23, 2009 at 7:04 PM, Al Gambardella <agam....@gmail.com> wrote:
> I'm sorry, I should have mentioned that I am using the Boost Spirit library
> and I am asking for help with the grammer for the parser.

Yeah, I noticed a few minutes ago that you posted to the Spirit list
as well, for all Spirit related help, that is the best place. :)

Reply all
Reply to author
Forward
0 new messages