vil_stream_url.h
Go to the documentation of this file.
1 // This is core/vil/vil_stream_url.h
2 #ifndef vil_stream_url_h_
3 #define vil_stream_url_h_
4 //:
5 // \file
6 // \brief open an URL
7 // \author fsm
8 
9 #include <vil/vil_stream.h>
10 
11 //: open an URL
12 
13 class vil_stream_url : public vil_stream
14 {
15  vil_stream *u_; // underlying stream
16 
17  // Make private to prevent use.
19  vil_stream_url& operator=(vil_stream_url const &) { return *this; }
20  public:
21  vil_stream_url(char const *);
22  ~vil_stream_url() override;
23 
24  // implement virtual vil_stream interface:
25  bool ok() const override { return u_ && u_->ok(); }
26  vil_streampos write(void const *buf, vil_streampos n) override { return u_ ? u_->write(buf, n) : 0L; }
27  // strictly speaking, writes should fail, but that isn't useful in any way.
28  vil_streampos read(void *buf, vil_streampos n) override { return u_ ? u_->read(buf, n) : 0L; }
29  vil_streampos tell() const override { return u_ ? u_->tell() : (vil_streampos)(-1L); }
30  void seek(vil_streampos position) override { if (u_) u_->seek(position); }
31 
32  vil_streampos file_size() const override { return u_ ? u_->file_size() : 0L; }
33 };
34 
35 #endif // vil_stream_url_h_
Stream interface for VIL image loaders.
bool ok() const override
Return false if the stream is broken.
vil_stream_url(vil_stream_url const &)
virtual vil_streampos tell() const =0
Return file pointer.
virtual vil_streampos write(void const *buf, vil_streampos n)=0
Write n bytes from buf. Returns number of bytes written.
vil_streampos read(void *buf, vil_streampos n) override
Read n bytes into buf. Returns number of bytes read.
vil_streampos file_size() const override
Amount of data in the stream.
vil_stream_url & operator=(vil_stream_url const &)
virtual void seek(vil_streampos position)=0
Goto file pointer.
virtual vil_streampos read(void *buf, vil_streampos n)=0
Read n bytes into buf. Returns number of bytes read.
Stream interface for VIL image loaders.
Definition: vil_stream.h:21
void seek(vil_streampos position) override
Goto file pointer.
vil_stream * u_
~vil_stream_url() override
virtual bool ok() const =0
Return false if the stream is broken.
vxl_int_32 vil_streampos
Definition: vil_stream.h:16
virtual vil_streampos file_size() const =0
Amount of data in the stream.
vil_streampos tell() const override
Return file pointer.
open an URL.
vil_streampos write(void const *buf, vil_streampos n) override
Write n bytes from buf. Returns number of bytes written.