00001 // ============================================================================ 00021 // ============================================================================ 00022 #ifndef CLDAQ__TOPTION_HH 00023 #define CLDAQ__TOPTION_HH 00024 00025 #include "Tglobals.h" 00026 00027 00047 class TOption 00048 { 00049 00050 public: 00051 enum { tNeedNot = 0, tNeed = 1, tEither = 2 }; 00052 00053 private: 00054 Tstring theLongOption; 00055 Tstring theShortOption; 00056 Tint theArgumentStyle; 00057 Tstring theDescription; 00058 00059 public: 00060 TOption( const Tstring& longoption, const Tstring& shortoption = "", Tint argstyle = tNeedNot, const Tstring& desc = "" ); 00061 TOption( const Tstring& longoption, Tint argstyle, const Tstring& shortoption = "", const Tstring& desc = "" ); 00062 TOption( const TOption& right ); 00063 ~TOption(); 00064 00065 public: 00066 const TOption& operator=( const TOption& right ); 00067 Tbool operator==( const TOption& right ) const; 00068 Tbool operator!=( const TOption& right ) const; 00069 Tbool operator==( const Tstring& right ) const; 00070 Tbool operator!=( const Tstring& right ) const; 00071 00072 public: 00073 friend Tostream& operator<<( Tostream& tos, const TOption& right ); 00074 00075 public: 00076 Tbool NeedParameter() const; 00077 Tbool NeedNotParameter() const; 00078 Tbool EitherNeedOrNot() const; 00079 00080 public: 00081 const Tstring& GetLongOption() const; 00082 const Tstring& GetShortOption() const; 00083 Tint GetArgumentStyle() const; 00084 const Tstring& GetDescription() const; 00085 Tvoid SetLongOption( const Tstring& longoption ); 00086 Tvoid SetShortOption( const Tstring& shortoption ); 00087 Tvoid SetArgumentStyle( Tint argstyle ); 00088 Tvoid SetDescription( const Tstring& desc ); 00089 00090 private: 00091 Tvoid initialize(); 00092 00093 }; 00094 00095 inline const Tstring& TOption::GetLongOption() const 00096 { 00097 return theLongOption; 00098 } 00099 00100 inline const Tstring& TOption::GetShortOption() const 00101 { 00102 return theShortOption; 00103 } 00104 00105 inline Tint TOption::GetArgumentStyle() const 00106 { 00107 return theArgumentStyle; 00108 } 00109 00110 inline const Tstring& TOption::GetDescription() const 00111 { 00112 return theDescription; 00113 } 00114 00115 inline Tvoid TOption::SetLongOption( const Tstring& longoption ) 00116 { 00117 theLongOption = longoption; 00118 initialize(); 00119 return; 00120 } 00121 00122 inline Tvoid TOption::SetShortOption( const Tstring& shortoption ) 00123 { 00124 theShortOption = shortoption; 00125 initialize(); 00126 return; 00127 } 00128 00129 inline Tvoid TOption::SetArgumentStyle( Tint argstyle ) 00130 { 00131 theArgumentStyle = argstyle; 00132 initialize(); 00133 return; 00134 } 00135 00136 inline Tvoid TOption::SetDescription( const Tstring& desc ) 00137 { 00138 theDescription = desc; 00139 initialize(); 00140 return; 00141 } 00142 00143 #endif