This repository has been archived on 2020-05-27. You can view files and clone it, but cannot push or open issues/pull-requests.
crystal-pokedex/PokeDexC++ GNU/StrToke.cpp

36 lines
626 B
C++
Executable File

#ifndef STRTOKE_CPP
#define STRTOKE_CPP
StrToke::StrToke ( string s, string d )
{
string str = s;
tokes = 0;
while ( str.find ( d ) != -1 )
{
int index = str.find ( d );
string newstr = str.substr ( 0, index );
tokens.add ( newstr );
str = str.substr ( index + 1, str.length() - index );
tokes++;
}
tokens.add ( str );
tokes++;
}
bool StrToke::hasTokens()
{
return (tokes > 0);
}
string StrToke::nextToken()
{
if ( tokes > 0 )
{
tokes--;
return tokens.get ( tokens.size() - tokes - 1 );
}
return "Out of tokens";
}
#endif /* END STRTOKE_CPP */