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

TObjectFile.hh

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

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