winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

Compression.h (1793B)


      1 // Copyright (c) Microsoft Corporation.
      2 // Licensed under the MIT License.
      3 #pragma once
      4 #include <wil/resource.h>
      5 #include <compressapi.h>
      6 #include <vector>
      7 #include <string_view>
      8 
      9 namespace AppInstaller::Compression
     10 {
     11     // Contains a compressor from the Windows Compression API.
     12     struct Compressor
     13     {
     14         // Create a compressor using the given algorithm (see COMPRESS_ALGORITHM_*)
     15         Compressor(DWORD algorithm);
     16 
     17         // Compresses the given data.
     18         std::vector<uint8_t> Compress(std::string_view data);
     19 
     20         // Resets the compressor.
     21         void Reset();
     22 
     23         // Sets compressor information values.
     24         void SetInformation(COMPRESS_INFORMATION_CLASS information, DWORD value);
     25 
     26         // Gets compressor information values.
     27         DWORD GetInformation(COMPRESS_INFORMATION_CLASS information);
     28 
     29     private:
     30         wil::unique_any<COMPRESSOR_HANDLE, decltype(CloseCompressor), CloseCompressor> m_compressor;
     31     };
     32 
     33     // Contains a decompressor from the Windows Compression API.
     34     struct Decompressor
     35     {
     36         // Create a decompressor using the given algorithm (see COMPRESS_ALGORITHM_*)
     37         Decompressor(DWORD algorithm);
     38 
     39         // Decompresses the given data.
     40         std::vector<uint8_t> Decompress(const std::vector<uint8_t>& data);
     41 
     42         // Resets the decompressor.
     43         void Reset();
     44 
     45         // Sets decompressor information values.
     46         void SetInformation(COMPRESS_INFORMATION_CLASS information, DWORD value);
     47 
     48         // Gets decompressor information values.
     49         DWORD GetInformation(COMPRESS_INFORMATION_CLASS information);
     50 
     51     private:
     52         wil::unique_any<DECOMPRESSOR_HANDLE, decltype(CloseDecompressor), CloseDecompressor> m_decompressor;
     53     };
     54 }