// C++/WinRT v2.0.250303.1 // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #pragma once #ifndef WINRT_Windows_Storage_Compression_H #define WINRT_Windows_Storage_Compression_H #include "winrt/base.h" static_assert(winrt::check_version(CPPWINRT_VERSION, "2.0.250303.1"), "Mismatched C++/WinRT headers."); #define CPPWINRT_VERSION "2.0.250303.1" #include "winrt/Windows.Storage.h" #include "winrt/impl/Windows.Foundation.2.h" #include "winrt/impl/Windows.Storage.Streams.2.h" #include "winrt/impl/Windows.Storage.Compression.2.h" namespace winrt::impl { template auto consume_Windows_Storage_Compression_ICompressor::FinishAsync() const { void* operation{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->FinishAsync(&operation)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->FinishAsync(&operation)); } return winrt::Windows::Foundation::IAsyncOperation{ operation, take_ownership_from_abi }; } template auto consume_Windows_Storage_Compression_ICompressor::DetachStream() const { void* stream{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->DetachStream(&stream)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->DetachStream(&stream)); } return winrt::Windows::Storage::Streams::IOutputStream{ stream, take_ownership_from_abi }; } template auto consume_Windows_Storage_Compression_ICompressorFactory::CreateCompressor(winrt::Windows::Storage::Streams::IOutputStream const& underlyingStream) const { void* createdCompressor{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->CreateCompressor(*(void**)(&underlyingStream), &createdCompressor)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->CreateCompressor(*(void**)(&underlyingStream), &createdCompressor)); } return winrt::Windows::Storage::Compression::Compressor{ createdCompressor, take_ownership_from_abi }; } template auto consume_Windows_Storage_Compression_ICompressorFactory::CreateCompressorEx(winrt::Windows::Storage::Streams::IOutputStream const& underlyingStream, winrt::Windows::Storage::Compression::CompressAlgorithm const& algorithm, uint32_t blockSize) const { void* createdCompressor{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->CreateCompressorEx(*(void**)(&underlyingStream), static_cast(algorithm), blockSize, &createdCompressor)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->CreateCompressorEx(*(void**)(&underlyingStream), static_cast(algorithm), blockSize, &createdCompressor)); } return winrt::Windows::Storage::Compression::Compressor{ createdCompressor, take_ownership_from_abi }; } template auto consume_Windows_Storage_Compression_IDecompressor::DetachStream() const { void* stream{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->DetachStream(&stream)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->DetachStream(&stream)); } return winrt::Windows::Storage::Streams::IInputStream{ stream, take_ownership_from_abi }; } template auto consume_Windows_Storage_Compression_IDecompressorFactory::CreateDecompressor(winrt::Windows::Storage::Streams::IInputStream const& underlyingStream) const { void* createdDecompressor{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->CreateDecompressor(*(void**)(&underlyingStream), &createdDecompressor)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->CreateDecompressor(*(void**)(&underlyingStream), &createdDecompressor)); } return winrt::Windows::Storage::Compression::Decompressor{ createdDecompressor, take_ownership_from_abi }; } #ifndef WINRT_LEAN_AND_MEAN template struct produce : produce_base { int32_t __stdcall FinishAsync(void** operation) noexcept final try { clear_abi(operation); typename D::abi_guard guard(this->shim()); *operation = detach_from>(this->shim().FinishAsync()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall DetachStream(void** stream) noexcept final try { clear_abi(stream); typename D::abi_guard guard(this->shim()); *stream = detach_from(this->shim().DetachStream()); return 0; } catch (...) { return to_hresult(); } }; #endif #ifndef WINRT_LEAN_AND_MEAN template struct produce : produce_base { int32_t __stdcall CreateCompressor(void* underlyingStream, void** createdCompressor) noexcept final try { clear_abi(createdCompressor); typename D::abi_guard guard(this->shim()); *createdCompressor = detach_from(this->shim().CreateCompressor(*reinterpret_cast(&underlyingStream))); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall CreateCompressorEx(void* underlyingStream, int32_t algorithm, uint32_t blockSize, void** createdCompressor) noexcept final try { clear_abi(createdCompressor); typename D::abi_guard guard(this->shim()); *createdCompressor = detach_from(this->shim().CreateCompressorEx(*reinterpret_cast(&underlyingStream), *reinterpret_cast(&algorithm), blockSize)); return 0; } catch (...) { return to_hresult(); } }; #endif #ifndef WINRT_LEAN_AND_MEAN template struct produce : produce_base { int32_t __stdcall DetachStream(void** stream) noexcept final try { clear_abi(stream); typename D::abi_guard guard(this->shim()); *stream = detach_from(this->shim().DetachStream()); return 0; } catch (...) { return to_hresult(); } }; #endif #ifndef WINRT_LEAN_AND_MEAN template struct produce : produce_base { int32_t __stdcall CreateDecompressor(void* underlyingStream, void** createdDecompressor) noexcept final try { clear_abi(createdDecompressor); typename D::abi_guard guard(this->shim()); *createdDecompressor = detach_from(this->shim().CreateDecompressor(*reinterpret_cast(&underlyingStream))); return 0; } catch (...) { return to_hresult(); } }; #endif } WINRT_EXPORT namespace winrt::Windows::Storage::Compression { inline Compressor::Compressor(winrt::Windows::Storage::Streams::IOutputStream const& underlyingStream) : Compressor(impl::call_factory([&](ICompressorFactory const& f) { return f.CreateCompressor(underlyingStream); })) { } inline Compressor::Compressor(winrt::Windows::Storage::Streams::IOutputStream const& underlyingStream, winrt::Windows::Storage::Compression::CompressAlgorithm const& algorithm, uint32_t blockSize) : Compressor(impl::call_factory([&](ICompressorFactory const& f) { return f.CreateCompressorEx(underlyingStream, algorithm, blockSize); })) { } inline Decompressor::Decompressor(winrt::Windows::Storage::Streams::IInputStream const& underlyingStream) : Decompressor(impl::call_factory([&](IDecompressorFactory const& f) { return f.CreateDecompressor(underlyingStream); })) { } } namespace std { #ifndef WINRT_LEAN_AND_MEAN template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; #endif #ifdef __cpp_lib_format #endif } #endif