1 /*=========================================================================
3 Program: KWSys - Kitware System Library
4 Module: $RCSfile: CommandLineArguments.cxx,v $
6 Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved.
7 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notices for more information.
13 =========================================================================*/
14 #include "kwsysPrivate.h"
15 #include KWSYS_HEADER(CommandLineArguments.hxx)
17 #include KWSYS_HEADER(Configure.hxx)
18 #include KWSYS_HEADER(String.hxx)
20 #include KWSYS_HEADER(stl/vector)
21 #include KWSYS_HEADER(stl/map)
22 #include KWSYS_HEADER(stl/set)
23 #include KWSYS_HEADER(ios/sstream)
24 #include KWSYS_HEADER(ios/iostream)
26 // Work-around CMake dependency scanning limitation. This must
27 // duplicate the above list of headers.
29 # include "CommandLineArguments.hxx.in"
30 # include "Configure.hxx.in"
31 # include "kwsys_stl.hxx.in"
32 # include "kwsys_ios_sstream.h.in"
33 # include "kwsys_ios_iostream.h.in"
41 # pragma warning (disable: 4786)
44 #if defined(__sgi) && !defined(__GNUC__)
45 # pragma set woff 1375 /* base class destructor not virtual */
49 # define CommandLineArguments_DEBUG(x) \
50 kwsys_ios::cout << __LINE__ << " CLA: " << x << kwsys_ios::endl
52 # define CommandLineArguments_DEBUG(x)
55 namespace KWSYS_NAMESPACE
58 //----------------------------------------------------------------------------
59 //============================================================================
60 struct CommandLineArgumentsCallbackStructure
64 CommandLineArguments::CallbackType Callback
;
71 class CommandLineArgumentsVectorOfStrings
:
72 public kwsys_stl::vector
<kwsys::String
> {};
73 class CommandLineArgumentsSetOfStrings
:
74 public kwsys_stl::set
<kwsys::String
> {};
75 class CommandLineArgumentsMapOfStrucs
:
76 public kwsys_stl::map
<kwsys::String
,
77 CommandLineArgumentsCallbackStructure
> {};
79 class CommandLineArgumentsInternal
82 CommandLineArgumentsInternal()
84 this->UnknownArgumentCallback
= 0;
86 this->LastArgument
= 0;
89 typedef CommandLineArgumentsVectorOfStrings VectorOfStrings
;
90 typedef CommandLineArgumentsMapOfStrucs CallbacksMap
;
91 typedef kwsys::String String
;
92 typedef CommandLineArgumentsSetOfStrings SetOfStrings
;
96 CallbacksMap Callbacks
;
98 CommandLineArguments::ErrorCallbackType UnknownArgumentCallback
;
101 VectorOfStrings::size_type LastArgument
;
103 VectorOfStrings UnusedArguments
;
105 //============================================================================
106 //----------------------------------------------------------------------------
108 //----------------------------------------------------------------------------
109 CommandLineArguments::CommandLineArguments()
111 this->Internals
= new CommandLineArguments::Internal
;
113 this->LineLength
= 80;
114 this->StoreUnusedArgumentsFlag
= false;
117 //----------------------------------------------------------------------------
118 CommandLineArguments::~CommandLineArguments()
120 delete this->Internals
;
123 //----------------------------------------------------------------------------
124 void CommandLineArguments::Initialize(int argc
, const char* const argv
[])
129 this->Internals
->Argv0
= argv
[0];
130 for ( cc
= 1; cc
< argc
; cc
++ )
132 this->ProcessArgument(argv
[cc
]);
136 //----------------------------------------------------------------------------
137 void CommandLineArguments::Initialize(int argc
, char* argv
[])
139 this->Initialize(argc
, static_cast<const char* const*>(argv
));
142 //----------------------------------------------------------------------------
143 void CommandLineArguments::Initialize()
145 this->Internals
->Argv
.clear();
146 this->Internals
->LastArgument
= 0;
149 //----------------------------------------------------------------------------
150 void CommandLineArguments::ProcessArgument(const char* arg
)
152 this->Internals
->Argv
.push_back(arg
);
155 //----------------------------------------------------------------------------
156 bool CommandLineArguments::GetMatchedArguments(
157 kwsys_stl::vector
<kwsys_stl::string
>* matches
,
158 const kwsys_stl::string
& arg
)
161 CommandLineArguments::Internal::CallbacksMap::iterator it
;
163 // Does the argument match to any we know about?
164 for ( it
= this->Internals
->Callbacks
.begin();
165 it
!= this->Internals
->Callbacks
.end();
168 const CommandLineArguments::Internal::String
& parg
= it
->first
;
169 CommandLineArgumentsCallbackStructure
*cs
= &it
->second
;
170 if (cs
->ArgumentType
== CommandLineArguments::NO_ARGUMENT
||
171 cs
->ArgumentType
== CommandLineArguments::SPACE_ARGUMENT
)
175 matches
->push_back(parg
);
178 else if ( arg
.find( parg
) == 0 )
180 matches
->push_back(parg
);
183 return matches
->size() > 0;
186 //----------------------------------------------------------------------------
187 int CommandLineArguments::Parse()
189 kwsys_stl::vector
<kwsys_stl::string
>::size_type cc
;
190 kwsys_stl::vector
<kwsys_stl::string
> matches
;
191 if ( this->StoreUnusedArgumentsFlag
)
193 this->Internals
->UnusedArguments
.clear();
195 for ( cc
= 0; cc
< this->Internals
->Argv
.size(); cc
++ )
197 const kwsys_stl::string
& arg
= this->Internals
->Argv
[cc
];
198 CommandLineArguments_DEBUG("Process argument: " << arg
);
199 this->Internals
->LastArgument
= cc
;
200 if ( this->GetMatchedArguments(&matches
, arg
) )
202 // Ok, we found one or more arguments that match what user specified.
203 // Let's find the longest one.
204 CommandLineArguments::Internal::VectorOfStrings::size_type kk
;
205 CommandLineArguments::Internal::VectorOfStrings::size_type maxidx
= 0;
206 CommandLineArguments::Internal::String::size_type maxlen
= 0;
207 for ( kk
= 0; kk
< matches
.size(); kk
++ )
209 if ( matches
[kk
].size() > maxlen
)
211 maxlen
= matches
[kk
].size();
215 // So, the longest one is probably the right one. Now see if it has any
217 CommandLineArgumentsCallbackStructure
*cs
218 = &this->Internals
->Callbacks
[matches
[maxidx
]];
219 const kwsys_stl::string
& sarg
= matches
[maxidx
];
220 if ( cs
->Argument
!= sarg
)
224 switch ( cs
->ArgumentType
)
228 if ( !this->PopulateVariable(cs
, 0) )
234 if ( cc
== this->Internals
->Argv
.size()-1 )
236 this->Internals
->LastArgument
--;
239 CommandLineArguments_DEBUG("This is a space argument: " << arg
240 << " value: " << this->Internals
->Argv
[cc
+1].c_str());
241 // Value is the next argument
242 if ( !this->PopulateVariable(cs
, this->Internals
->Argv
[cc
+1].c_str()) )
249 if ( arg
.size() == sarg
.size() || *(arg
.c_str() + sarg
.size()) != '=' )
251 this->Internals
->LastArgument
--;
254 // Value is everythng followed the '=' sign
255 if ( !this->PopulateVariable(cs
, arg
.c_str() + sarg
.size() + 1) )
260 case CONCAT_ARGUMENT
:
261 // Value is whatever follows the argument
262 if ( !this->PopulateVariable(cs
, arg
.c_str() + sarg
.size()) )
268 // Suck in all the rest of the arguments
269 CommandLineArguments_DEBUG("This is a multi argument: " << arg
);
270 for (cc
++; cc
< this->Internals
->Argv
.size(); ++ cc
)
272 const kwsys_stl::string
& marg
= this->Internals
->Argv
[cc
];
273 CommandLineArguments_DEBUG(" check multi argument value: " << marg
);
274 if ( this->GetMatchedArguments(&matches
, marg
) )
276 CommandLineArguments_DEBUG("End of multi argument " << arg
<< " with value: " << marg
);
279 CommandLineArguments_DEBUG(" populate multi argument value: " << marg
);
280 if ( !this->PopulateVariable(cs
, marg
.c_str()) )
285 if ( cc
!= this->Internals
->Argv
.size() )
287 CommandLineArguments_DEBUG("Again End of multi argument " << arg
);
293 kwsys_ios::cerr
<< "Got unknown argument type: \"" << cs
->ArgumentType
<< "\"" << kwsys_ios::endl
;
294 this->Internals
->LastArgument
--;
300 // Handle unknown arguments
301 if ( this->Internals
->UnknownArgumentCallback
)
303 if ( !this->Internals
->UnknownArgumentCallback(arg
.c_str(),
304 this->Internals
->ClientData
) )
306 this->Internals
->LastArgument
--;
311 else if ( this->StoreUnusedArgumentsFlag
)
313 CommandLineArguments_DEBUG("Store unused argument " << arg
);
314 this->Internals
->UnusedArguments
.push_back(arg
.c_str());
318 kwsys_ios::cerr
<< "Got unknown argument: \"" << arg
.c_str() << "\"" << kwsys_ios::endl
;
319 this->Internals
->LastArgument
--;
327 //----------------------------------------------------------------------------
328 void CommandLineArguments::GetRemainingArguments(int* argc
, char*** argv
)
330 CommandLineArguments::Internal::VectorOfStrings::size_type size
331 = this->Internals
->Argv
.size() - this->Internals
->LastArgument
+ 1;
332 CommandLineArguments::Internal::VectorOfStrings::size_type cc
;
334 // Copy Argv0 as the first argument
335 char** args
= new char*[ size
];
336 args
[0] = new char[ this->Internals
->Argv0
.size() + 1 ];
337 strcpy(args
[0], this->Internals
->Argv0
.c_str());
340 // Copy everything after the LastArgument, since that was not parsed.
341 for ( cc
= this->Internals
->LastArgument
+1;
342 cc
< this->Internals
->Argv
.size(); cc
++ )
344 args
[cnt
] = new char[ this->Internals
->Argv
[cc
].size() + 1];
345 strcpy(args
[cnt
], this->Internals
->Argv
[cc
].c_str());
352 //----------------------------------------------------------------------------
353 void CommandLineArguments::GetUnusedArguments(int* argc
, char*** argv
)
355 CommandLineArguments::Internal::VectorOfStrings::size_type size
356 = this->Internals
->UnusedArguments
.size() + 1;
357 CommandLineArguments::Internal::VectorOfStrings::size_type cc
;
359 // Copy Argv0 as the first argument
360 char** args
= new char*[ size
];
361 args
[0] = new char[ this->Internals
->Argv0
.size() + 1 ];
362 strcpy(args
[0], this->Internals
->Argv0
.c_str());
365 // Copy everything after the LastArgument, since that was not parsed.
367 cc
< this->Internals
->UnusedArguments
.size(); cc
++ )
369 kwsys::String
&str
= this->Internals
->UnusedArguments
[cc
];
370 args
[cnt
] = new char[ str
.size() + 1];
371 strcpy(args
[cnt
], str
.c_str());
378 //----------------------------------------------------------------------------
379 void CommandLineArguments::DeleteRemainingArguments(int argc
, char*** argv
)
382 for ( cc
= 0; cc
< argc
; ++ cc
)
384 delete [] (*argv
)[cc
];
389 //----------------------------------------------------------------------------
390 void CommandLineArguments::AddCallback(const char* argument
, ArgumentTypeEnum type
,
391 CallbackType callback
, void* call_data
, const char* help
)
393 CommandLineArgumentsCallbackStructure s
;
394 s
.Argument
= argument
;
395 s
.ArgumentType
= type
;
396 s
.Callback
= callback
;
397 s
.CallData
= call_data
;
398 s
.VariableType
= CommandLineArguments::NO_VARIABLE_TYPE
;
402 this->Internals
->Callbacks
[argument
] = s
;
403 this->GenerateHelp();
406 //----------------------------------------------------------------------------
407 void CommandLineArguments::AddArgument(const char* argument
, ArgumentTypeEnum type
,
408 VariableTypeEnum vtype
, void* variable
, const char* help
)
410 CommandLineArgumentsCallbackStructure s
;
411 s
.Argument
= argument
;
412 s
.ArgumentType
= type
;
415 s
.VariableType
= vtype
;
416 s
.Variable
= variable
;
419 this->Internals
->Callbacks
[argument
] = s
;
420 this->GenerateHelp();
423 //----------------------------------------------------------------------------
424 #define CommandLineArgumentsAddArgumentMacro(type, ctype) \
425 void CommandLineArguments::AddArgument(const char* argument, ArgumentTypeEnum type, \
426 ctype* variable, const char* help) \
428 this->AddArgument(argument, type, CommandLineArguments::type##_TYPE, variable, help); \
431 CommandLineArgumentsAddArgumentMacro(BOOL
, bool)
432 CommandLineArgumentsAddArgumentMacro(INT
, int)
433 CommandLineArgumentsAddArgumentMacro(DOUBLE
, double)
434 CommandLineArgumentsAddArgumentMacro(STRING
, char*)
435 CommandLineArgumentsAddArgumentMacro(STL_STRING
, kwsys_stl::string
)
437 CommandLineArgumentsAddArgumentMacro(VECTOR_BOOL
, kwsys_stl::vector
<bool>)
438 CommandLineArgumentsAddArgumentMacro(VECTOR_INT
, kwsys_stl::vector
<int>)
439 CommandLineArgumentsAddArgumentMacro(VECTOR_DOUBLE
, kwsys_stl::vector
<double>)
440 CommandLineArgumentsAddArgumentMacro(VECTOR_STRING
, kwsys_stl::vector
<char*>)
441 CommandLineArgumentsAddArgumentMacro(VECTOR_STL_STRING
, kwsys_stl::vector
<kwsys_stl::string
>)
443 //----------------------------------------------------------------------------
444 #define CommandLineArgumentsAddBooleanArgumentMacro(type, ctype) \
445 void CommandLineArguments::AddBooleanArgument(const char* argument, \
446 ctype* variable, const char* help) \
448 this->AddArgument(argument, CommandLineArguments::NO_ARGUMENT, \
449 CommandLineArguments::type##_TYPE, variable, help); \
452 CommandLineArgumentsAddBooleanArgumentMacro(BOOL
, bool)
453 CommandLineArgumentsAddBooleanArgumentMacro(INT
, int)
454 CommandLineArgumentsAddBooleanArgumentMacro(DOUBLE
, double)
455 CommandLineArgumentsAddBooleanArgumentMacro(STRING
, char*)
456 CommandLineArgumentsAddBooleanArgumentMacro(STL_STRING
, kwsys_stl::string
)
458 //----------------------------------------------------------------------------
459 void CommandLineArguments::SetClientData(void* client_data
)
461 this->Internals
->ClientData
= client_data
;
464 //----------------------------------------------------------------------------
465 void CommandLineArguments::SetUnknownArgumentCallback(
466 CommandLineArguments::ErrorCallbackType callback
)
468 this->Internals
->UnknownArgumentCallback
= callback
;
471 //----------------------------------------------------------------------------
472 const char* CommandLineArguments::GetHelp(const char* arg
)
474 CommandLineArguments::Internal::CallbacksMap::iterator it
475 = this->Internals
->Callbacks
.find(arg
);
476 if ( it
== this->Internals
->Callbacks
.end() )
481 // Since several arguments may point to the same argument, find the one this
482 // one point to if this one is pointing to another argument.
483 CommandLineArgumentsCallbackStructure
*cs
= &(it
->second
);
486 CommandLineArguments::Internal::CallbacksMap::iterator hit
487 = this->Internals
->Callbacks
.find(cs
->Help
);
488 if ( hit
== this->Internals
->Callbacks
.end() )
497 //----------------------------------------------------------------------------
498 void CommandLineArguments::SetLineLength(unsigned int ll
)
500 if ( ll
< 9 || ll
> 1000 )
504 this->LineLength
= ll
;
505 this->GenerateHelp();
508 //----------------------------------------------------------------------------
509 const char* CommandLineArguments::GetArgv0()
511 return this->Internals
->Argv0
.c_str();
514 //----------------------------------------------------------------------------
515 unsigned int CommandLineArguments::GetLastArgument()
517 return static_cast<unsigned int>(this->Internals
->LastArgument
+ 1);
520 //----------------------------------------------------------------------------
521 void CommandLineArguments::GenerateHelp()
523 kwsys_ios::ostringstream str
;
525 // Collapse all arguments into the map of vectors of all arguments that do
527 CommandLineArguments::Internal::CallbacksMap::iterator it
;
528 typedef kwsys_stl::map
<CommandLineArguments::Internal::String
,
529 CommandLineArguments::Internal::SetOfStrings
> MapArgs
;
531 MapArgs::iterator mpit
, smpit
;
532 for ( it
= this->Internals
->Callbacks
.begin();
533 it
!= this->Internals
->Callbacks
.end();
536 CommandLineArgumentsCallbackStructure
*cs
= &(it
->second
);
537 mpit
= mp
.find(cs
->Help
);
538 if ( mpit
!= mp
.end() )
540 mpit
->second
.insert(it
->first
);
541 mp
[it
->first
].insert(it
->first
);
545 mp
[it
->first
].insert(it
->first
);
548 for ( it
= this->Internals
->Callbacks
.begin();
549 it
!= this->Internals
->Callbacks
.end();
552 CommandLineArgumentsCallbackStructure
*cs
= &(it
->second
);
553 mpit
= mp
.find(cs
->Help
);
554 if ( mpit
!= mp
.end() )
556 mpit
->second
.insert(it
->first
);
557 smpit
= mp
.find(it
->first
);
558 CommandLineArguments::Internal::SetOfStrings::iterator sit
;
559 for ( sit
= smpit
->second
.begin(); sit
!= smpit
->second
.end(); sit
++ )
561 mpit
->second
.insert(*sit
);
567 mp
[it
->first
].insert(it
->first
);
571 // Find the length of the longest string
572 CommandLineArguments::Internal::String::size_type maxlen
= 0;
573 for ( mpit
= mp
.begin();
577 CommandLineArguments::Internal::SetOfStrings::iterator sit
;
578 for ( sit
= mpit
->second
.begin(); sit
!= mpit
->second
.end(); sit
++ )
580 CommandLineArguments::Internal::String::size_type clen
= sit
->size();
581 switch ( this->Internals
->Callbacks
[*sit
].ArgumentType
)
583 case CommandLineArguments::NO_ARGUMENT
: clen
+= 0; break;
584 case CommandLineArguments::CONCAT_ARGUMENT
: clen
+= 3; break;
585 case CommandLineArguments::SPACE_ARGUMENT
: clen
+= 4; break;
586 case CommandLineArguments::EQUAL_ARGUMENT
: clen
+= 4; break;
595 // Create format for that string
597 sprintf(format
, " %%-%ds ", static_cast<unsigned int>(maxlen
));
599 maxlen
+= 4; // For the space before and after the option
601 // Print help for each option
602 for ( mpit
= mp
.begin();
606 CommandLineArguments::Internal::SetOfStrings::iterator sit
;
607 for ( sit
= mpit
->second
.begin(); sit
!= mpit
->second
.end(); sit
++ )
609 str
<< kwsys_ios::endl
;
611 sprintf(argument
, "%s", sit
->c_str());
612 switch ( this->Internals
->Callbacks
[*sit
].ArgumentType
)
614 case CommandLineArguments::NO_ARGUMENT
: break;
615 case CommandLineArguments::CONCAT_ARGUMENT
: strcat(argument
, "opt"); break;
616 case CommandLineArguments::SPACE_ARGUMENT
: strcat(argument
, " opt"); break;
617 case CommandLineArguments::EQUAL_ARGUMENT
: strcat(argument
, "=opt"); break;
618 case CommandLineArguments::MULTI_ARGUMENT
: strcat(argument
, " opt opt ..."); break;
621 sprintf(buffer
, format
, argument
);
624 const char* ptr
= this->Internals
->Callbacks
[mpit
->first
].Help
;
625 size_t len
= strlen(ptr
);
629 // If argument with help is longer than line length, split it on previous
630 // space (or tab) and continue on the next line
631 CommandLineArguments::Internal::String::size_type cc
;
632 for ( cc
= 0; ptr
[cc
]; cc
++ )
634 if ( *ptr
== ' ' || *ptr
== '\t' )
642 for ( cc
= 0; cc
< maxlen
; cc
++ )
647 CommandLineArguments::Internal::String::size_type skip
= len
;
648 if ( skip
> this->LineLength
- maxlen
)
650 skip
= this->LineLength
- maxlen
;
651 for ( cc
= skip
-1; cc
> 0; cc
-- )
653 if ( ptr
[cc
] == ' ' || ptr
[cc
] == '\t' )
663 str
.write(ptr
, static_cast<kwsys_ios::streamsize
>(skip
));
664 str
<< kwsys_ios::endl
;
671 // This can help debugging help string
674 for ( cc = 0; cc < this->LineLength; cc ++ )
680 this->Help
= str
.str();
683 //----------------------------------------------------------------------------
684 void CommandLineArguments::PopulateVariable(
685 bool* variable
, const kwsys_stl::string
& value
)
687 if ( value
== "1" || value
== "ON" || value
== "on" || value
== "On" ||
688 value
== "TRUE" || value
== "true" || value
== "True" ||
689 value
== "yes" || value
== "Yes" || value
== "YES" )
699 //----------------------------------------------------------------------------
700 void CommandLineArguments::PopulateVariable(
701 int* variable
, const kwsys_stl::string
& value
)
704 *variable
= static_cast<int>(strtol(value
.c_str(), &res
, 10));
707 // Can handle non-int
711 //----------------------------------------------------------------------------
712 void CommandLineArguments::PopulateVariable(
713 double* variable
, const kwsys_stl::string
& value
)
716 *variable
= strtod(value
.c_str(), &res
);
719 // Can handle non-double
723 //----------------------------------------------------------------------------
724 void CommandLineArguments::PopulateVariable(
725 char** variable
, const kwsys_stl::string
& value
)
732 *variable
= new char[ value
.size() + 1 ];
733 strcpy(*variable
, value
.c_str());
736 //----------------------------------------------------------------------------
737 void CommandLineArguments::PopulateVariable(
738 kwsys_stl::string
* variable
, const kwsys_stl::string
& value
)
743 //----------------------------------------------------------------------------
744 void CommandLineArguments::PopulateVariable(
745 kwsys_stl::vector
<bool>* variable
, const kwsys_stl::string
& value
)
748 if ( value
== "1" || value
== "ON" || value
== "on" || value
== "On" ||
749 value
== "TRUE" || value
== "true" || value
== "True" ||
750 value
== "yes" || value
== "Yes" || value
== "YES" )
754 variable
->push_back(val
);
757 //----------------------------------------------------------------------------
758 void CommandLineArguments::PopulateVariable(
759 kwsys_stl::vector
<int>* variable
, const kwsys_stl::string
& value
)
762 variable
->push_back(static_cast<int>(strtol(value
.c_str(), &res
, 10)));
765 // Can handle non-int
769 //----------------------------------------------------------------------------
770 void CommandLineArguments::PopulateVariable(
771 kwsys_stl::vector
<double>* variable
, const kwsys_stl::string
& value
)
774 variable
->push_back(strtod(value
.c_str(), &res
));
777 // Can handle non-int
781 //----------------------------------------------------------------------------
782 void CommandLineArguments::PopulateVariable(
783 kwsys_stl::vector
<char*>* variable
, const kwsys_stl::string
& value
)
785 char* var
= new char[ value
.size() + 1 ];
786 strcpy(var
, value
.c_str());
787 variable
->push_back(var
);
790 //----------------------------------------------------------------------------
791 void CommandLineArguments::PopulateVariable(
792 kwsys_stl::vector
<kwsys_stl::string
>* variable
,
793 const kwsys_stl::string
& value
)
795 variable
->push_back(value
);
798 //----------------------------------------------------------------------------
799 bool CommandLineArguments::PopulateVariable(CommandLineArgumentsCallbackStructure
* cs
,
805 if ( !cs
->Callback(cs
->Argument
, value
, cs
->CallData
) )
807 this->Internals
->LastArgument
--;
811 CommandLineArguments_DEBUG("Set argument: " << cs
->Argument
<< " to " << value
);
814 kwsys_stl::string var
= "1";
819 switch ( cs
->VariableType
)
821 case CommandLineArguments::INT_TYPE
:
822 this->PopulateVariable(static_cast<int*>(cs
->Variable
), var
);
824 case CommandLineArguments::DOUBLE_TYPE
:
825 this->PopulateVariable(static_cast<double*>(cs
->Variable
), var
);
827 case CommandLineArguments::STRING_TYPE
:
828 this->PopulateVariable(static_cast<char**>(cs
->Variable
), var
);
830 case CommandLineArguments::STL_STRING_TYPE
:
831 this->PopulateVariable(static_cast<kwsys_stl::string
*>(cs
->Variable
), var
);
833 case CommandLineArguments::BOOL_TYPE
:
834 this->PopulateVariable(static_cast<bool*>(cs
->Variable
), var
);
836 case CommandLineArguments::VECTOR_BOOL_TYPE
:
837 this->PopulateVariable(static_cast<kwsys_stl::vector
<bool>*>(cs
->Variable
), var
);
839 case CommandLineArguments::VECTOR_INT_TYPE
:
840 this->PopulateVariable(static_cast<kwsys_stl::vector
<int>*>(cs
->Variable
), var
);
842 case CommandLineArguments::VECTOR_DOUBLE_TYPE
:
843 this->PopulateVariable(static_cast<kwsys_stl::vector
<double>*>(cs
->Variable
), var
);
845 case CommandLineArguments::VECTOR_STRING_TYPE
:
846 this->PopulateVariable(static_cast<kwsys_stl::vector
<char*>*>(cs
->Variable
), var
);
848 case CommandLineArguments::VECTOR_STL_STRING_TYPE
:
849 this->PopulateVariable(static_cast<kwsys_stl::vector
<kwsys_stl::string
>*>(cs
->Variable
), var
);
852 kwsys_ios::cerr
<< "Got unknown variable type: \"" << cs
->VariableType
<< "\"" << kwsys_ios::endl
;
853 this->Internals
->LastArgument
--;
861 } // namespace KWSYS_NAMESPACE