summaryrefslogtreecommitdiffstats
path: root/src/StringCompression.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/StringCompression.h')
-rw-r--r--src/StringCompression.h102
1 files changed, 49 insertions, 53 deletions
diff --git a/src/StringCompression.h b/src/StringCompression.h
index 862cf7a62..06666c220 100644
--- a/src/StringCompression.h
+++ b/src/StringCompression.h
@@ -18,66 +18,62 @@ struct libdeflate_decompressor;
namespace Compression
{
- /** Contains the result of a compression or extraction operation. */
- struct Result
- {
- using Static = std::array<std::byte, 128 KiB>;
- using Dynamic = std::unique_ptr<std::byte[]>;
-
- static constexpr size_t StaticCapacity = sizeof(Compression::Result::Static) / sizeof(Compression::Result::Static::value_type);
-
- /** Returns a view (of type char) of the internal store. */
- std::string_view GetStringView() const;
-
- /** Returns a view (of type std::byte) of the internal store. */
- ContiguousByteBufferView GetView() const;
-
- /** A store allocated on either the stack or heap. */
- std::variant<Static, Dynamic> Storage;
-
- /** The length of valid data in the store. */
- size_t Size;
- };
-
- /** Contains routines for data compression. */
- class Compressor
- {
- public:
-
- /** Creates a new compressor instance with a compression factor [0-12]. */
- Compressor(int CompressionFactor = 6);
- ~Compressor();
+/** Contains the result of a compression or extraction operation. */
+struct Result
+{
+ using Static = std::array<std::byte, 128 KiB>;
+ using Dynamic = std::unique_ptr<std::byte[]>;
- Result CompressGZip(ContiguousByteBufferView Input);
- Result CompressZLib(ContiguousByteBufferView Input);
- Result CompressZLib(const void * Input, size_t Size);
+ static constexpr size_t StaticCapacity =
+ sizeof(Compression::Result::Static) / sizeof(Compression::Result::Static::value_type);
- private:
+ /** Returns a view (of type char) of the internal store. */
+ std::string_view GetStringView() const;
- template <auto Algorithm>
- Result Compress(const void * Input, size_t Size);
+ /** Returns a view (of type std::byte) of the internal store. */
+ ContiguousByteBufferView GetView() const;
- libdeflate_compressor * m_Handle;
- };
+ /** A store allocated on either the stack or heap. */
+ std::variant<Static, Dynamic> Storage;
- /** Contains routines for data extraction. */
- class Extractor
- {
- public:
+ /** The length of valid data in the store. */
+ size_t Size;
+};
- /** Creates a new extractor instance. */
- Extractor();
- ~Extractor();
+/** Contains routines for data compression. */
+class Compressor
+{
+ public:
+ /** Creates a new compressor instance with a compression factor [0-12]. */
+ Compressor(int CompressionFactor = 6);
+ ~Compressor();
- Result ExtractGZip(ContiguousByteBufferView Input);
- Result ExtractZLib(ContiguousByteBufferView Input);
- Result ExtractZLib(ContiguousByteBufferView Input, size_t UncompressedSize);
+ Result CompressGZip(ContiguousByteBufferView Input);
+ Result CompressZLib(ContiguousByteBufferView Input);
+ Result CompressZLib(const void * Input, size_t Size);
- private:
+ private:
+ template <auto Algorithm> Result Compress(const void * Input, size_t Size);
- template <auto Algorithm> Result Extract(ContiguousByteBufferView Input);
- template <auto Algorithm> Result Extract(ContiguousByteBufferView Input, size_t UncompressedSize);
+ libdeflate_compressor * m_Handle;
+};
- libdeflate_decompressor * m_Handle;
- };
-}
+/** Contains routines for data extraction. */
+class Extractor
+{
+ public:
+ /** Creates a new extractor instance. */
+ Extractor();
+ ~Extractor();
+
+ Result ExtractGZip(ContiguousByteBufferView Input);
+ Result ExtractZLib(ContiguousByteBufferView Input);
+ Result ExtractZLib(ContiguousByteBufferView Input, size_t UncompressedSize);
+
+ private:
+ template <auto Algorithm> Result Extract(ContiguousByteBufferView Input);
+ template <auto Algorithm> Result Extract(ContiguousByteBufferView Input, size_t UncompressedSize);
+
+ libdeflate_decompressor * m_Handle;
+};
+} // namespace Compression