wxString wxStringTokenizer::GetNextToken() { wxString token; do { if ( !HasMoreTokens() ) { break; } m_hasMoreTokens = MoreTokens_Unknown; // find the end of this token wxString::const_iterator pos = find_first_of(m_delims, m_delimsLen, m_pos, m_stringEnd); // and the start of the next one if ( pos == m_stringEnd ) { // no more delimiters, the token is everything till the end of // string token.assign(m_pos, m_stringEnd); // skip the token m_pos = m_stringEnd; // it wasn't terminated m_lastDelim = wxT('\0'); } else // we found a delimiter at pos { // in wxTOKEN_RET_DELIMS mode we return the delimiter character // with token, otherwise leave it out wxString::const_iterator tokenEnd(pos); if ( m_mode == wxTOKEN_RET_DELIMS ) ++tokenEnd; token.assign(m_pos, tokenEnd); // skip the token and the trailing delimiter m_pos = pos + 1; m_lastDelim = (pos == m_stringEnd) ? wxT('\0') : (wxChar)*pos; } } while ( !AllowEmpty() && token.empty() ); return token; }
wxString wxStringTokenizer::GetNextToken() { wxString token; do { if ( !HasMoreTokens() ) { break; } // find the end of this token size_t pos = m_string.find_first_of(m_delims, m_pos); // and the start of the next one if ( pos == wxString::npos ) { // no more delimiters, the token is everything till the end of // string token.assign(m_string, m_pos, wxString::npos); // skip the token m_pos = m_string.length(); // it wasn't terminated m_lastDelim = _T('\0'); } else // we found a delimiter at pos { // in wxTOKEN_RET_DELIMS mode we return the delimiter character // with token, otherwise leave it out size_t len = pos - m_pos; if ( m_mode == wxTOKEN_RET_DELIMS ) len++; token.assign(m_string, m_pos, len); // skip the token and the trailing delimiter m_pos = pos + 1; m_lastDelim = m_string[pos]; } } while ( !AllowEmpty() && token.empty() ); return token; }