bool cFileCtrl::getToken( const char*& str, string& token, char addSeps )
{
if( !addSeps )
{
while( 1 )
{
if( *str != 0 && (*str == 0X09 || *str == 0X20 ) )
{
str++;
continue;
}
if(strncmp( str, NEXT_LINE, strlen(NEXT_LINE) ) == 0)//换行
{
str += strlen(NEXT_LINE);
continue;
}
break;
}
if( *str == 0 )
return false;
char* temp =new char[128];
memset(temp,'/0',128);
char* tempptr = temp;
while( *str != 0
&& *str != 0X09 //空格
&& *str != 0X20 //tab
&& strncmp( str, NEXT_LINE, strlen(NEXT_LINE) ) != 0
)
{
*tempptr = *str;
str++;tempptr++;
}
*tempptr = 0;
token = temp;
if (temp != NULL)
{
delete temp;
temp = NULL;
}
return true;
}
else
{
if( *str == 0 )
return false;
if( *str == addSeps )
{
str++;
token = "";
return true;
}
const char* temp = str;
while(1)
{
str++;
if( *str == 0 )
{
token = string( temp, str-temp );
return true;
}
if( *str == addSeps )
{
token = string( temp, str-temp );
str++;
return true;
}
}
return false;
}
}