Boost logo

Boost Users :

Subject: [Boost-users] [boost-spirit qi] internal copies
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2010-10-07 09:14:41


Hello *,

I think this is more the question to spirit devlopers. I would like to know
how spirit internally maintains the parsed data? Here is an example of what
I mean.
I have to parse some byte sequence represented as hex pairs:

00 ce ab 00 de ad be ef ...

If I use the parser like this:

boost::spirit::qi::uint_parser<unsigned char, 16, 2,2> hex_byte;

std::string str("...");
std::vector<byte_t> vec;

iter_type curr=str.begin(), end=str.end();

bool r=phrase_parse(curr, end, +hex_byte, space, vec);

Is vec going to be copied somewhere inside of qi? Or are the bytes directly
appended to the vec? I would like to reserver some space for the maximum
possible input and avoid additional internal copies inside of qi...

How does the behaviour changes std::vector<byte_t> is part of the
fusion::map like

fusion::map
< fusion::pair<tag1, string>
, fusion::pair<tag2, string>
...
, fusion::pair<tagN, std::vector<byte_t> >
> data_item;

Are the fields of the map used directly while parsing, or are there some
temporaries, which will be first created (somewhere inside qi core) and
filled with data and afterwards assigned to the corresponding map field?

Many thanks for the gread lib!

Ovanes



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