Boost logo

Boost Users :

From: Lane (software.research.development_at_[hidden])
Date: 2020-12-15 21:24:22


I am using boost::spirit:x3, shown below. I use it to import/parse
some very large files and am trying to find a way to get some sort of
progress from it so that I can use for a progress bar in app, but so
far I've been unable to see a way.

    namespace parser {
        namespace x3 = boost::spirit::x3;
        using namespace x3;

        auto const string = lexeme[+graph];
        auto const point = rule<struct _p, ast::point> {"point"} =
            int_ >> double_ >> double_ >> double_;
        auto const element = rule<struct _e, ast::element> {"element"} =
            int_ >> string >> int_ >> int_ >> int_ >> eol >>
            *(int_ >> int_ >> int_);

        auto lines = [](auto p) { return *(p >> eol); };

        auto const input =
            lines(point) >>
            lines(element);
    }

And I import a file like so.

{
    namespace x3 = boost::spirit::x3;

    mapped_file_source map(filePath);
    std::istringstream iss(map.data());
    map.close();

    boost::spirit::istream_iterator iter(iss >> std::noskipws), eof;

    bool ok = phrase_parse(iter, eof, smf::parser::input, x3::blank, types);

    if (iter != eof) {
        // ...
    }
}

Would anyone have thoughts on how to get some sort of indicator during
the parsing?


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