2004-09-13 20:15:02 +00:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
Program: KWSys - Kitware System Library
|
|
|
|
Module: $RCSfile$
|
|
|
|
|
|
|
|
Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
#include "kwsysPrivate.h"
|
|
|
|
#include KWSYS_HEADER(CommandLineArguments.hxx)
|
|
|
|
|
|
|
|
#include KWSYS_HEADER(Configure.hxx)
|
2006-07-14 13:13:23 +00:00
|
|
|
#include KWSYS_HEADER(String.hxx)
|
2004-09-13 20:15:02 +00:00
|
|
|
|
|
|
|
#include KWSYS_HEADER(stl/vector)
|
|
|
|
#include KWSYS_HEADER(stl/map)
|
|
|
|
#include KWSYS_HEADER(stl/set)
|
|
|
|
#include KWSYS_HEADER(ios/sstream)
|
2004-09-13 23:06:19 +00:00
|
|
|
#include KWSYS_HEADER(ios/iostream)
|
2004-09-13 20:15:02 +00:00
|
|
|
|
2005-04-13 20:46:09 +00:00
|
|
|
// Work-around CMake dependency scanning limitation. This must
|
|
|
|
// duplicate the above list of headers.
|
|
|
|
#if 0
|
|
|
|
# include "CommandLineArguments.hxx.in"
|
|
|
|
# include "Configure.hxx.in"
|
|
|
|
# include "kwsys_stl.hxx.in"
|
|
|
|
# include "kwsys_ios_sstream.h.in"
|
|
|
|
# include "kwsys_ios_iostream.h.in"
|
|
|
|
#endif
|
|
|
|
|
2004-09-13 20:15:02 +00:00
|
|
|
#include <stdio.h>
|
2004-09-14 15:39:04 +00:00
|
|
|
#include <stdlib.h>
|
2005-03-11 15:07:36 +00:00
|
|
|
#include <string.h>
|
2004-09-13 20:15:02 +00:00
|
|
|
|
2004-09-15 13:22:34 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
# pragma warning (disable: 4786)
|
|
|
|
#endif
|
|
|
|
|
2005-05-03 18:58:13 +00:00
|
|
|
#if defined(__sgi) && !defined(__GNUC__)
|
|
|
|
# pragma set woff 1375 /* base class destructor not virtual */
|
|
|
|
#endif
|
|
|
|
|
2006-07-14 13:13:23 +00:00
|
|
|
#if 0
|
|
|
|
# define CommandLineArguments_DEBUG(x) \
|
|
|
|
kwsys_ios::cout << __LINE__ << " CLA: " << x << kwsys_ios::endl
|
|
|
|
#else
|
|
|
|
# define CommandLineArguments_DEBUG(x)
|
|
|
|
#endif
|
|
|
|
|
2004-09-13 20:15:02 +00:00
|
|
|
namespace KWSYS_NAMESPACE
|
|
|
|
{
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//============================================================================
|
2004-09-15 13:22:34 +00:00
|
|
|
struct CommandLineArgumentsCallbackStructure
|
|
|
|
{
|
|
|
|
const char* Argument;
|
|
|
|
int ArgumentType;
|
|
|
|
CommandLineArguments::CallbackType Callback;
|
|
|
|
void* CallData;
|
|
|
|
void* Variable;
|
|
|
|
int VariableType;
|
|
|
|
const char* Help;
|
|
|
|
};
|
|
|
|
|
2004-09-13 20:15:02 +00:00
|
|
|
class CommandLineArgumentsVectorOfStrings :
|
2006-07-14 13:13:23 +00:00
|
|
|
public kwsys_stl::vector<kwsys::String> {};
|
2004-09-13 20:15:02 +00:00
|
|
|
class CommandLineArgumentsSetOfStrings :
|
2006-07-14 13:13:23 +00:00
|
|
|
public kwsys_stl::set<kwsys::String> {};
|
2004-09-13 20:15:02 +00:00
|
|
|
class CommandLineArgumentsMapOfStrucs :
|
2006-07-14 13:13:23 +00:00
|
|
|
public kwsys_stl::map<kwsys::String,
|
2004-09-15 13:22:34 +00:00
|
|
|
CommandLineArgumentsCallbackStructure> {};
|
2004-09-13 20:15:02 +00:00
|
|
|
|
|
|
|
class CommandLineArgumentsInternal
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CommandLineArgumentsInternal()
|
|
|
|
{
|
|
|
|
this->UnknownArgumentCallback = 0;
|
|
|
|
this->ClientData = 0;
|
|
|
|
this->LastArgument = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef CommandLineArgumentsVectorOfStrings VectorOfStrings;
|
|
|
|
typedef CommandLineArgumentsMapOfStrucs CallbacksMap;
|
2006-07-14 13:13:23 +00:00
|
|
|
typedef kwsys::String String;
|
2004-09-13 20:15:02 +00:00
|
|
|
typedef CommandLineArgumentsSetOfStrings SetOfStrings;
|
|
|
|
|
|
|
|
VectorOfStrings Argv;
|
2004-09-23 15:45:02 +00:00
|
|
|
String Argv0;
|
2004-09-13 20:15:02 +00:00
|
|
|
CallbacksMap Callbacks;
|
|
|
|
|
|
|
|
CommandLineArguments::ErrorCallbackType UnknownArgumentCallback;
|
|
|
|
void* ClientData;
|
|
|
|
|
|
|
|
VectorOfStrings::size_type LastArgument;
|
2006-07-14 19:02:27 +00:00
|
|
|
|
|
|
|
VectorOfStrings UnusedArguments;
|
2004-09-13 20:15:02 +00:00
|
|
|
};
|
|
|
|
//============================================================================
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
CommandLineArguments::CommandLineArguments()
|
|
|
|
{
|
|
|
|
this->Internals = new CommandLineArguments::Internal;
|
|
|
|
this->Help = "";
|
|
|
|
this->LineLength = 80;
|
2006-07-14 19:02:27 +00:00
|
|
|
this->StoreUnusedArgumentsFlag = false;
|
2004-09-13 20:15:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
CommandLineArguments::~CommandLineArguments()
|
|
|
|
{
|
|
|
|
delete this->Internals;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2004-09-14 14:34:10 +00:00
|
|
|
void CommandLineArguments::Initialize(int argc, const char* const argv[])
|
2004-09-13 20:15:02 +00:00
|
|
|
{
|
|
|
|
int cc;
|
|
|
|
|
|
|
|
this->Initialize();
|
2004-09-23 15:45:02 +00:00
|
|
|
this->Internals->Argv0 = argv[0];
|
2004-09-13 20:15:02 +00:00
|
|
|
for ( cc = 1; cc < argc; cc ++ )
|
|
|
|
{
|
|
|
|
this->ProcessArgument(argv[cc]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-14 15:48:34 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::Initialize(int argc, char* argv[])
|
|
|
|
{
|
2004-09-23 15:45:02 +00:00
|
|
|
this->Initialize(argc, static_cast<const char* const*>(argv));
|
2004-09-14 15:48:34 +00:00
|
|
|
}
|
|
|
|
|
2004-09-13 20:15:02 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::Initialize()
|
|
|
|
{
|
|
|
|
this->Internals->Argv.clear();
|
|
|
|
this->Internals->LastArgument = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::ProcessArgument(const char* arg)
|
|
|
|
{
|
|
|
|
this->Internals->Argv.push_back(arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2006-07-14 13:13:23 +00:00
|
|
|
bool CommandLineArguments::GetMatchedArguments(
|
|
|
|
kwsys_stl::vector<kwsys_stl::string>* matches,
|
|
|
|
const kwsys_stl::string& arg)
|
2004-09-13 20:15:02 +00:00
|
|
|
{
|
2006-07-14 13:13:23 +00:00
|
|
|
matches->clear();
|
|
|
|
CommandLineArguments::Internal::CallbacksMap::iterator it;
|
|
|
|
|
|
|
|
// Does the argument match to any we know about?
|
|
|
|
for ( it = this->Internals->Callbacks.begin();
|
|
|
|
it != this->Internals->Callbacks.end();
|
|
|
|
it ++ )
|
2004-09-13 20:15:02 +00:00
|
|
|
{
|
2006-07-14 13:13:23 +00:00
|
|
|
const CommandLineArguments::Internal::String& parg = it->first;
|
|
|
|
CommandLineArgumentsCallbackStructure *cs = &it->second;
|
|
|
|
if (cs->ArgumentType == CommandLineArguments::NO_ARGUMENT ||
|
|
|
|
cs->ArgumentType == CommandLineArguments::SPACE_ARGUMENT)
|
2004-09-13 20:15:02 +00:00
|
|
|
{
|
2006-07-14 13:13:23 +00:00
|
|
|
if ( arg == parg )
|
2004-09-13 20:15:02 +00:00
|
|
|
{
|
2006-07-14 13:13:23 +00:00
|
|
|
matches->push_back(parg);
|
2004-09-13 20:15:02 +00:00
|
|
|
}
|
|
|
|
}
|
2006-07-14 13:13:23 +00:00
|
|
|
else if ( arg.find( parg ) == 0 )
|
|
|
|
{
|
|
|
|
matches->push_back(parg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return matches->size() > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
int CommandLineArguments::Parse()
|
|
|
|
{
|
|
|
|
kwsys_stl::vector<kwsys_stl::string>::size_type cc;
|
|
|
|
kwsys_stl::vector<kwsys_stl::string> matches;
|
2006-07-14 19:02:27 +00:00
|
|
|
if ( this->StoreUnusedArgumentsFlag )
|
|
|
|
{
|
|
|
|
this->Internals->UnusedArguments.clear();
|
|
|
|
}
|
2006-07-14 13:13:23 +00:00
|
|
|
for ( cc = 0; cc < this->Internals->Argv.size(); cc ++ )
|
|
|
|
{
|
|
|
|
const kwsys_stl::string& arg = this->Internals->Argv[cc];
|
|
|
|
CommandLineArguments_DEBUG("Process argument: " << arg);
|
|
|
|
this->Internals->LastArgument = cc;
|
|
|
|
if ( this->GetMatchedArguments(&matches, arg) )
|
2004-09-13 20:15:02 +00:00
|
|
|
{
|
|
|
|
// Ok, we found one or more arguments that match what user specified.
|
|
|
|
// Let's find the longest one.
|
|
|
|
CommandLineArguments::Internal::VectorOfStrings::size_type kk;
|
|
|
|
CommandLineArguments::Internal::VectorOfStrings::size_type maxidx = 0;
|
|
|
|
CommandLineArguments::Internal::String::size_type maxlen = 0;
|
|
|
|
for ( kk = 0; kk < matches.size(); kk ++ )
|
|
|
|
{
|
|
|
|
if ( matches[kk].size() > maxlen )
|
|
|
|
{
|
|
|
|
maxlen = matches[kk].size();
|
|
|
|
maxidx = kk;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// So, the longest one is probably the right one. Now see if it has any
|
|
|
|
// additional value
|
2004-09-15 13:22:34 +00:00
|
|
|
CommandLineArgumentsCallbackStructure *cs
|
2004-09-13 20:15:02 +00:00
|
|
|
= &this->Internals->Callbacks[matches[maxidx]];
|
2006-08-01 15:38:42 +00:00
|
|
|
const kwsys_stl::string& sarg = matches[maxidx];
|
2006-07-14 13:13:23 +00:00
|
|
|
if ( cs->Argument != sarg )
|
2004-09-13 20:15:02 +00:00
|
|
|
{
|
2006-07-14 13:13:23 +00:00
|
|
|
abort();
|
2004-09-13 20:15:02 +00:00
|
|
|
}
|
2006-07-14 13:13:23 +00:00
|
|
|
switch ( cs->ArgumentType )
|
2004-09-13 20:15:02 +00:00
|
|
|
{
|
2006-07-14 13:13:23 +00:00
|
|
|
case NO_ARGUMENT:
|
|
|
|
// No value
|
|
|
|
if ( !this->PopulateVariable(cs, 0) )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SPACE_ARGUMENT:
|
2004-09-13 20:15:02 +00:00
|
|
|
if ( cc == this->Internals->Argv.size()-1 )
|
|
|
|
{
|
2004-09-23 15:45:02 +00:00
|
|
|
this->Internals->LastArgument --;
|
2004-09-13 20:15:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2006-07-14 13:13:23 +00:00
|
|
|
CommandLineArguments_DEBUG("This is a space argument: " << arg
|
|
|
|
<< " value: " << this->Internals->Argv[cc+1].c_str());
|
2004-09-13 20:15:02 +00:00
|
|
|
// Value is the next argument
|
2006-07-14 13:13:23 +00:00
|
|
|
if ( !this->PopulateVariable(cs, this->Internals->Argv[cc+1].c_str()) )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2004-09-13 20:15:02 +00:00
|
|
|
cc ++;
|
2006-07-14 13:13:23 +00:00
|
|
|
break;
|
|
|
|
case EQUAL_ARGUMENT:
|
2004-09-13 20:15:02 +00:00
|
|
|
if ( arg.size() == sarg.size() || *(arg.c_str() + sarg.size()) != '=' )
|
|
|
|
{
|
2004-09-23 15:45:02 +00:00
|
|
|
this->Internals->LastArgument --;
|
2004-09-13 20:15:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
// Value is everythng followed the '=' sign
|
2006-07-14 13:13:23 +00:00
|
|
|
if ( !this->PopulateVariable(cs, arg.c_str() + sarg.size() + 1) )
|
2004-09-13 20:15:02 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2006-07-14 13:13:23 +00:00
|
|
|
break;
|
|
|
|
case CONCAT_ARGUMENT:
|
|
|
|
// Value is whatever follows the argument
|
|
|
|
if ( !this->PopulateVariable(cs, arg.c_str() + sarg.size()) )
|
2004-09-13 20:15:02 +00:00
|
|
|
{
|
2006-07-14 13:13:23 +00:00
|
|
|
return 0;
|
2004-09-13 20:15:02 +00:00
|
|
|
}
|
2006-07-14 13:13:23 +00:00
|
|
|
break;
|
|
|
|
case MULTI_ARGUMENT:
|
|
|
|
// Suck in all the rest of the arguments
|
|
|
|
CommandLineArguments_DEBUG("This is a multi argument: " << arg);
|
|
|
|
for (cc++; cc < this->Internals->Argv.size(); ++ cc )
|
2004-09-13 20:15:02 +00:00
|
|
|
{
|
2006-07-14 13:13:23 +00:00
|
|
|
const kwsys_stl::string& marg = this->Internals->Argv[cc];
|
|
|
|
CommandLineArguments_DEBUG(" check multi argument value: " << marg);
|
|
|
|
if ( this->GetMatchedArguments(&matches, marg) )
|
2004-09-13 20:15:02 +00:00
|
|
|
{
|
2006-07-14 13:13:23 +00:00
|
|
|
CommandLineArguments_DEBUG("End of multi argument " << arg << " with value: " << marg);
|
|
|
|
break;
|
2004-09-13 20:15:02 +00:00
|
|
|
}
|
2006-07-14 13:13:23 +00:00
|
|
|
CommandLineArguments_DEBUG(" populate multi argument value: " << marg);
|
|
|
|
if ( !this->PopulateVariable(cs, marg.c_str()) )
|
2004-09-13 20:15:02 +00:00
|
|
|
{
|
2006-07-14 13:13:23 +00:00
|
|
|
return 0;
|
2004-09-13 20:15:02 +00:00
|
|
|
}
|
|
|
|
}
|
2006-07-14 13:13:23 +00:00
|
|
|
if ( cc != this->Internals->Argv.size() )
|
2004-09-13 20:15:02 +00:00
|
|
|
{
|
2006-07-14 13:13:23 +00:00
|
|
|
CommandLineArguments_DEBUG("Again End of multi argument " << arg);
|
|
|
|
cc--;
|
|
|
|
continue;
|
2004-09-13 20:15:02 +00:00
|
|
|
}
|
2006-07-14 19:02:27 +00:00
|
|
|
break;
|
2006-07-14 13:13:23 +00:00
|
|
|
default:
|
|
|
|
kwsys_ios::cerr << "Got unknown argument type: \"" << cs->ArgumentType << "\"" << kwsys_ios::endl;
|
|
|
|
this->Internals->LastArgument --;
|
|
|
|
return 0;
|
2004-09-13 20:15:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Handle unknown arguments
|
|
|
|
if ( this->Internals->UnknownArgumentCallback )
|
|
|
|
{
|
|
|
|
if ( !this->Internals->UnknownArgumentCallback(arg.c_str(),
|
|
|
|
this->Internals->ClientData) )
|
|
|
|
{
|
2004-09-23 15:45:02 +00:00
|
|
|
this->Internals->LastArgument --;
|
2004-09-13 20:15:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2006-12-21 15:24:33 +00:00
|
|
|
return 1;
|
2004-09-13 20:15:02 +00:00
|
|
|
}
|
2006-07-14 19:02:27 +00:00
|
|
|
else if ( this->StoreUnusedArgumentsFlag )
|
|
|
|
{
|
|
|
|
CommandLineArguments_DEBUG("Store unused argument " << arg);
|
|
|
|
this->Internals->UnusedArguments.push_back(arg.c_str());
|
|
|
|
}
|
2004-09-13 20:15:02 +00:00
|
|
|
else
|
|
|
|
{
|
2004-09-13 22:57:28 +00:00
|
|
|
kwsys_ios::cerr << "Got unknown argument: \"" << arg.c_str() << "\"" << kwsys_ios::endl;
|
2004-09-23 15:45:02 +00:00
|
|
|
this->Internals->LastArgument --;
|
2004-09-13 20:15:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::GetRemainingArguments(int* argc, char*** argv)
|
|
|
|
{
|
|
|
|
CommandLineArguments::Internal::VectorOfStrings::size_type size
|
2004-09-23 19:02:22 +00:00
|
|
|
= this->Internals->Argv.size() - this->Internals->LastArgument + 1;
|
2004-09-13 20:15:02 +00:00
|
|
|
CommandLineArguments::Internal::VectorOfStrings::size_type cc;
|
|
|
|
|
2004-09-23 15:45:02 +00:00
|
|
|
// Copy Argv0 as the first argument
|
2004-09-13 20:15:02 +00:00
|
|
|
char** args = new char*[ size ];
|
2004-09-23 15:45:02 +00:00
|
|
|
args[0] = new char[ this->Internals->Argv0.size() + 1 ];
|
|
|
|
strcpy(args[0], this->Internals->Argv0.c_str());
|
2004-09-13 20:15:02 +00:00
|
|
|
int cnt = 1;
|
2004-09-23 15:45:02 +00:00
|
|
|
|
|
|
|
// Copy everything after the LastArgument, since that was not parsed.
|
|
|
|
for ( cc = this->Internals->LastArgument+1;
|
2004-09-13 20:15:02 +00:00
|
|
|
cc < this->Internals->Argv.size(); cc ++ )
|
|
|
|
{
|
|
|
|
args[cnt] = new char[ this->Internals->Argv[cc].size() + 1];
|
|
|
|
strcpy(args[cnt], this->Internals->Argv[cc].c_str());
|
|
|
|
cnt ++;
|
|
|
|
}
|
|
|
|
*argc = cnt;
|
|
|
|
*argv = args;
|
|
|
|
}
|
|
|
|
|
2006-07-14 19:02:27 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::GetUnusedArguments(int* argc, char*** argv)
|
|
|
|
{
|
|
|
|
CommandLineArguments::Internal::VectorOfStrings::size_type size
|
|
|
|
= this->Internals->UnusedArguments.size() + 1;
|
|
|
|
CommandLineArguments::Internal::VectorOfStrings::size_type cc;
|
|
|
|
|
|
|
|
// Copy Argv0 as the first argument
|
|
|
|
char** args = new char*[ size ];
|
|
|
|
args[0] = new char[ this->Internals->Argv0.size() + 1 ];
|
|
|
|
strcpy(args[0], this->Internals->Argv0.c_str());
|
|
|
|
int cnt = 1;
|
|
|
|
|
|
|
|
// Copy everything after the LastArgument, since that was not parsed.
|
|
|
|
for ( cc = 0;
|
|
|
|
cc < this->Internals->UnusedArguments.size(); cc ++ )
|
|
|
|
{
|
|
|
|
kwsys::String &str = this->Internals->UnusedArguments[cc];
|
|
|
|
args[cnt] = new char[ str.size() + 1];
|
|
|
|
strcpy(args[cnt], str.c_str());
|
|
|
|
cnt ++;
|
|
|
|
}
|
|
|
|
*argc = cnt;
|
|
|
|
*argv = args;
|
|
|
|
}
|
|
|
|
|
2005-12-10 17:10:09 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::DeleteRemainingArguments(int argc, char*** argv)
|
|
|
|
{
|
|
|
|
int cc;
|
|
|
|
for ( cc = 0; cc < argc; ++ cc )
|
|
|
|
{
|
2006-06-25 19:18:49 +00:00
|
|
|
delete [] (*argv)[cc];
|
2005-12-10 17:10:09 +00:00
|
|
|
}
|
|
|
|
delete [] *argv;
|
|
|
|
}
|
|
|
|
|
2004-09-13 20:15:02 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::AddCallback(const char* argument, ArgumentTypeEnum type,
|
|
|
|
CallbackType callback, void* call_data, const char* help)
|
|
|
|
{
|
2004-09-15 13:22:34 +00:00
|
|
|
CommandLineArgumentsCallbackStructure s;
|
2004-09-13 20:15:02 +00:00
|
|
|
s.Argument = argument;
|
|
|
|
s.ArgumentType = type;
|
|
|
|
s.Callback = callback;
|
|
|
|
s.CallData = call_data;
|
|
|
|
s.VariableType = CommandLineArguments::NO_VARIABLE_TYPE;
|
|
|
|
s.Variable = 0;
|
|
|
|
s.Help = help;
|
|
|
|
|
|
|
|
this->Internals->Callbacks[argument] = s;
|
|
|
|
this->GenerateHelp();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::AddArgument(const char* argument, ArgumentTypeEnum type,
|
|
|
|
VariableTypeEnum vtype, void* variable, const char* help)
|
|
|
|
{
|
2004-09-15 13:22:34 +00:00
|
|
|
CommandLineArgumentsCallbackStructure s;
|
2004-09-13 20:15:02 +00:00
|
|
|
s.Argument = argument;
|
|
|
|
s.ArgumentType = type;
|
|
|
|
s.Callback = 0;
|
|
|
|
s.CallData = 0;
|
|
|
|
s.VariableType = vtype;
|
|
|
|
s.Variable = variable;
|
|
|
|
s.Help = help;
|
|
|
|
|
|
|
|
this->Internals->Callbacks[argument] = s;
|
|
|
|
this->GenerateHelp();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2006-07-14 13:13:23 +00:00
|
|
|
#define CommandLineArgumentsAddArgumentMacro(type, ctype) \
|
|
|
|
void CommandLineArguments::AddArgument(const char* argument, ArgumentTypeEnum type, \
|
|
|
|
ctype* variable, const char* help) \
|
|
|
|
{ \
|
|
|
|
this->AddArgument(argument, type, CommandLineArguments::type##_TYPE, variable, help); \
|
|
|
|
}
|
|
|
|
|
2007-08-08 12:41:07 +00:00
|
|
|
CommandLineArgumentsAddArgumentMacro(BOOL, bool)
|
|
|
|
CommandLineArgumentsAddArgumentMacro(INT, int)
|
|
|
|
CommandLineArgumentsAddArgumentMacro(DOUBLE, double)
|
|
|
|
CommandLineArgumentsAddArgumentMacro(STRING, char*)
|
|
|
|
CommandLineArgumentsAddArgumentMacro(STL_STRING, kwsys_stl::string)
|
|
|
|
|
|
|
|
CommandLineArgumentsAddArgumentMacro(VECTOR_BOOL, kwsys_stl::vector<bool>)
|
|
|
|
CommandLineArgumentsAddArgumentMacro(VECTOR_INT, kwsys_stl::vector<int>)
|
|
|
|
CommandLineArgumentsAddArgumentMacro(VECTOR_DOUBLE, kwsys_stl::vector<double>)
|
|
|
|
CommandLineArgumentsAddArgumentMacro(VECTOR_STRING, kwsys_stl::vector<char*>)
|
|
|
|
CommandLineArgumentsAddArgumentMacro(VECTOR_STL_STRING, kwsys_stl::vector<kwsys_stl::string>)
|
2004-09-13 20:15:02 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2006-07-14 13:13:23 +00:00
|
|
|
#define CommandLineArgumentsAddBooleanArgumentMacro(type, ctype) \
|
|
|
|
void CommandLineArguments::AddBooleanArgument(const char* argument, \
|
|
|
|
ctype* variable, const char* help) \
|
|
|
|
{ \
|
|
|
|
this->AddArgument(argument, CommandLineArguments::NO_ARGUMENT, \
|
|
|
|
CommandLineArguments::type##_TYPE, variable, help); \
|
|
|
|
}
|
|
|
|
|
2007-08-08 12:41:07 +00:00
|
|
|
CommandLineArgumentsAddBooleanArgumentMacro(BOOL, bool)
|
|
|
|
CommandLineArgumentsAddBooleanArgumentMacro(INT, int)
|
|
|
|
CommandLineArgumentsAddBooleanArgumentMacro(DOUBLE, double)
|
|
|
|
CommandLineArgumentsAddBooleanArgumentMacro(STRING, char*)
|
|
|
|
CommandLineArgumentsAddBooleanArgumentMacro(STL_STRING, kwsys_stl::string)
|
2006-07-14 13:13:23 +00:00
|
|
|
|
2004-09-13 20:15:02 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::SetClientData(void* client_data)
|
|
|
|
{
|
|
|
|
this->Internals->ClientData = client_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::SetUnknownArgumentCallback(
|
|
|
|
CommandLineArguments::ErrorCallbackType callback)
|
|
|
|
{
|
|
|
|
this->Internals->UnknownArgumentCallback = callback;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
const char* CommandLineArguments::GetHelp(const char* arg)
|
|
|
|
{
|
|
|
|
CommandLineArguments::Internal::CallbacksMap::iterator it
|
|
|
|
= this->Internals->Callbacks.find(arg);
|
|
|
|
if ( it == this->Internals->Callbacks.end() )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Since several arguments may point to the same argument, find the one this
|
|
|
|
// one point to if this one is pointing to another argument.
|
2004-09-15 13:22:34 +00:00
|
|
|
CommandLineArgumentsCallbackStructure *cs = &(it->second);
|
2005-04-22 13:21:33 +00:00
|
|
|
for(;;)
|
2004-09-13 20:15:02 +00:00
|
|
|
{
|
|
|
|
CommandLineArguments::Internal::CallbacksMap::iterator hit
|
|
|
|
= this->Internals->Callbacks.find(cs->Help);
|
|
|
|
if ( hit == this->Internals->Callbacks.end() )
|
|
|
|
{
|
2004-10-20 16:37:39 +00:00
|
|
|
break;
|
2004-09-13 20:15:02 +00:00
|
|
|
}
|
|
|
|
cs = &(hit->second);
|
|
|
|
}
|
2004-10-20 16:37:39 +00:00
|
|
|
return cs->Help;
|
2004-09-13 20:15:02 +00:00
|
|
|
}
|
|
|
|
|
2004-09-16 14:27:17 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::SetLineLength(unsigned int ll)
|
|
|
|
{
|
|
|
|
if ( ll < 9 || ll > 1000 )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this->LineLength = ll;
|
|
|
|
this->GenerateHelp();
|
|
|
|
}
|
|
|
|
|
2004-09-28 15:34:29 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
const char* CommandLineArguments::GetArgv0()
|
|
|
|
{
|
|
|
|
return this->Internals->Argv0.c_str();
|
|
|
|
}
|
|
|
|
|
2004-09-29 11:56:25 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
unsigned int CommandLineArguments::GetLastArgument()
|
|
|
|
{
|
2006-07-12 13:21:26 +00:00
|
|
|
return static_cast<unsigned int>(this->Internals->LastArgument + 1);
|
2004-09-29 11:56:25 +00:00
|
|
|
}
|
|
|
|
|
2004-09-13 20:15:02 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::GenerateHelp()
|
|
|
|
{
|
|
|
|
kwsys_ios::ostringstream str;
|
2009-03-19 13:20:40 +00:00
|
|
|
|
2004-09-13 20:15:02 +00:00
|
|
|
// Collapse all arguments into the map of vectors of all arguments that do
|
|
|
|
// the same thing.
|
|
|
|
CommandLineArguments::Internal::CallbacksMap::iterator it;
|
|
|
|
typedef kwsys_stl::map<CommandLineArguments::Internal::String,
|
|
|
|
CommandLineArguments::Internal::SetOfStrings > MapArgs;
|
|
|
|
MapArgs mp;
|
|
|
|
MapArgs::iterator mpit, smpit;
|
|
|
|
for ( it = this->Internals->Callbacks.begin();
|
|
|
|
it != this->Internals->Callbacks.end();
|
|
|
|
it ++ )
|
|
|
|
{
|
2004-09-15 13:22:34 +00:00
|
|
|
CommandLineArgumentsCallbackStructure *cs = &(it->second);
|
2004-09-13 20:15:02 +00:00
|
|
|
mpit = mp.find(cs->Help);
|
|
|
|
if ( mpit != mp.end() )
|
|
|
|
{
|
|
|
|
mpit->second.insert(it->first);
|
|
|
|
mp[it->first].insert(it->first);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mp[it->first].insert(it->first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for ( it = this->Internals->Callbacks.begin();
|
|
|
|
it != this->Internals->Callbacks.end();
|
|
|
|
it ++ )
|
|
|
|
{
|
2004-09-15 13:22:34 +00:00
|
|
|
CommandLineArgumentsCallbackStructure *cs = &(it->second);
|
2004-09-13 20:15:02 +00:00
|
|
|
mpit = mp.find(cs->Help);
|
|
|
|
if ( mpit != mp.end() )
|
|
|
|
{
|
|
|
|
mpit->second.insert(it->first);
|
|
|
|
smpit = mp.find(it->first);
|
|
|
|
CommandLineArguments::Internal::SetOfStrings::iterator sit;
|
|
|
|
for ( sit = smpit->second.begin(); sit != smpit->second.end(); sit++ )
|
|
|
|
{
|
|
|
|
mpit->second.insert(*sit);
|
|
|
|
}
|
|
|
|
mp.erase(smpit);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mp[it->first].insert(it->first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find the length of the longest string
|
|
|
|
CommandLineArguments::Internal::String::size_type maxlen = 0;
|
|
|
|
for ( mpit = mp.begin();
|
|
|
|
mpit != mp.end();
|
|
|
|
mpit ++ )
|
|
|
|
{
|
|
|
|
CommandLineArguments::Internal::SetOfStrings::iterator sit;
|
|
|
|
for ( sit = mpit->second.begin(); sit != mpit->second.end(); sit++ )
|
|
|
|
{
|
|
|
|
CommandLineArguments::Internal::String::size_type clen = sit->size();
|
|
|
|
switch ( this->Internals->Callbacks[*sit].ArgumentType )
|
|
|
|
{
|
|
|
|
case CommandLineArguments::NO_ARGUMENT: clen += 0; break;
|
2004-09-16 14:27:17 +00:00
|
|
|
case CommandLineArguments::CONCAT_ARGUMENT: clen += 3; break;
|
|
|
|
case CommandLineArguments::SPACE_ARGUMENT: clen += 4; break;
|
|
|
|
case CommandLineArguments::EQUAL_ARGUMENT: clen += 4; break;
|
2004-09-13 20:15:02 +00:00
|
|
|
}
|
|
|
|
if ( clen > maxlen )
|
|
|
|
{
|
|
|
|
maxlen = clen;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create format for that string
|
|
|
|
char format[80];
|
2004-09-16 14:49:09 +00:00
|
|
|
sprintf(format, " %%-%ds ", static_cast<unsigned int>(maxlen));
|
2004-09-13 20:15:02 +00:00
|
|
|
|
2004-09-16 14:49:09 +00:00
|
|
|
maxlen += 4; // For the space before and after the option
|
2004-09-13 20:15:02 +00:00
|
|
|
|
|
|
|
// Print help for each option
|
|
|
|
for ( mpit = mp.begin();
|
|
|
|
mpit != mp.end();
|
|
|
|
mpit ++ )
|
|
|
|
{
|
|
|
|
CommandLineArguments::Internal::SetOfStrings::iterator sit;
|
|
|
|
for ( sit = mpit->second.begin(); sit != mpit->second.end(); sit++ )
|
|
|
|
{
|
2004-09-13 22:57:28 +00:00
|
|
|
str << kwsys_ios::endl;
|
2004-09-13 20:15:02 +00:00
|
|
|
char argument[100];
|
2007-08-03 19:43:31 +00:00
|
|
|
sprintf(argument, "%s", sit->c_str());
|
2004-09-13 20:15:02 +00:00
|
|
|
switch ( this->Internals->Callbacks[*sit].ArgumentType )
|
|
|
|
{
|
|
|
|
case CommandLineArguments::NO_ARGUMENT: break;
|
2004-09-16 14:27:17 +00:00
|
|
|
case CommandLineArguments::CONCAT_ARGUMENT: strcat(argument, "opt"); break;
|
|
|
|
case CommandLineArguments::SPACE_ARGUMENT: strcat(argument, " opt"); break;
|
|
|
|
case CommandLineArguments::EQUAL_ARGUMENT: strcat(argument, "=opt"); break;
|
2006-07-14 13:13:23 +00:00
|
|
|
case CommandLineArguments::MULTI_ARGUMENT: strcat(argument, " opt opt ..."); break;
|
2004-09-13 20:15:02 +00:00
|
|
|
}
|
|
|
|
char buffer[80];
|
|
|
|
sprintf(buffer, format, argument);
|
|
|
|
str << buffer;
|
|
|
|
}
|
|
|
|
const char* ptr = this->Internals->Callbacks[mpit->first].Help;
|
2006-03-30 18:49:56 +00:00
|
|
|
size_t len = strlen(ptr);
|
2004-09-13 20:15:02 +00:00
|
|
|
int cnt = 0;
|
|
|
|
while ( len > 0)
|
|
|
|
{
|
|
|
|
// If argument with help is longer than line length, split it on previous
|
|
|
|
// space (or tab) and continue on the next line
|
|
|
|
CommandLineArguments::Internal::String::size_type cc;
|
|
|
|
for ( cc = 0; ptr[cc]; cc ++ )
|
|
|
|
{
|
|
|
|
if ( *ptr == ' ' || *ptr == '\t' )
|
|
|
|
{
|
|
|
|
ptr ++;
|
|
|
|
len --;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( cnt > 0 )
|
|
|
|
{
|
|
|
|
for ( cc = 0; cc < maxlen; cc ++ )
|
|
|
|
{
|
|
|
|
str << " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CommandLineArguments::Internal::String::size_type skip = len;
|
|
|
|
if ( skip > this->LineLength - maxlen )
|
|
|
|
{
|
|
|
|
skip = this->LineLength - maxlen;
|
|
|
|
for ( cc = skip-1; cc > 0; cc -- )
|
|
|
|
{
|
|
|
|
if ( ptr[cc] == ' ' || ptr[cc] == '\t' )
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( cc != 0 )
|
|
|
|
{
|
|
|
|
skip = cc;
|
|
|
|
}
|
|
|
|
}
|
2009-03-19 15:48:50 +00:00
|
|
|
str.write(ptr, static_cast<kwsys_ios::streamsize>(skip));
|
2004-09-13 22:57:28 +00:00
|
|
|
str << kwsys_ios::endl;
|
2004-09-13 20:15:02 +00:00
|
|
|
ptr += skip;
|
|
|
|
len -= skip;
|
|
|
|
cnt ++;
|
|
|
|
}
|
|
|
|
}
|
2004-09-16 14:27:17 +00:00
|
|
|
/*
|
|
|
|
// This can help debugging help string
|
|
|
|
str << endl;
|
|
|
|
unsigned int cc;
|
|
|
|
for ( cc = 0; cc < this->LineLength; cc ++ )
|
|
|
|
{
|
|
|
|
str << cc % 10;
|
|
|
|
}
|
|
|
|
str << endl;
|
|
|
|
*/
|
2004-09-13 20:15:02 +00:00
|
|
|
this->Help = str.str();
|
|
|
|
}
|
|
|
|
|
2006-07-14 13:13:23 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::PopulateVariable(
|
|
|
|
bool* variable, const kwsys_stl::string& value)
|
|
|
|
{
|
|
|
|
if ( value == "1" || value == "ON" || value == "on" || value == "On" ||
|
|
|
|
value == "TRUE" || value == "true" || value == "True" ||
|
|
|
|
value == "yes" || value == "Yes" || value == "YES" )
|
|
|
|
{
|
|
|
|
*variable = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*variable = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::PopulateVariable(
|
|
|
|
int* variable, const kwsys_stl::string& value)
|
|
|
|
{
|
|
|
|
char* res = 0;
|
2009-03-19 13:20:40 +00:00
|
|
|
*variable = static_cast<int>(strtol(value.c_str(), &res, 10));
|
2006-07-14 13:13:23 +00:00
|
|
|
//if ( res && *res )
|
|
|
|
// {
|
|
|
|
// Can handle non-int
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::PopulateVariable(
|
|
|
|
double* variable, const kwsys_stl::string& value)
|
|
|
|
{
|
|
|
|
char* res = 0;
|
|
|
|
*variable = strtod(value.c_str(), &res);
|
|
|
|
//if ( res && *res )
|
|
|
|
// {
|
|
|
|
// Can handle non-double
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::PopulateVariable(
|
|
|
|
char** variable, const kwsys_stl::string& value)
|
|
|
|
{
|
|
|
|
if ( *variable )
|
|
|
|
{
|
|
|
|
delete [] *variable;
|
|
|
|
*variable = 0;
|
|
|
|
}
|
|
|
|
*variable = new char[ value.size() + 1 ];
|
|
|
|
strcpy(*variable, value.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::PopulateVariable(
|
|
|
|
kwsys_stl::string* variable, const kwsys_stl::string& value)
|
|
|
|
{
|
|
|
|
*variable = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::PopulateVariable(
|
|
|
|
kwsys_stl::vector<bool>* variable, const kwsys_stl::string& value)
|
|
|
|
{
|
|
|
|
bool val = false;
|
|
|
|
if ( value == "1" || value == "ON" || value == "on" || value == "On" ||
|
|
|
|
value == "TRUE" || value == "true" || value == "True" ||
|
|
|
|
value == "yes" || value == "Yes" || value == "YES" )
|
|
|
|
{
|
|
|
|
val = true;
|
|
|
|
}
|
|
|
|
variable->push_back(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::PopulateVariable(
|
|
|
|
kwsys_stl::vector<int>* variable, const kwsys_stl::string& value)
|
|
|
|
{
|
|
|
|
char* res = 0;
|
2009-03-19 13:20:40 +00:00
|
|
|
variable->push_back(static_cast<int>(strtol(value.c_str(), &res, 10)));
|
2006-07-14 13:13:23 +00:00
|
|
|
//if ( res && *res )
|
|
|
|
// {
|
|
|
|
// Can handle non-int
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::PopulateVariable(
|
|
|
|
kwsys_stl::vector<double>* variable, const kwsys_stl::string& value)
|
|
|
|
{
|
|
|
|
char* res = 0;
|
|
|
|
variable->push_back(strtod(value.c_str(), &res));
|
|
|
|
//if ( res && *res )
|
|
|
|
// {
|
|
|
|
// Can handle non-int
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::PopulateVariable(
|
|
|
|
kwsys_stl::vector<char*>* variable, const kwsys_stl::string& value)
|
|
|
|
{
|
|
|
|
char* var = new char[ value.size() + 1 ];
|
|
|
|
strcpy(var, value.c_str());
|
|
|
|
variable->push_back(var);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void CommandLineArguments::PopulateVariable(
|
|
|
|
kwsys_stl::vector<kwsys_stl::string>* variable,
|
|
|
|
const kwsys_stl::string& value)
|
|
|
|
{
|
|
|
|
variable->push_back(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool CommandLineArguments::PopulateVariable(CommandLineArgumentsCallbackStructure* cs,
|
|
|
|
const char* value)
|
|
|
|
{
|
|
|
|
// Call the callback
|
|
|
|
if ( cs->Callback )
|
|
|
|
{
|
|
|
|
if ( !cs->Callback(cs->Argument, value, cs->CallData) )
|
|
|
|
{
|
|
|
|
this->Internals->LastArgument --;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2006-07-14 19:02:27 +00:00
|
|
|
CommandLineArguments_DEBUG("Set argument: " << cs->Argument << " to " << value);
|
2006-07-14 13:13:23 +00:00
|
|
|
if ( cs->Variable )
|
|
|
|
{
|
|
|
|
kwsys_stl::string var = "1";
|
|
|
|
if ( value )
|
|
|
|
{
|
|
|
|
var = value;
|
|
|
|
}
|
|
|
|
switch ( cs->VariableType )
|
|
|
|
{
|
|
|
|
case CommandLineArguments::INT_TYPE:
|
|
|
|
this->PopulateVariable(static_cast<int*>(cs->Variable), var);
|
|
|
|
break;
|
|
|
|
case CommandLineArguments::DOUBLE_TYPE:
|
|
|
|
this->PopulateVariable(static_cast<double*>(cs->Variable), var);
|
|
|
|
break;
|
|
|
|
case CommandLineArguments::STRING_TYPE:
|
|
|
|
this->PopulateVariable(static_cast<char**>(cs->Variable), var);
|
|
|
|
break;
|
|
|
|
case CommandLineArguments::STL_STRING_TYPE:
|
|
|
|
this->PopulateVariable(static_cast<kwsys_stl::string*>(cs->Variable), var);
|
|
|
|
break;
|
|
|
|
case CommandLineArguments::BOOL_TYPE:
|
|
|
|
this->PopulateVariable(static_cast<bool*>(cs->Variable), var);
|
|
|
|
break;
|
|
|
|
case CommandLineArguments::VECTOR_BOOL_TYPE:
|
|
|
|
this->PopulateVariable(static_cast<kwsys_stl::vector<bool>*>(cs->Variable), var);
|
|
|
|
break;
|
|
|
|
case CommandLineArguments::VECTOR_INT_TYPE:
|
|
|
|
this->PopulateVariable(static_cast<kwsys_stl::vector<int>*>(cs->Variable), var);
|
|
|
|
break;
|
|
|
|
case CommandLineArguments::VECTOR_DOUBLE_TYPE:
|
|
|
|
this->PopulateVariable(static_cast<kwsys_stl::vector<double>*>(cs->Variable), var);
|
|
|
|
break;
|
|
|
|
case CommandLineArguments::VECTOR_STRING_TYPE:
|
|
|
|
this->PopulateVariable(static_cast<kwsys_stl::vector<char*>*>(cs->Variable), var);
|
|
|
|
break;
|
|
|
|
case CommandLineArguments::VECTOR_STL_STRING_TYPE:
|
|
|
|
this->PopulateVariable(static_cast<kwsys_stl::vector<kwsys_stl::string>*>(cs->Variable), var);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
kwsys_ios::cerr << "Got unknown variable type: \"" << cs->VariableType << "\"" << kwsys_ios::endl;
|
|
|
|
this->Internals->LastArgument --;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-13 20:15:02 +00:00
|
|
|
} // namespace KWSYS_NAMESPACE
|