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

TUtilities.hh

解説を見る。
00001 // ============================================================================
00032 // ============================================================================
00033 #ifndef CLDAQ__TUTILITIES_HH
00034 #define CLDAQ__TUTILITIES_HH
00035 
00036 #include "Ttypes.h"
00037 
00038 
00058 class TUtilities
00059 {
00060 
00061   public:
00062     static Tstring ConvertIntegerToString( Tint i, Tint digits );
00063     static Tstring ConvertLongToString( Tlong l, Tint digits );
00064     static Tstring ConvertUnsignedLongToString( TUlong ul, Tint digits );
00065     static Tstring ConvertDoubleToString( Tdouble d, Tint precision );
00066     static Tstring ConvertFloatToString( Tfloat f, Tint precision );
00067     static Tint ConvertStringToInteger( const Tstring& nptr, Tchar** endptr, Tint base );
00068     static Tdouble ConvertStringToDouble( const Tstring& nptr, Tchar** endptr );
00069     static Tvoid ShowBitPattern( Tint bit );
00070     static Tbool FileExist( const Tstring& filename, Tint mode );
00071     static TstringList Split( const Tstring& source, const Tstring& pattern, Tint pos );
00072     static TintList Index( const Tstring& source, const Tstring& pattern, Tint pos );
00073     static TintList Size( const Tstring& source, const Tstring& pattern, Tint pos );
00074     static Tstring Substitute( const Tstring& source, const Tstring& pattern, const Tstring& substr, Tint pos );
00075     static Tstring SubstituteAll( const Tstring& source, const Tstring& pattern, const Tstring& substr, Tint pos );
00076     static Tbool IsMatch( const Tstring& source, const Tstring& pattern, Tbool igcase, Tint pos );
00077     static Tint GetNumberOfMatches( const Tstring& source, const Tstring& pattern, Tint pos );
00078     static Tstring GetSubMatch( Tint index, const Tstring& source, const Tstring& pattern, Tint pos );
00079     static TstringList GetSubMatch( const Tstring& source, const Tstring& pattern, Tint pos );
00080     static Tstring GetBaseName( const Tstring& path );
00081     static Tstring GetDirectoryName( const Tstring& path );
00082 
00083   public:
00084     friend Tstring itostr( Tint i, Tint digits = 6 );
00085     friend Tstring ltostr( Tlong l, Tint digits = 6 );
00086     friend Tstring ultostr( TUlong ul, Tint digits = 6 );
00087     friend Tstring dtostr( Tdouble d, Tint precision = 6 );
00088     friend Tstring ftostr( Tfloat f, Tint precision = 6 );
00089     friend Tint strtoi( const Tstring& nptr, Tchar** endptr = 0, Tint base = 0 );
00090     friend Tdouble strtod( const Tstring& nptr, Tchar** endptr = 0 );
00091     friend Tvoid showbit( Tint bit );
00092     friend Tbool isexist( const Tstring& filename, Tint mode = R_OK|F_OK );
00093     friend TstringList split( const Tstring& source, const Tstring& pattern = "(\t| |\\s)+", Tint pos = 0 );
00094     friend TintList index( const Tstring& source, const Tstring& pattern = "(\t| |\\s)+", Tint pos = 0 );
00095     friend TintList size( const Tstring& source, const Tstring& pattern, Tint pos = 0 );
00096     friend Tstring subst( const Tstring& source, const Tstring& pattern = "(#.*)|(//.*)", const Tstring& substr = "", Tbool all = Ttrue, Tint pos = 0 );
00097     friend Tbool match( const Tstring& source, const Tstring& pattern, Tbool igcase = Tfalse, Tint pos = 0 );
00098     friend Tint nmatch( const Tstring& source, const Tstring& pattern, Tint pos = 0 );
00099     friend Tstring submatch( Tint index, const Tstring& source, const Tstring& pattern, Tint pos = 0 );
00100     friend TstringList submatch( const Tstring& source, const Tstring& pattern, Tint pos = 0 );
00101     friend Tbool grep( const Tstring& source, const Tstring& pattern, Tbool igcase = Tfalse, Tint pos = 0 );
00102     friend Tstring basename( const Tstring& path );
00103     friend Tstring dirname( const Tstring& path );
00104  
00105 };
00106 
00107 inline Tstring itostr( Tint i, Tint digits )
00108 {
00109   return TUtilities::ConvertIntegerToString( i, digits );
00110 }
00111 
00112 inline Tstring ltostr( Tlong l, Tint digits )
00113 {
00114   return TUtilities::ConvertLongToString( l, digits );
00115 }
00116 
00117 inline Tstring ultostr( TUlong ul, Tint digits )
00118 {
00119   return TUtilities::ConvertUnsignedLongToString( ul, digits );
00120 }
00121 
00122 inline Tstring dtostr( Tdouble d, Tint precision )
00123 {
00124   return TUtilities::ConvertDoubleToString( d, precision );
00125 }
00126 
00127 inline Tstring ftostr( Tfloat f, Tint precision )
00128 {
00129   return TUtilities::ConvertFloatToString( f, precision );
00130 }
00131 
00132 inline Tint strtoi( const Tstring& nptr, Tchar** endptr, Tint base )
00133 {
00134   return TUtilities::ConvertStringToInteger( nptr, endptr, base );
00135 }
00136 
00137 inline Tdouble strtod( const Tstring& nptr, Tchar** endptr )
00138 {
00139   return TUtilities::ConvertStringToDouble( nptr, endptr );
00140 }
00141 
00142 inline Tvoid showbit( Tint bit )
00143 {
00144   TUtilities::ShowBitPattern( bit );
00145   return;
00146 }
00147 
00148 inline Tbool isexist( const Tstring& filename, Tint mode )
00149 {
00150   return TUtilities::FileExist( filename, mode );
00151 }
00152 
00153 inline TstringList split( const Tstring& source, const Tstring& pattern, Tint pos )
00154 {
00155   return TUtilities::Split( source, pattern, pos );
00156 }
00157 
00158 inline TintList index( const Tstring& source, const Tstring& pattern, Tint pos )
00159 {
00160   return TUtilities::Index( source, pattern, pos );
00161 }
00162 
00163 inline TintList size( const Tstring& source, const Tstring& pattern, Tint pos )
00164 {
00165   return TUtilities::Size( source, pattern, pos );
00166 }
00167 
00168 inline Tstring subst( const Tstring& source, const Tstring& pattern, const Tstring& substr, Tbool all, Tint pos )
00169 {
00170   if ( all ) {
00171     return TUtilities::SubstituteAll( source, pattern, substr, pos );
00172   } else {
00173     return TUtilities::Substitute( source, pattern, substr, pos );
00174   }
00175 }
00176 
00177 inline Tbool match( const Tstring& source, const Tstring& pattern, Tbool igcase, Tint pos )
00178 {
00179   return TUtilities::IsMatch( source, pattern, igcase, pos );
00180 }
00181 
00182 inline Tbool grep( const Tstring& source, const Tstring& pattern, Tbool igcase, Tint pos )
00183 {
00184   return TUtilities::IsMatch( source, pattern, igcase, pos );
00185 }
00186 
00187 inline Tstring submatch( Tint index, const Tstring& source, const Tstring& pattern, Tint pos )
00188 {
00189   return TUtilities::GetSubMatch( index, source, pattern, pos );
00190 }
00191 
00192 inline TstringList submatch( const Tstring& source, const Tstring& pattern, Tint pos )
00193 {
00194   return TUtilities::GetSubMatch( source, pattern, pos );
00195 }
00196 
00197 inline Tstring basename( const Tstring& path )
00198 {
00199   return TUtilities::GetBaseName( path );
00200 }
00201 
00202 inline Tstring dirname( const Tstring& path )
00203 {
00204   return TUtilities::GetDirectoryName( path );
00205 }
00206 
00207 #endif

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