I'm currently trying to write a parser for an ASCII text file that is surrounded by a small envelope with checksum.
The basic structure of the file is: <0x02><"File payload"><0x03><16bit CRC>
and I want to extract the payload in another string to feed it to the next parser.
The parser expression I use to parse this envelope is:
qi::phrase_parse(
first, last,
char_('\x02') >> *print >> char_('\x02') >> *xdigit,
space
);
The input is consumed... and I already tried to dump out the payload:
qi::phrase_parse(
first, last,
char_('\x02') >> *print[cout << _1] >> char_('\x02') >> *xdigit,
space
);
But problem is that every newline, blank etc. is omitted!
Now my questions:
How do I extract the content between the 0x02/0x03 (ETX/STX) bytes correctly without omitting spaces, newlines etc.
And is my approach to first remove the envelope and then parse the payload good or is there another better approach I should use?