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

TArgument.hh

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

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