# # # patch "simplestring_xform.cc" # from [8cafc035447b17c5701f51ad4056c6bee1d17c01] # to [689a23c4dc2ed9414812695bd69a7d88e6cb950f] # # patch "simplestring_xform.hh" # from [b43d9ade47e5112c9d6cbf3a9a7ecf3f3daeb433] # to [ae3cc88bb0b86f43977cfe5df9da810e3919006c] # ============================================================ --- simplestring_xform.cc 8cafc035447b17c5701f51ad4056c6bee1d17c01 +++ simplestring_xform.cc 689a23c4dc2ed9414812695bd69a7d88e6cb950f @@ -106,28 +106,6 @@ split_into_lines(string const & in, split_into_lines(in, constants::default_encoding, out); } -std::vector< utf8 > split_into_words(utf8 const & in) -{ - string const & instr = in(); - vector< utf8 > out; - - string::size_type begin = 0; - string::size_type end = instr.find_first_of(" ", begin); - - while (end != string::npos && end >= begin) - { - out.push_back(utf8(instr.substr(begin, end-begin))); - begin = end + 1; - if (begin >= instr.size()) - break; - end = instr.find_first_of(" ", begin); - } - if (begin < instr.size()) - out.push_back(utf8(instr.substr(begin, instr.size() - begin))); - - return out; -} - void join_lines(vector const & in, string & out, ============================================================ --- simplestring_xform.hh b43d9ade47e5112c9d6cbf3a9a7ecf3f3daeb433 +++ simplestring_xform.hh ae3cc88bb0b86f43977cfe5df9da810e3919006c @@ -23,8 +23,29 @@ void join_lines(std::vector void join_lines(std::vector const & in, std::string & out); -std::vector< utf8 > split_into_words(utf8 const & in); +template< class T > +std::vector< T > split_into_words(T const & in) +{ + std::string const & instr = in(); + std::vector< T > out; + std::string::size_type begin = 0; + std::string::size_type end = instr.find_first_of(" ", begin); + + while (end != std::string::npos && end >= begin) + { + out.push_back(T(instr.substr(begin, end-begin))); + begin = end + 1; + if (begin >= instr.size()) + break; + end = instr.find_first_of(" ", begin); + } + if (begin < instr.size()) + out.push_back(T(instr.substr(begin, instr.size() - begin))); + + return out; +} + template< template< typename > class T1, class T2 > T2 join_words(T1< T2 > const & in, std::string const & sep = " ") {