26 template <
class ContainerT>
27 void tokenize(
const std::string& str, ContainerT& tokens,
const std::string& delimiters=
" ",
bool trimEmpty=
false)
29 std::string::size_type pos;
30 std::string::size_type lastPos= 0;
34 pos= str.find_first_of(delimiters, lastPos);
35 if (pos == std::string::npos)
39 if (pos != lastPos || not trimEmpty)
40 tokens.push_back(
typename ContainerT::value_type(str.data()+lastPos,
41 static_cast<typename ContainerT::value_type::size_type
>(pos)-lastPos));
47 if (pos != lastPos || not trimEmpty)
48 tokens.push_back(
typename ContainerT::value_type(str.data()+lastPos,
49 static_cast<typename ContainerT::value_type::size_type
>(pos)-lastPos));