00001 // This is core/vil/vil_stream_fstream.h 00002 #ifndef vil_stream_fstream_h_ 00003 #define vil_stream_fstream_h_ 00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE 00005 #pragma interface 00006 #endif 00007 00008 #ifdef VIL_USE_FSTREAM64 00009 #include <vil/vil_stream_fstream64.h> 00010 #endif //VIL_USE_FSTREAM64 00011 00012 //: 00013 // \file 00014 // \brief A vil_stream implementation using vcl_fstream 00015 // \author awf@robots.ox.ac.uk 00016 // \date 16 Feb 00 00017 00018 #include <vcl_fstream.h> 00019 #include <vil/vil_stream.h> 00020 #include <vxl_config.h> 00021 00022 //: A vil_stream implementation using vcl_fstream 00023 class vil_stream_fstream : public vil_stream 00024 { 00025 public: 00026 vil_stream_fstream(char const* filename, char const* mode); 00027 00028 #if defined(VCL_WIN32) && VXL_USE_WIN_WCHAR_T 00029 vil_stream_fstream(wchar_t const* filename, char const* mode); 00030 #endif 00031 00032 // implement virtual vil_stream interface: 00033 bool ok() const { return f_.good(); } 00034 vil_streampos write(void const* buf, vil_streampos n); 00035 vil_streampos read(void* buf, vil_streampos n); 00036 vil_streampos tell() const; 00037 void seek(vil_streampos position); 00038 00039 vil_streampos file_size() const; 00040 00041 protected: 00042 ~vil_stream_fstream(); 00043 00044 // There are a (very few) occasions when access to the underlying stream is useful 00045 vcl_fstream & underlying_stream() {return f_;} 00046 private: 00047 vcl_ios_openmode flags_; 00048 mutable vcl_fstream f_; 00049 int id_; 00050 mutable vil_streampos end_; 00051 }; 00052 00053 #endif // vil_stream_fstream_h_