aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/blockcodecs/core/stream.h
blob: a66c2e0c317b67318495b30a6767f2c61c98f50d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once

#include <util/stream/walk.h>
#include <util/stream/input.h>
#include <util/stream/output.h>
#include <util/stream/zerocopy.h>
#include <util/generic/buffer.h>

namespace NBlockCodecs {
    struct ICodec;

    class TCodedOutput: public IOutputStream { 
    public:
        TCodedOutput(IOutputStream* out, const ICodec* c, size_t bufLen); 
        ~TCodedOutput() override;

    private:
        void DoWrite(const void* buf, size_t len) override;
        void DoFlush() override;
        void DoFinish() override;

        bool FlushImpl();

    private:
        const ICodec* C_;
        TBuffer D_;
        TBuffer O_;
        IOutputStream* S_; 
    };

    class TDecodedInput: public IWalkInput { 
    public:
        TDecodedInput(IInputStream* in); 
        TDecodedInput(IInputStream* in, const ICodec* codec);

        ~TDecodedInput() override;

    private:
        size_t DoUnboundedNext(const void** ptr) override;

    private:
        TBuffer D_;
        IInputStream* S_; 
        const ICodec* C_;
    };
}