00001 // This is core/vil/vil_stream_url.h 00002 #ifndef vil_stream_url_h_ 00003 #define vil_stream_url_h_ 00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE 00005 #pragma interface 00006 #endif 00007 //: 00008 // \file 00009 // \brief open an URL 00010 // \author fsm 00011 00012 #include <vil/vil_stream.h> 00013 00014 //: open an URL 00015 00016 class vil_stream_url : public vil_stream 00017 { 00018 vil_stream *u_; // underlying stream 00019 00020 // Make private to prevent use. 00021 vil_stream_url(vil_stream_url const &): vil_stream() { } 00022 vil_stream_url& operator=(vil_stream_url const &) { return *this; } 00023 public: 00024 vil_stream_url(char const *); 00025 ~vil_stream_url(); 00026 00027 // implement virtual vil_stream interface: 00028 bool ok() const { return u_ && u_->ok(); } 00029 vil_streampos write(void const *buf, vil_streampos n) { return u_ ? u_->write(buf, n) : 0L; } 00030 // strictly speaking, writes should fail, but that isn't useful in any way. 00031 vil_streampos read(void *buf, vil_streampos n) { return u_ ? u_->read(buf, n) : 0L; } 00032 vil_streampos tell() const { return u_ ? u_->tell() : (vil_streampos)(-1L); } 00033 void seek(vil_streampos position) { if (u_) u_->seek(position); } 00034 00035 vil_streampos file_size() const { return u_ ? u_->file_size() : 0L; } 00036 }; 00037 00038 #endif // vil_stream_url_h_