39 template<
typename StringType,
typename Iter>
42 const StringType& delims,
44 bool strip_whitespace=
false)
46 typename StringType::size_type start_pos = 0;
47 typename StringType::size_type end_pos = 0;
48 unsigned int token_count = 0;
51 start_pos = str.find_first_not_of(delims, start_pos);
52 end_pos = str.find_first_of(delims, start_pos);
53 if (start_pos != end_pos) {
54 if (end_pos == str.npos) {
55 end_pos = str.length();
57 if (strip_whitespace) {
58 StringType stripped = str.substr(start_pos, end_pos - start_pos);
60 if (stripped.length()) {
64 *it++ = str.substr(start_pos, end_pos - start_pos);
67 start_pos = str.find_first_not_of(delims, end_pos + 1);
69 }
while (start_pos != str.npos);
71 if (start_pos != str.npos) {
72 if (strip_whitespace) {
73 StringType stripped = str.substr(start_pos, str.length() - start_pos);
75 if (stripped.length()) {
79 *it++ = str.substr(start_pos, str.length() - start_pos);
unsigned int tokenize(const StringType &str, const StringType &delims, Iter it, bool strip_whitespace=false)
void strip_whitespace_edges(std::string &str)