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

TObjectFile.hh

解説を見る。
00001 // =====================================================================
00048 // =====================================================================
00049 #ifndef CLDAQ__TOBJECTFILE_HH
00050 #define CLDAQ__TOBJECTFILE_HH
00051 
00052 #include "Tglobals.h"
00053 #include "TFileProperty.hh"
00054 
00055 
00075 class TObjectFile
00076 {
00077 
00078   public:
00079     enum { 
00080       ERROR = -1
00081     };
00082 
00083     enum { 
00084       tSeekBegin = SEEK_SET, 
00085       tSeekCurrent = SEEK_CUR, 
00086       tSeekEnd = SEEK_END
00087     };
00088 
00089   protected:
00090     Tstring theFileName;
00091     Tstring theMode;
00092     TFileStream* theFileStream;
00093     TFileProperty theFileProperty;
00094 
00095   public:
00096     TObjectFile( const Tstring& filename, const Tstring& mode );
00097 
00098   protected:
00099     virtual ~TObjectFile();
00100 
00101   public:
00102     const Tstring& GetFileName() const;
00103     const Tstring& GetMode() const;
00104     TFileStream* GetFileStream() const;
00105     Tvoid SetFileName( const Tstring& filename );
00106     Tvoid SetMode( const Tstring& mode );
00107     const TFileProperty& GetFileProperty() const;
00108 
00109   public:
00110     //inline const Tvoid* SetFileStream() const;
00111     Tvoid SetOffset( Tint offset, Tint whence = tSeekCurrent );
00112     Tint GetOffset();
00113     Tbool IsEnd() const;
00114     Tbool IsError() const;
00115 
00116     // とりあえずファイルのみの実装
00118     Tint GetStreamSize() const;
00119 
00121     Tint Size() const;
00122 
00124     Tint FindDataRecord( const Tstring& id, Tint offset = 0 ) const;
00125 
00127     Tint FindDataRecord( Tint index, Tint offset = 0 ) const;
00128 
00130     Tint Find( const Tstring& id, Tint offset = 0 ) const;
00131 
00133     Tint Find( Tint index, Tint offset = 0 ) const;
00134 
00135 };
00136 
00137 inline const Tstring& TObjectFile::GetFileName() const
00138 { 
00139   return theFileName;
00140 }
00141 
00142 inline const Tstring& TObjectFile::GetMode() const
00143 { 
00144   return theMode;
00145 }
00146 
00147 inline TFileStream* TObjectFile::GetFileStream() const
00148 {
00149   return theFileStream;
00150 }
00151 
00152 inline Tvoid TObjectFile::SetFileName( const Tstring& filename )
00153 {
00154   theFileName = filename;
00155   return;
00156 }
00157 
00158 inline Tvoid TObjectFile::SetMode( const Tstring& mode )
00159 {
00160   // reopenしなくては
00161   theMode = mode;
00162   return;
00163 }
00164 
00165 inline Tvoid TObjectFile::SetOffset( Tint offset, Tint whence )
00166 {
00167   fseek( theFileStream, (Tlong)offset, whence );
00168   return;
00169 }
00170 
00171 inline Tint TObjectFile::GetOffset()
00172 {
00173   return (Tint)( ftell( theFileStream ) );
00174 }
00175 
00176 inline const TFileProperty& TObjectFile::GetFileProperty() const
00177 {
00178   return theFileProperty;
00179 }
00180 
00181 inline Tbool TObjectFile::IsEnd() const
00182 {
00183   return ( feof( theFileStream ) != 0 );
00184 }
00185 
00186 inline Tbool TObjectFile::IsError() const
00187 {
00188   return ( ferror( theFileStream ) != 0 );
00189 }
00190 
00191 inline Tint TObjectFile::Find( const Tstring& id, Tint offset ) const
00192 {
00193   return FindDataRecord( id, offset );
00194 }
00195 
00196 inline Tint TObjectFile::Find( Tint index, Tint offset ) const
00197 {
00198   return FindDataRecord( index, offset );
00199 }
00200 
00201 #endif

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