VR-Link API Documentation for HLA 1516
cmdUnlabeledMultiArg.h
Go to the documentation of this file.
00001 
00002 /****************************************************************************** 
00003  * 
00004  *  file:  UnlabeledMultiArg.h
00005  * 
00006  *  Copyright (c) 2003, Michael E. Smoot.
00007  *  All rights reverved.
00008  * 
00009  *  See the file COPYING in the top directory of this distribution for
00010  *  more information.
00011  *  
00012  *  THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 
00013  *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
00014  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
00015  *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
00016  *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
00017  *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
00018  *  DEALINGS IN THE SOFTWARE.  
00019  *  
00020  *****************************************************************************/ 
00021 
00022 
00023 #ifndef DtCmdLine_MULTIPLE_UNLABELED_ARGUMENT_H
00024 #define DtCmdLine_MULTIPLE_UNLABELED_ARGUMENT_H
00025 
00029 
00030 #include <string>
00031 #include <vector>
00032 
00033 #include "cmdMultiArg.h"
00034 
00035 #ifdef DtUSE_UTILITIES_NAMESPACE
00036 namespace DtUSE_UTILITIES_NAMESPACE
00037 {
00038 #endif
00039 
00040    namespace DtCmdLine {
00041 
00047 
00048       template<class T>
00049          class UnlabeledMultiArg : public MultiArg<T>
00050       {
00051 #ifndef __solaris__
00052 
00053 
00054          using MultiArg<T>::_ignoreable;
00055          using MultiArg<T>::_hasBlanks;
00056          using MultiArg<T>::_extractValue;
00057          using MultiArg<T>::_typeDesc;
00058          using MultiArg<T>::_name;
00059          using MultiArg<T>::_description;
00060 #endif
00061 
00062       public:
00063 
00079          UnlabeledMultiArg( const std::string& name,
00080                             const std::string& desc,
00081                             const std::string& typeDesc,
00082                             bool ignoreable = false,
00083                             Visitor* v = NULL );
00100          UnlabeledMultiArg( const std::string& name,
00101                             const std::string& desc,
00102                             const std::string& typeDesc,
00103                             CmdLineInterface& parser,
00104                             bool ignoreable = false,
00105                             Visitor* v = NULL );
00106 
00120          UnlabeledMultiArg( const std::string& name,
00121                             const std::string& desc,
00122                             const std::vector<T>& allowed,
00123                             bool ignoreable = false,
00124                             Visitor* v = NULL );
00125 
00140          UnlabeledMultiArg( const std::string& name, 
00141                             const std::string& desc, 
00142                             const std::vector<T>& allowed,
00143                             CmdLineInterface& parser,
00144                             bool ignoreable = false,
00145                             Visitor* v = NULL );
00146 
00155          virtual bool processArg(int* i, std::vector<std::string>& args); 
00156 
00161          virtual std::string shortID(const std::string& val="val") const;
00162 
00167          virtual std::string longID(const std::string& val="val") const;
00168 
00173          virtual bool operator==(const Arg& a) const;
00174 
00179          virtual void addToList( std::list<Arg*>& argList ) const;
00180       };
00181 
00182       template<class T>
00183          UnlabeledMultiArg<T>::UnlabeledMultiArg(const std::string& name, 
00184                                                  const std::string& desc, 
00185                                                  const std::string& typeDesc,
00186                                                  bool ignoreable,
00187                                                  Visitor* v)
00188          : MultiArg<T>("", name, desc,  false, typeDesc, v)
00189          { 
00190             _ignoreable = ignoreable;
00191          }
00192 
00193       template<class T>
00194          UnlabeledMultiArg<T>::UnlabeledMultiArg(const std::string& name, 
00195                                                  const std::string& desc, 
00196                                                  const std::string& typeDesc,
00197                                                  CmdLineInterface& parser,
00198                                                  bool ignoreable,
00199                                                  Visitor* v)
00200          : MultiArg<T>("", name, desc,  false, typeDesc, v)
00201          { 
00202             _ignoreable = ignoreable;
00203             parser.add( this );
00204          }
00205 
00206 
00207       template<class T>
00208          UnlabeledMultiArg<T>::UnlabeledMultiArg(const std::string& name, 
00209                                                  const std::string& desc, 
00210                                                  const std::vector<T>& allowed,
00211                                                  bool ignoreable,
00212                                                  Visitor* v)
00213          : MultiArg<T>("", name, desc,  false, allowed, v)
00214          { 
00215             _ignoreable = ignoreable;
00216          }
00217 
00218       template<class T>
00219          UnlabeledMultiArg<T>::UnlabeledMultiArg(const std::string& name, 
00220                                                  const std::string& desc, 
00221                                                  const std::vector<T>& allowed,
00222                                                  CmdLineInterface& parser,
00223                                                  bool ignoreable,
00224                                                  Visitor* v)
00225          : MultiArg<T>("", name, desc,  false, allowed, v)
00226          { 
00227             _ignoreable = ignoreable;
00228             parser.add( this );
00229          }
00230 
00231 
00232       template<class T>
00233          bool UnlabeledMultiArg<T>::processArg(int *i, std::vector<std::string>& args) 
00234          {
00235 
00236             if ( _hasBlanks( args[*i] ) )
00237                return false;
00238 
00240 
00241             _extractValue( args[*i] );
00242             return true;
00243          }
00244 
00245       template<class T>
00246          std::string UnlabeledMultiArg<T>::shortID(const std::string& val) const
00247          {
00248             std::string id = "<" + _typeDesc + "> ...";
00249 
00250             return id;
00251          }
00252 
00253       template<class T>
00254          std::string UnlabeledMultiArg<T>::longID(const std::string& val) const
00255          {
00256             std::string id = "<" + _typeDesc + ">  (accepted multiple times)";
00257 
00258             return id;
00259          }
00260 
00261       template<class T>
00262          bool UnlabeledMultiArg<T>::operator==(const Arg& a) const
00263          {
00264             if ( _name == a.getName() || _description == a.getDescription() )
00265                return true;
00266             else
00267                return false;
00268          }
00269 
00270       template<class T>
00271          void UnlabeledMultiArg<T>::addToList( std::list<Arg*>& argList ) const
00272          {
00273             argList.push_back( (Arg*)this );
00274          }
00275 
00276    }
00277 
00278 #ifdef DtUSE_UTILITIES_NAMESPACE
00279 }     
00280 #endif
00281 
00282 #endif

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)