00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef replacedCmdUnlabledMultiArg_H_
00023 #define replacedCmdUnlabledMultiArg_H_
00024
00027
00028 #include <string>
00029 #include <vector>
00030
00031 #include <cmdLine/cmdMultiArg.h>
00032
00033 namespace MAKLogger
00034 {
00035
00041 template<class T>
00042 class ReplacedUnlabeledMultiArg : public DtCmdLine::MultiArg<T>
00043 {
00044
00045 public:
00046
00047 #ifndef __solaris__
00048
00049
00050 using DtCmdLine::MultiArg<T>::_ignoreable;
00051 using DtCmdLine::MultiArg<T>::_hasBlanks;
00052 using DtCmdLine::MultiArg<T>::_extractValue;
00053 using DtCmdLine::MultiArg<T>::_typeDesc;
00054 using DtCmdLine::MultiArg<T>::_name;
00055 using DtCmdLine::MultiArg<T>::_description;
00056 #endif
00057
00058
00059
00075 ReplacedUnlabeledMultiArg( const std::string& name,
00076 const std::string& desc,
00077 const std::string& typeDesc,
00078 bool ignoreable = false,
00079 DtCmdLine::Visitor* v = NULL );
00096 ReplacedUnlabeledMultiArg( const std::string& name,
00097 const std::string& desc,
00098 const std::string& typeDesc,
00099 DtCmdLine::CmdLineInterface& parser,
00100 bool ignoreable = false,
00101 DtCmdLine::Visitor* v = NULL );
00102
00116 ReplacedUnlabeledMultiArg( const std::string& name,
00117 const std::string& desc,
00118 const std::vector<T>& allowed,
00119 bool ignoreable = false,
00120 DtCmdLine::Visitor* v = NULL );
00121
00136 ReplacedUnlabeledMultiArg( const std::string& name,
00137 const std::string& desc,
00138 const std::vector<T>& allowed,
00139 DtCmdLine::CmdLineInterface& parser,
00140 bool ignoreable = false,
00141 DtCmdLine::Visitor* v = NULL );
00142
00151 virtual bool processArg(int* i, std::vector<std::string>& args);
00152
00157 virtual std::string shortID(const std::string& val) const;
00158
00163 virtual std::string longID(const std::string& val) const;
00164
00169 virtual void addToList( std::list<DtCmdLine::Arg*>& argList ) const;
00170 };
00171
00172 template<class T>
00173 ReplacedUnlabeledMultiArg<T>::ReplacedUnlabeledMultiArg(const std::string& name,
00174 const std::string& desc,
00175 const std::string& typeDesc,
00176 bool ignoreable,
00177 DtCmdLine::Visitor* v)
00178 : DtCmdLine::MultiArg<T>("", name, desc, false, typeDesc, v)
00179 {
00180 _ignoreable = ignoreable;
00181 }
00182
00183 template<class T>
00184 ReplacedUnlabeledMultiArg<T>::ReplacedUnlabeledMultiArg(const std::string& name,
00185 const std::string& desc,
00186 const std::string& typeDesc,
00187 DtCmdLine::CmdLineInterface& parser,
00188 bool ignoreable,
00189 DtCmdLine::Visitor* v)
00190 : DtCmdLine::MultiArg<T>("", name, desc, false, typeDesc, v)
00191 {
00192 _ignoreable = ignoreable;
00193 parser.add( this );
00194 }
00195
00196
00197 template<class T>
00198 ReplacedUnlabeledMultiArg<T>::ReplacedUnlabeledMultiArg(const std::string& name,
00199 const std::string& desc,
00200 const std::vector<T>& allowed,
00201 bool ignoreable,
00202 DtCmdLine::Visitor* v)
00203 : DtCmdLine::MultiArg<T>("", name, desc, false, allowed, v)
00204 {
00205 _ignoreable = ignoreable;
00206 }
00207
00208 template<class T>
00209 ReplacedUnlabeledMultiArg<T>::ReplacedUnlabeledMultiArg(const std::string& name,
00210 const std::string& desc,
00211 const std::vector<T>& allowed,
00212 DtCmdLine::CmdLineInterface& parser,
00213 bool ignoreable,
00214 DtCmdLine::Visitor* v)
00215 : DtCmdLine::MultiArg<T>("", name, desc, false, allowed, v)
00216 {
00217 _ignoreable = ignoreable;
00218 parser.add( this );
00219 }
00220
00221
00222 template<class T>
00223 bool ReplacedUnlabeledMultiArg<T>::processArg(int *i, std::vector<std::string>& args)
00224 {
00225
00226 if ( _hasBlanks( args[*i] ) )
00227 return false;
00228
00230
00231 _extractValue( args[*i] );
00232 return true;
00233 }
00234
00235 template<class T>
00236 std::string ReplacedUnlabeledMultiArg<T>::shortID(const std::string& val) const
00237 {
00238 std::string id = "<" + _typeDesc + "> ...";
00239
00240 return id;
00241 }
00242
00243 template<class T>
00244 std::string ReplacedUnlabeledMultiArg<T>::longID(const std::string& val) const
00245 {
00246 std::string id = "<" + _typeDesc + "> (accepted multiple times)";
00247
00248 return id;
00249 }
00250
00259
00260 template<class T>
00261 void ReplacedUnlabeledMultiArg<T>::addToList( std::list<DtCmdLine::Arg*>& argList ) const
00262 {
00263 argList.push_back( (DtCmdLine::Arg*)this );
00264 }
00265
00266 }
00267
00268 #endif