Boost logo

Boost :

Subject: [boost] Help with boost spirit
From: Theodore Papadopoulo (Theodore.Papadopoulo_at_[hidden])
Date: 2014-10-14 08:44:24

Hash: SHA1

Sorry, this is probably a beginner question, but I'm stuck on it for
quite some time.

        I'm trying to write a small string like parser in which the size of
the string is first given. Some thing like:

int_ >> repeat(_1)[ char_ ]

But I cannot figure out the right way of doing this.
The natural:

const bool result = boost::spirit::qi::parse(it,str.end(),int_ >>
repeat(_1)[ char_ ]);

fails to compile (and I tried many variations of val, etc) with no
success. If I replace _1 by 10, everything works fine.

Another question is that of the associated attribute. From the
documentation, I would have expected it to be:

typedef std::pair<int,std::vector<unsigned char>> Attribute;

but that does not work. I have managed to work around this using a
second rule, using an attribute std::vector<char>(int) but then again
I do not know how to pass the parameter. 10 works but _1 does not.

Any help will be appreciated. Some test code is attached, compile with:
g++ -g -std=c++11 -dboost_spirit_use_phoenix_v3 Test.C. Variants are
in comment.

    Thank's in advance for any help.

Version: GnuPG v1


Boost list run by bdawes at, gregod at, cpdaniel at, john at