You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

36 lines
901 B

#include "header.h"
void StringTool::String2CmdArg(string s, string & cmd, string & arg)
{
string message = stripWhiteSpace(s);
if (message.find_first_of(STRING_WHITESPACES, 1) != string::npos)
{
cmd = stripWhiteSpace(message.substr(0, message.find_first_of(STRING_WHITESPACES, 1)));
arg = stripWhiteSpace(message.substr(message.find_first_of(STRING_WHITESPACES, 1)));
} else
{
cmd = message;
arg = "";
}
return;
}
string StringTool::stripWhiteSpace(string s)
{
unsigned int i, j;
if (s.length() > 0)
{
i = s.find_first_not_of(STRING_WHITESPACES);
j = s.find_last_not_of(STRING_WHITESPACES);
if (i == string::npos)
i = 0;
if (j == string::npos)
j = s.length()-1;
return string(s, i, j-i+1);
}
return string("");
}