ZipEntryUtf8To32ReadResource.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_UTF8_TO_32_READ_RESOURCE
18 #define COM_BORA_SOFTWARE__BALAU_RESOURCE__ZIP_ENTRY_UTF8_TO_32_READ_RESOURCE
19 
22 #include <Balau/Resource/Impl/ZipEntrySource.hpp>
23 
24 #include <boost/iostreams/code_converter.hpp>
25 #include <boost/iostreams/stream.hpp>
26 
27 #include <codecvt>
28 
29 namespace Balau::Resource {
30 
31 class ZipEntry;
32 
39  private: using idevice_utf8_utf32 = boost::iostreams::code_converter<std::istream, std::codecvt_utf8<char32_t, 0x10ffff, std::consume_header>>;
40  private: using istream_utf8_utf32 = boost::iostreams::stream<idevice_utf8_utf32>;
41 
42  public: ~ZipEntryUtf8To32ReadResource() override = default;
43 
45  : entry(rhs.entry)
46  , utf8Stream(std::move(rhs.utf8Stream))
47  , ref(rhs.ref)
48  , utf32Stream(std::move(rhs.utf32Stream)) {}
49 
50  public: void close() override {
51  // NOP
52  }
53 
54  public: const Uri & uri() const override;
55 
56  public: std::u32istream & readStream() override {
57  return *utf32Stream;
58  }
59 
63  public: explicit ZipEntryUtf8To32ReadResource(const ZipEntry & entry_);
64 
66 
67  friend class ZipEntry;
68 
69  private: const ZipEntry & entry;
70  private: std::unique_ptr<boost::iostreams::stream<Impl::ZipEntrySource>> utf8Stream;
71  private: std::istream & ref;
72  private: std::unique_ptr<istream_utf8_utf32> utf32Stream;
73 };
74 
75 } // namespace Balau::Resource
76 
77 #endif // COM_BORA_SOFTWARE__BALAU_RESOURCE__ZIP_ENTRY_UTF8_TO_32_READ_RESOURCE
A read-only UTF-8 resource which is read as UTF-32 characters.
A read-only UTF-8 resource which is read in as UTF-32 characters.
Definition: Utf8To32ReadResource.hpp:28
An abstract universal resource identifier.
Definition: Uri.hpp:131
const Uri & uri() const override
Get the URI associated with this resource.
void close() override
Close the stream(s) in the resource.
Definition: ZipEntryUtf8To32ReadResource.hpp:50
The unified resource class hierarchy.
Definition: ByteReadResource.hpp:24
std::u32istream & readStream() override
Get the input stream of the UTF-8 to UTF-32 read resource.
Definition: ZipEntryUtf8To32ReadResource.hpp:56
An entry in a zip archive on the local file system.
Definition: ZipEntry.hpp:35
A read-only entry in a zip file which is read as UTF-8 characters and implicitly converted to UTF-32 ...
Definition: ZipEntryUtf8To32ReadResource.hpp:38
A read-only resource which is read as bytes.