メインページ   モジュール   クラス階層   アルファベット順一覧   構成   ファイル一覧   構成メンバ   ファイルメンバ   関連ページ    

TArgument.hh

解説を見る。
00001 // ============================================================================
00021 // ============================================================================
00022 #ifndef __TARGUMENT_HH
00023 #define __TARGUMENT_HH
00024 
00025 #include "Tglobals.h"
00026 #include "TOptionTable.hh"
00027 #include "TOptionMap.hh"
00028 
00029 
00049 class TArgument
00050 {
00051 
00052   private:
00053     Tint theNumberOfOriginalArguments;
00054     Tchar** theOriginalArguments;
00055     TOptionTable theOptionTable;
00056     TOptionMap theOptionMap;
00057     Tstring theProgramName;
00058     Tstring theDirectoryName;
00059     TstringList theElements;
00060     Tint theNumberOfElements;
00061     Tstring theUsage;
00062 
00063   public:
00064     TArgument( Tint argc, Tchar** argv, const Tstring& usage = "" );
00065     TArgument( Tint argc, Tchar** argv, const TOptionTable& table, const Tstring& usage = "" );
00066     ~TArgument();
00067 
00068   public:
00069     Tvoid Analyse();
00070     Tvoid ShowUsage() const;
00071     Tvoid ShowVersion() const;
00072     Tvoid ShowHelp() const;
00073 
00074   public:
00075     Tstring operator[]( Tint index ) const;
00076     Tstring operator[]( const TOption& option ) const;
00077     Tstring operator[]( const Tstring& optionname ) const;
00078 
00079   public:
00080     friend Tostream& operator<<( Tostream& tos, const TArgument& right );
00081 
00082   public:
00083     Tint GetNumberOfOriginalArguments() const;
00084     Tchar** GetOriginalArguments() const;
00085     const TOptionTable& GetOptionTable() const;
00086     const TOptionMap& GetOptionMap() const;
00087     const Tstring& GetProgramName() const;
00088     const Tstring& GetDirectoryName() const;
00089     const TstringList& GetElements() const;
00090     Tint GetNumberOfElements() const;
00091     const Tstring& GetUsage() const;
00092     Tvoid SetUsage( const Tstring& usage );
00093 
00094   public:
00095     Tbool HasOption( const TOption& option ) const;
00096     Tbool HasOption( const Tstring& optionname ) const;
00097     Tstring GetParameter( Tint index ) const;
00098     Tstring GetParameter( const Tstring& optionname ) const;
00099     Tstring GetParameter( const TOption& option ) const;
00100     Tint GetIntegerParameter( Tint index ) const;
00101     Tint GetIntegerParameter( const Tstring& optionname ) const;
00102     Tint GetIntegerParameter( const TOption& option ) const;
00103     Tdouble GetDoubleParameter( Tint index ) const;
00104     Tdouble GetDoubleParameter( const Tstring& optionname ) const;
00105     Tdouble GetDoubleParameter( const TOption& option ) const;
00106     TintList GetIntegerElements() const;
00107     TdoubleList GetDoubleElements() const;
00108     Tstring GetElement( Tint index ) const;
00109     Tint GetIntegerElement( Tint index ) const;
00110     Tdouble GetDoubleElement( Tint index ) const;
00111 
00112 };
00113 
00114 inline Tint TArgument::GetNumberOfOriginalArguments() const
00115 {
00116   return theNumberOfOriginalArguments;
00117 }
00118 
00119 inline Tchar** TArgument::GetOriginalArguments() const
00120 {
00121   return theOriginalArguments;
00122 }
00123 
00124 inline const TOptionTable& TArgument::GetOptionTable() const
00125 {
00126   return theOptionTable;
00127 }
00128 
00129 inline const TOptionMap& TArgument::GetOptionMap() const
00130 {
00131   return theOptionMap;
00132 }
00133 
00134 inline const Tstring& TArgument::GetProgramName() const
00135 {
00136   return theProgramName;
00137 }
00138 
00139 inline const Tstring& TArgument::GetDirectoryName() const
00140 {
00141   return theDirectoryName;
00142 }
00143 
00144 inline const TstringList& TArgument::GetElements() const
00145 {
00146   return theElements;
00147 }
00148 
00149 inline Tint TArgument::GetNumberOfElements() const
00150 {
00151   return theNumberOfElements;
00152 }
00153 
00154 inline Tbool TArgument::HasOption( const TOption& option ) const
00155 {
00156   return theOptionMap.HasOption( option );
00157 }
00158 
00159 inline Tbool TArgument::HasOption( const Tstring& optionname ) const
00160 {
00161   return theOptionMap.HasOption( optionname );
00162 }
00163 
00164 inline Tstring TArgument::GetParameter( Tint index ) const
00165 {
00166   return theOptionMap.GetParameter( index );
00167 }
00168 
00169 inline Tstring TArgument::GetParameter( const Tstring& optionname ) const
00170 {
00171   return theOptionMap.GetParameter( optionname );
00172 }
00173 
00174 inline Tstring TArgument::GetParameter( const TOption& option ) const
00175 {
00176   return theOptionMap.GetParameter( option );
00177 }
00178 
00179 inline Tint TArgument::GetIntegerParameter( Tint index ) const
00180 {
00181   return strtoi( GetParameter( index ) );
00182 }
00183 
00184 inline Tint TArgument::GetIntegerParameter( const Tstring& optionname ) const
00185 {
00186   return strtoi( GetParameter( optionname ) );
00187 }
00188 
00189 inline Tint TArgument::GetIntegerParameter( const TOption& option ) const
00190 {
00191   return strtoi( GetParameter( option ) );
00192 }
00193 
00194 inline Tdouble TArgument::GetDoubleParameter( Tint index ) const
00195 {
00196   return strtod( GetParameter( index ) );
00197 }
00198 
00199 inline Tdouble TArgument::GetDoubleParameter( const Tstring& optionname ) const
00200 {
00201   return strtod( GetParameter( optionname ) );
00202 }
00203 
00204 inline Tdouble TArgument::GetDoubleParameter( const TOption& option ) const
00205 {
00206   return strtod( GetParameter( option ) );
00207 }
00208 
00209 inline TintList TArgument::GetIntegerElements() const
00210 {
00211   TintList retval;
00212   for ( Tint i = 0; i < theNumberOfElements; i ++ ) {
00213     retval.push_back( strtoi( theElements[ i ] ) );
00214   }
00215   return retval;
00216 }
00217 
00218 inline TdoubleList TArgument::GetDoubleElements() const
00219 {
00220   TdoubleList retval;
00221   for ( Tint i = 0; i < theNumberOfElements; i ++ ) {
00222     retval.push_back( strtod( theElements[ i ] ) );
00223   }
00224   return retval;
00225 }
00226 
00227 inline Tstring TArgument::GetElement( Tint index ) const
00228 {
00229   Tstring retval = "";
00230   Tint listlen = (Tint)theElements.size();
00231   if ( index >= 0 && index < listlen && !theElements.empty() ) {
00232     retval = theElements[ index ];
00233   }
00234   return retval;
00235 }
00236 
00237 inline Tint TArgument::GetIntegerElement( Tint index ) const
00238 {
00239   return strtoi( GetElement( index ) );
00240 }
00241 
00242 inline Tdouble TArgument::GetDoubleElement( Tint index ) const
00243 {
00244   return strtod( GetElement( index ) );
00245 }
00246 
00247 inline Tstring TArgument::operator[]( Tint index ) const
00248 {
00249   return GetElement( index );
00250 }
00251 
00252 inline Tstring TArgument::operator[]( const TOption& option ) const
00253 {
00254   return GetParameter( option );
00255 }
00256 
00257 inline Tstring TArgument::operator[]( const Tstring& optionname ) const
00258 {
00259   return GetParameter( optionname );
00260 }
00261 
00262 inline const Tstring& TArgument::GetUsage() const
00263 {
00264   return theUsage;
00265 }
00266 
00267 inline Tvoid TArgument::SetUsage( const Tstring& usage )
00268 {
00269   theUsage = usage;
00270   return;
00271 }
00272 
00273 #endif

CLDAQ - a Class Library for Data AcQuisition (Version 1.11.0)
Go IWAI <goiwai@users.sourceforge.jp>