HttpByteReadResource.hpp
Go to the documentation of this file.
1 // @formatter:off
2 //
3 // Balau core C++ library
4 //
5 // Copyright (C) 2008 Bora Software (contact@borasoftware.com)
6 //
7 // Licensed under the Boost Software License - Version 1.0 - August 17th, 2003.
8 // See the LICENSE file for the full license text.
9 //
10 
16 
17 #ifndef COM_BORA_SOFTWARE__BALAU_RESOURCE__HTTP_BYTE_READ_RESOURCE
18 #define COM_BORA_SOFTWARE__BALAU_RESOURCE__HTTP_BYTE_READ_RESOURCE
19 
21 #include <Balau/Resource/Impl/HttpSource.hpp>
22 
23 #include <boost/iostreams/stream.hpp>
24 
25 namespace Balau::Resource {
26 
27 class Http;
28 class Uri;
29 
39  public: explicit HttpByteReadResource(const Http & url_);
40 
41  public: HttpByteReadResource(HttpByteReadResource && rhs) noexcept
42  : url(std::move(rhs.url))
43  , stream(std::move(rhs.stream)) {}
44 
45  public: ~HttpByteReadResource() override {
46  close();
47  }
48 
49  public: std::istream & readStream() override {
50  return *stream;
51  }
52 
53  public: const Uri & uri() const override;
54 
55  public: void close() override {
56  stream->close();
57  }
58 
60 
61  private: std::unique_ptr<Http> url;
62  private: std::unique_ptr<boost::iostreams::stream<Impl::HttpSource>> stream;
63 };
64 
65 } // namespace Balau::Resource
66 
67 #endif // COM_BORA_SOFTWARE__BALAU_RESOURCE__HTTPS_BYTE_READ_RESOURCE
std::istream & readStream() override
Get the input stream of the byte read resource.
Definition: HttpByteReadResource.hpp:49
A read-only resource which is read as bytes.
Definition: ByteReadResource.hpp:29
A read-only HTTP resource which is read as bytes.
Definition: HttpByteReadResource.hpp:33
An abstract universal resource identifier.
Definition: Uri.hpp:131
void close() override
Close the stream(s) in the resource.
Definition: HttpByteReadResource.hpp:55
The unified resource class hierarchy.
Definition: ByteReadResource.hpp:24
An HTTP URL.
Definition: Http.hpp:31
HttpByteReadResource(const Http &url_)
Create a new HTTP byte read resource from the supplied HTTP URI.
const Uri & uri() const override
Get the URI associated with this resource.
A read-only resource which is read as bytes.