ClickHouse/src/IO/IReadableWriteBuffer.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

33 lines
701 B
C++
Raw Normal View History

#pragma once
#include <memory>
#include <IO/ReadBuffer.h>
namespace DB
{
struct IReadableWriteBuffer
{
/// At the first time returns getReadBufferImpl(). Next calls return nullptr.
2023-11-27 19:39:08 +00:00
inline std::unique_ptr<ReadBuffer> tryGetReadBuffer()
{
if (!can_reread)
return nullptr;
can_reread = false;
return getReadBufferImpl();
}
virtual ~IReadableWriteBuffer() = default;
protected:
/// Creates read buffer from current write buffer.
/// Returned buffer points to the first byte of original buffer.
/// Original stream becomes invalid.
2023-11-27 19:39:08 +00:00
virtual std::unique_ptr<ReadBuffer> getReadBufferImpl() = 0;
bool can_reread = true;
};
}