Boost logo

Boost Users :

From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2008-01-28 11:46:41


On 28/01/2008, Chengyuan Ma <chengyuan_ma_at_[hidden]> wrote:
> What's the best way to load the data? I use Boost::RegEx and
> Boost::lexical_cast to do this. But It takes 2 minutes to read all the
> data. Is there a better way to do this?
>

How about a spirit parser?

I don't know spirit, but it'd be something like this:

bool
parse_numbers(istreambuf_iterator<char> s, map<unsigned, double> &m) {
    unsigned k;
    double d;
    return parse(s,
        (
            *( ( uint_p[assign_a(k)] >> ':' >> real_p[assign_a(d)
)[insert_at_a(m,k,d)] )
        ) >> end_p
        ,
        space_p).full;
}

~ Scott


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