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

TUtilities.hh

解説を見る。
00001 // ============================================================================
00019 // ============================================================================
00020 #ifndef __TUTILITIES_HH
00021 #define __TUTILITIES_HH
00022 
00023 #include "Ttypes.h"
00024 
00025 
00045 class TUtilities
00046 {
00047 
00048   public:
00049     static Tstring ConvertIntegerToString( Tint i, Tint digits );
00050     static Tstring ConvertLongToString( Tlong l, Tint digits );
00051     static Tstring ConvertUnsignedLongToString( TUlong ul, Tint digits );
00052     static Tstring ConvertDoubleToString( Tdouble d, Tint precision );
00053     static Tstring ConvertFloatToString( Tfloat f, Tint precision );
00054     static Tint ConvertStringToInteger( const Tstring& nptr, Tchar** endptr, Tint base );
00055     static Tdouble ConvertStringToDouble( const Tstring& nptr, Tchar** endptr );
00056     static Tvoid ShowBitPattern( Tint bit );
00057     static Tbool FileExist( const Tstring& filename );
00058     static TstringList Split( const Tstring& source, const Tstring& pattern, Tint pos );
00059     static TintList Indexes( const Tstring& source, const Tstring& pattern, Tint pos );
00060     static TintList Sizes( const Tstring& source, const Tstring& pattern, Tint pos );
00061     static Tstring Substitute( const Tstring& source, const Tstring& pattern, const Tstring& substr, Tint pos );
00062     static Tstring SubstituteAll( const Tstring& source, const Tstring& pattern, const Tstring& substr, Tint pos );
00063     static Tbool IsMatch( const Tstring& source, const Tstring& pattern, Tbool igcase, Tint pos );
00064     static Tstring GetBaseName( const Tstring& path );
00065     static Tstring GetDirectoryName( const Tstring& path );
00066 
00067   public:
00068     friend Tstring itostr( Tint i, Tint digits = 6 );
00069     friend Tstring ltostr( Tlong l, Tint digits = 6 );
00070     friend Tstring ultostr( TUlong ul, Tint digits = 6 );
00071     friend Tstring dtostr( Tdouble d, Tint precision = 6 );
00072     friend Tstring ftostr( Tfloat f, Tint precision = 6 );
00073     friend Tint strtoi( const Tstring& nptr, Tchar** endptr = 0, Tint base = 0 );
00074     friend Tdouble strtod( const Tstring& nptr, Tchar** endptr = 0 );
00075     friend Tvoid showbit( Tint bit );
00076     friend Tbool isexist( const Tstring& filename );
00077     friend TstringList split( const Tstring& source, const Tstring& pattern = "[\t+| +]", Tint pos = 0 );
00078     friend TintList index( const Tstring& source, const Tstring& pattern, Tint pos = 0 );
00079     friend TintList size( const Tstring& source, const Tstring& pattern, Tint pos = 0 );
00080     friend Tstring subst( const Tstring& source, const Tstring& pattern, Tstring& substr, Tbool all = Ttrue, Tint pos = 0 );
00081     friend Tbool grep( const Tstring& source, const Tstring& pattern, Tbool igcase = Tfalse, Tint pos = 0 );
00082     friend Tstring basename( const Tstring& path );
00083     friend Tstring dirname( const Tstring& path );
00084  
00085 };
00086 
00087 inline Tstring itostr( Tint i, Tint digits )
00088 {
00089   return TUtilities::ConvertIntegerToString( i, digits );
00090 }
00091 
00092 inline Tstring ltostr( Tlong l, Tint digits )
00093 {
00094   return TUtilities::ConvertLongToString( l, digits );
00095 }
00096 
00097 inline Tstring ultostr( TUlong ul, Tint digits )
00098 {
00099   return TUtilities::ConvertUnsignedLongToString( ul, digits );
00100 }
00101 
00102 inline Tstring dtostr( Tdouble d, Tint precision )
00103 {
00104   return TUtilities::ConvertDoubleToString( d, precision );
00105 }
00106 
00107 inline Tstring ftostr( Tfloat f, Tint precision )
00108 {
00109   return TUtilities::ConvertFloatToString( f, precision );
00110 }
00111 
00112 inline Tint strtoi( const Tstring& nptr, Tchar** endptr, Tint base )
00113 {
00114   return TUtilities::ConvertStringToInteger( nptr, endptr, base );
00115 }
00116 
00117 inline Tdouble strtod( const Tstring& nptr, Tchar** endptr )
00118 {
00119   return TUtilities::ConvertStringToDouble( nptr, endptr );
00120 }
00121 
00122 inline Tvoid showbit( Tint bit )
00123 {
00124   TUtilities::ShowBitPattern( bit );
00125   return;
00126 }
00127 
00128 inline Tbool isexist( const Tstring& filename )
00129 {
00130   return TUtilities::FileExist( filename );
00131 }
00132 
00133 inline TstringList split( const Tstring& source, const Tstring& pattern, Tint pos )
00134 {
00135   return TUtilities::Split( source, pattern, pos );
00136 }
00137 
00138 inline TintList index( const Tstring& source, const Tstring& pattern, Tint pos )
00139 {
00140   return TUtilities::Indexes( source, pattern, pos );
00141 }
00142 
00143 inline TintList size( const Tstring& source, const Tstring& pattern, Tint pos )
00144 {
00145   return TUtilities::Sizes( source, pattern, pos );
00146 }
00147 
00148 inline Tstring subst( const Tstring& source, const Tstring& pattern, const Tstring& substr, Tbool all, Tint pos )
00149 {
00150   if ( all ) {
00151     return TUtilities::SubstituteAll( source, pattern, substr, pos );
00152   } else {
00153     return TUtilities::Substitute( source, pattern, substr, pos );
00154   }
00155 }
00156 
00157 inline Tbool grep( const Tstring& source, const Tstring& pattern, Tbool igcase, Tint pos )
00158 {
00159   return TUtilities::IsMatch( source, pattern, igcase, pos );
00160 }
00161 
00162 inline Tstring basename( const Tstring& path )
00163 {
00164   return TUtilities::GetBaseName( path );
00165 }
00166 
00167 inline Tstring dirname( const Tstring& path )
00168 {
00169   return TUtilities::GetDirectoryName( path );
00170 }
00171 
00172 #endif

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