Sane C++ Libraries
C++ Platform Abstraction Libraries
Loading...
Searching...
No Matches
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 void setEventLoop(AsyncEventLoop& loop) { eventLoop = &loop; }
29
30 private:
31 AsyncEventLoop* eventLoop = nullptr;
32
33 Result compressExecute(Span<const char> input, Span<char> output);
34 Result compressFinalize(Span<char> output);
35 void afterWork(AsyncLoopWork::Result& result);
36 Result work();
37
38 bool finalizing = false;
39 bool streamEnded = false;
40
41 Span<const char> savedInput;
42 Span<char> savedOutput;
43};
44
45} // namespace SC
A stream that can both produce and consume buffers.
Definition AsyncStreams.h:277
Asynchronous I/O (files, sockets, timers, processes, fs events, threads wake-up) (see Async) AsyncEve...
Definition Async.h:976
Executes work in a thread pool and then invokes a callback on the event loop thread.
Definition Async.h:928
Helper holding CompletionData for a specific AsyncRequest-derived class.
Definition Async.h:290
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