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 virtual Result asyncWrite(AsyncBufferView::ID bufferID, Function<void(AsyncBufferView::ID)> cb) override;
18 virtual bool canEndWritable() override;
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 virtual Result onProcess(Span<const char> input, Span<char> output) override;
34 virtual Result onFinalize(Span<char> output) override;
35
36 void afterWork(AsyncLoopWork::Result& result);
37 Result work();
38
39 bool finalizing = false;
40 bool streamEnded = false;
41
42 Span<const char> savedInput;
43 Span<char> savedOutput;
44};
45
46} // namespace SC
struct SC_COMPILER_EXPORT Function
Wraps function pointers, member functions and lambdas without ever allocating.
Definition Function.h:19
Definition AsyncStreams.h:52
A stream that can both produce and consume buffers.
Definition AsyncStreams.h:455
Asynchronous I/O (files, sockets, timers, processes, fs events, threads wake-up) (see Async) AsyncEve...
Definition Async.h:1285
Executes work in a thread pool and then invokes a callback on the event loop thread.
Definition Async.h:1034
Helper holding CompletionData for a specific AsyncRequest-derived class.
Definition Async.h:286
A duplex stream that produces new buffers transforming received buffers.
Definition AsyncStreams.h:466
Definition ZLibTransformStreams.h:22
An ascii string used as boolean result. SC_TRY macro forwards errors to caller.
Definition Result.h:13
View over a contiguous sequence of items (pointer + size in elements).
Definition Span.h:29
Definition ZLibTransformStreams.h:10