I kindo like this:

/// gives a vector of stringparts which have the delimiter delim
vector<string> const getVectorFromString(string const & str,
                                         string const & delim)
{
#if 0
    vector<string> vec;
    if (str.empty())
        return vec;
    string keys(rtrim(str));
    for(;;) {
        string::size_type const idx = keys.find(delim);
        if (idx == string::npos) {
            vec.push_back(ltrim(keys));
            break;
        }
        string const key = trim(keys.substr(0, idx));
        if (!key.empty())
            vec.push_back(key);
        string::size_type const start = idx + delim.size();
        keys = keys.substr(start);
    }
    return vec;
#else
    typedef boost::tokenizer<boost::char_separator<char> >
    tokenizer;
    boost::char_separator<char> sep(delim.c_str());
    tokenizer tokens(str, sep);
    return vector<string>(tokens.begin(), tokens.end());
#endif
}


objections?

-- 
        Lgb

Reply via email to