ZipEntryByteReadResource.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__ZIP_ENTRY_BYTE_READ_RESOURCE
18 #define COM_BORA_SOFTWARE__BALAU_RESOURCE__ZIP_ENTRY_BYTE_READ_RESOURCE
19 
21 #include <Balau/Resource/Impl/ZipEntrySource.hpp>
22 
23 #include <boost/iostreams/stream.hpp>
24 
25 namespace Balau::Resource {
26 
27 class ZipEntry;
28 
35  public: ZipEntryByteReadResource(ZipEntryByteReadResource && rhs) noexcept
36  : entry(rhs.entry)
37  , stream(std::move(rhs.stream)) {}
38 
39  public: ~ZipEntryByteReadResource() override = default;
40 
41  public: void close() override {
42  // NOP
43  }
44 
45  public: const Uri & uri() const override;
46 
47  public: std::istream & readStream() override {
48  return *stream;
49  }
50 
52 
53  friend class ZipEntry;
54 
55  private: explicit ZipEntryByteReadResource(const ZipEntry & entry_);
56 
57  private: const ZipEntry & entry;
58  private: std::unique_ptr<boost::iostreams::stream<Impl::ZipEntrySource>> stream;
59 };
60 
61 } // namespace Balau::Resource
62 
63 #endif // COM_BORA_SOFTWARE__BALAU_RESOURCE__ZIP_ENTRY_BYTE_READ_RESOURCE
const Uri & uri() const override
Get the URI associated with this resource.
A read-only resource which is read as bytes.
Definition: ByteReadResource.hpp:29
An abstract universal resource identifier.
Definition: Uri.hpp:131
The unified resource class hierarchy.
Definition: ByteReadResource.hpp:24
void close() override
Close the stream(s) in the resource.
Definition: ZipEntryByteReadResource.hpp:41
std::istream & readStream() override
Get the input stream of the byte read resource.
Definition: ZipEntryByteReadResource.hpp:47
An entry in a zip archive on the local file system.
Definition: ZipEntry.hpp:35
A read-only resource which is read as bytes.
A read-only entry in a zip file which is read as bytes.
Definition: ZipEntryByteReadResource.hpp:34