ENH: Abstract parsing of arguments so that I can use it in other places

This commit is contained in:
Andy Cedilnik 2003-08-07 19:00:53 -04:00
parent 9a0ca088a1
commit 028f5aa2c7
2 changed files with 32 additions and 20 deletions

View File

@ -293,20 +293,9 @@ bool cmSystemTools::IsOff(const char* val)
v == "N" || cmSystemTools::IsNOTFOUND(v.c_str()) || v == "IGNORE");
}
bool cmSystemTools::RunSingleCommand(
const char* command,
std::string* output,
int *retVal,
const char* dir,
bool verbose,
int timeout)
std::vector<cmStdString> cmSystemTools::ParseArguments(const char* command)
{
if(s_DisableRunCommandOutput)
{
verbose = false;
}
std::vector<std::string> args;
std::vector<cmStdString> args;
std::string arg;
bool win_path = false;
@ -365,19 +354,37 @@ bool cmSystemTools::RunSingleCommand(
}
}
return args;
}
bool cmSystemTools::RunSingleCommand(
const char* command,
std::string* output,
int *retVal,
const char* dir,
bool verbose,
int timeout)
{
if(s_DisableRunCommandOutput)
{
verbose = false;
}
std::vector<cmStdString> args = cmSystemTools::ParseArguments(command);
if(args.size() < 1)
{
return false;
}
std::vector<const char*> argv;
for(std::vector<std::string>::const_iterator a = args.begin();
for(std::vector<cmStdString>::const_iterator a = args.begin();
a != args.end(); ++a)
{
argv.push_back(a->c_str());
}
argv.push_back(0);
if(argv.size() < 2)
{
return false;
}
if ( output )
{
*output = "";

View File

@ -179,6 +179,11 @@ public:
*/
static bool RunSingleCommand(const char* command, std::string* output = 0,
int* retVal = 0, const char* dir = 0, bool verbose = true, int timeout = 0);
/**
* Parse arguments out of a single string command
*/
static std::vector<cmStdString> ParseArguments(const char* command);
static void EnableMessages() { s_DisableMessages = false; }
static void DisableMessages() { s_DisableMessages = true; }