+        case wxTOKEN_INVALID:
+        case wxTOKEN_DEFAULT:
+            wxFAIL_MSG( _T("unexpected tokenizer mode") );
+            // fall through
+
+        case wxTOKEN_STRTOK:
+            // never return empty delimiters
+            break;
+    }
+
+    return false;
+}
+
+// count the number of (remaining) tokens in the string
+size_t wxStringTokenizer::CountTokens() const
+{
+    wxCHECK_MSG( IsOk(), 0, _T("you should call SetString() first") );
+
+    // VZ: this function is IMHO not very useful, so it's probably not very
+    //     important if its implementation here is not as efficient as it
+    //     could be -- but OTOH like this we're sure to get the correct answer
+    //     in all modes
+    wxStringTokenizer tkz(wxString(m_pos, m_stringEnd), m_delims, m_mode);
+
+    size_t count = 0;
+    while ( tkz.HasMoreTokens() )