Sane C++ Libraries
C++ Platform Abstraction Libraries
ZLibTransformStreams.h
1// Copyright (c) Stefano Cristiano
2// SPDX-License-Identifier: MIT
3#pragma once
4#include "../Async/Async.h"
5#include "AsyncStreams.h"
6#include "Internal/ZLibStream.h"
7namespace SC
8{
10{
12 ZLibStream stream;
13
14 private:
15 size_t consumedInputBytes = 0;
16
17 Result transform(AsyncBufferView::ID bufferID, Function<void(AsyncBufferView::ID)> cb);
18 bool canEndTransform();
19};
20
22{
24
25 ZLibStream stream;
26 AsyncLoopWork asyncWork;
27
28 private:
29 Result compressExecute(Span<const char> input, Span<char> output);
30 Result compressFinalize(Span<char> output);
31 void afterWork(AsyncLoopWork::Result& result);
32 Result work();
33
34 bool finalizing = false;
35 bool streamEnded = false;
36
37 Span<const char> savedInput;
38 Span<char> savedOutput;
39};
40
41} // namespace SC
A stream that can both produce and consume buffers.
Definition: AsyncStreams.h:277
Executes work in a thread pool and then invokes a callback on the event loop thread.
Definition: Async.h:404
Helper holding CompletionData for a specific AsyncRequest-derived class.
Definition: Async.h:269
A duplex stream that produces new buffers transforming received buffers.
Definition: AsyncStreams.h:286
Definition: ZLibTransformStreams.h:22
Wraps function pointers, member functions and lambdas without ever allocating.
Definition: Function.h:19
An ascii string used as boolean result. SC_TRY macro forwards errors to caller.
Definition: Result.h:12
View over a contiguous sequence of items (pointer + size in elements).
Definition: Span.h:32
Definition: ZLibTransformStreams.h:10