I can't judge whether "the rest" (i.e. the non-binary data) justifies going for a PEG parser generator.
However, just to give you something to start with:
Use
qi::bin_float
,qi::little_bin_float
orqi::big_bin_float
qi::bin_double
,qi::little_bin_double
orqi::big_bin_double
Here's a 17-line sample program that exactly duplicates the behaviour of
od -w8 -A none -t f8 -v input.dat
on my box:
#include <boost/spirit/include/qi.hpp>
#include <fstream>
#include <iomanip>
namespace qi = boost::spirit::qi;
int main() {
using namespace std;
// read file
ifstream ifs("input.dat", ios::binary);
string const input { istreambuf_iterator<char>(ifs), {} };
// parse
vector<double> result;
bool ret = qi::parse(begin(input), end(input), *qi::bin_double, result);
// print
if (ret) for (auto v : result)
cout << setw(28) << setprecision(16) << right << v << "\n";
}
See it Live on Coliru
Commands used:
clang++ -Os -std=c++11 -Wall -pedantic main.cpp # compile
dd if=/dev/urandom count=32 bs=1 2>/dev/null > input.dat # generate input
./a.out # spirit demo
echo 'And `od` output:'
od -w8 -A none -t f8 -v /tmp/input.dat # compare to `od`
Disclaimer This just intended in case it helps you see how Spirit handles binary input.