00001 #ifndef OBT_OPTION_ARG_EXTRA_H
00002 #define OBT_OPTION_ARG_EXTRA_H
00003
00004 #include "OBTOptionArg.h"
00005 #include "OBTOptionArgHandler.h"
00006 #include <vector>
00007
00008 namespace OBT
00009 {
00010
00030 class OBT_API OptionLastArg : public OptionArg
00031 {
00032 public:
00033 OptionLastArg( const std::string& helpMsg ) : OptionArg( "<last arg>", helpMsg ), _prm() {}
00034 virtual ~OptionLastArg() {}
00035 virtual bool argMatch() ;
00036 virtual bool parseArg() { return true ; }
00037 const std::string& getPrm() const { return _prm ; }
00038 protected:
00039 std::string _prm ;
00040 } ;
00041
00068 class OBT_API OptionFlag : public OptionArg
00069 {
00070 public:
00071 OptionFlag( const std::string& flagName, const std::string& helpMsg ) : OptionArg( flagName, helpMsg ) {}
00072 virtual ~OptionFlag() {}
00073 virtual bool parseArg() ;
00074 } ;
00075
00115 class OBT_API OptionNPrm : public OptionArg
00116 {
00117 public:
00118 OptionNPrm( const std::string& flagName, const std::string& helpMsg,
00119 const std::string prmMsg, int n = 1 )
00120 : OptionArg( flagName, helpMsg ), _prmMsg( prmMsg ), _n( n ) {}
00121 virtual ~OptionNPrm() {}
00122 virtual bool parseArg() ;
00123 virtual std::string getHelp() const { return _flagName + " " + _prmMsg + ": " + _helpMsg ; }
00129 std::string getPrm( int i = 0 ) const { return _flag && 0 <= i && i < _n ? _prm[ i ] : "" ; }
00130 protected :
00131 std::string _prmMsg ;
00132 int _n ;
00133 std::vector< std::string > _prm ;
00134 } ;
00135
00166 class OBT_API OptionMultiNPrm : public OptionArg
00167 {
00168 public:
00169 OptionMultiNPrm( const std::string& flagName, const std::string& helpMsg,
00170 const std::string& prmMsg, int n = 1 ) : OptionArg( flagName, helpMsg ), _prmMsg( prmMsg ), _n( n ) {}
00171 virtual ~OptionMultiNPrm() {}
00172 virtual bool parseArg() ;
00173 virtual void reset() { _prm.clear() ; }
00174 virtual std::string getHelp() const { return _flagName + " " + _prmMsg + ": " + _helpMsg ; }
00177 int getNbOptions() const { return _prm.size() ; }
00184 std::string getPrm( int i, int j = 0 ) const { return 0 <= i && i < (int)_prm.size() && 0 <= j && j < _n ? _prm[ i ][ j ] : "" ; }
00185 protected :
00186 std::string _prmMsg ;
00187 int _n ;
00188 std::vector< std::vector< std::string > > _prm ;
00189 } ;
00190
00191 }
00192
00193 #endif // OBT_OPTION_ARG_EXTRA_H