HttpsByteReadResource.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__HTTPS_BYTE_READ_RESOURCE
18 #define COM_BORA_SOFTWARE__BALAU_RESOURCE__HTTPS_BYTE_READ_RESOURCE
19 
21 #include <Balau/Resource/Impl/HttpsSource.hpp>
22 
23 #include <boost/iostreams/stream.hpp>
24 
25 namespace Balau::Resource {
26 
27 class Https;
28 class Uri;
29 
39  public: explicit HttpsByteReadResource(const Https & url);
40 
41  public: HttpsByteReadResource(HttpsByteReadResource && rhs) noexcept
42  : url(std::move(rhs.url))
43  , stream(std::move(rhs.stream)) {}
44 
45  public: ~HttpsByteReadResource() 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<Https> url;
62  private: std::unique_ptr<boost::iostreams::stream<Impl::HttpsSource>> 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: HttpsByteReadResource.hpp:49
An HTTPS URL.
Definition: Https.hpp:30
A read-only resource which is read as bytes.
Definition: ByteReadResource.hpp:29
An abstract universal resource identifier.
Definition: Uri.hpp:131
const Uri & uri() const override
Get the URI associated with this resource.
The unified resource class hierarchy.
Definition: ByteReadResource.hpp:24
HttpsByteReadResource(const Https &url)
Create a new HTTPS byte read resource from the supplied HTTPS URI.
A read-only HTTP resource which is read as bytes.
Definition: HttpsByteReadResource.hpp:33
void close() override
Close the stream(s) in the resource.
Definition: HttpsByteReadResource.hpp:55
A read-only resource which is read as bytes.