blob: b0bccc5a63b4f46d88c74217640c18cfdd4e33b8 (
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
 | #pragma once
#include <util/stream/zerocopy_output.h>
namespace NSkiff {
////////////////////////////////////////////////////////////////////////////////
// Simple wrapper around
class TZeroCopyOutputStreamWriter
    : private TNonCopyable
{
public:
    explicit TZeroCopyOutputStreamWriter(IZeroCopyOutput* output);
    ~TZeroCopyOutputStreamWriter();
    Y_FORCE_INLINE char* Current() const;
    Y_FORCE_INLINE ui64 RemainingBytes() const;
    Y_FORCE_INLINE void Advance(size_t bytes);
    void UndoRemaining();
    Y_FORCE_INLINE void Write(const void* buffer, size_t length);
    Y_FORCE_INLINE ui64 GetTotalWrittenSize() const;
private:
    void ObtainNextBlock();
private:
    IZeroCopyOutput* Output_;
    char* Current_ = nullptr;
    ui64 RemainingBytes_ = 0;
    ui64 TotalWrittenBlockSize_ = 0;
};
////////////////////////////////////////////////////////////////////////////////
} // namespace NSkiff
#define ZEROCOPY_OUTPUT_WRITER_INL_H_
#include "zerocopy_output_writer-inl.h"
#undef ZEROCOPY_OUTPUT_WRITER_INL_H_
 |