2023-01-10 00:32:37 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <streambuf>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
class ReadBuffer;
|
|
|
|
class SeekableReadBuffer;
|
|
|
|
|
|
|
|
/// `std::streambuf`-compatible wrapper around a ReadBuffer.
|
|
|
|
class StdStreamBufFromReadBuffer : public std::streambuf
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using Base = std::streambuf;
|
|
|
|
|
2023-01-16 13:55:26 +00:00
|
|
|
explicit StdStreamBufFromReadBuffer(std::unique_ptr<ReadBuffer> read_buffer_, size_t size_);
|
|
|
|
explicit StdStreamBufFromReadBuffer(ReadBuffer & read_buffer_, size_t size_);
|
2023-01-10 00:32:37 +00:00
|
|
|
~StdStreamBufFromReadBuffer() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
int underflow() override;
|
|
|
|
std::streamsize showmanyc() override;
|
|
|
|
std::streamsize xsgetn(char* s, std::streamsize count) override;
|
2023-01-16 13:55:26 +00:00
|
|
|
std::streampos seekoff(std::streamoff off, std::ios_base::seekdir dir, std::ios_base::openmode which) override;
|
|
|
|
std::streampos seekpos(std::streampos pos, std::ios_base::openmode which) override;
|
2023-01-10 00:32:37 +00:00
|
|
|
|
|
|
|
std::streamsize xsputn(const char* s, std::streamsize n) override;
|
2023-01-16 13:55:26 +00:00
|
|
|
int overflow(int c) override;
|
2023-01-10 00:32:37 +00:00
|
|
|
|
|
|
|
std::streampos getCurrentPosition() const;
|
|
|
|
|
|
|
|
std::unique_ptr<ReadBuffer> read_buffer;
|
|
|
|
SeekableReadBuffer * seekable_read_buffer = nullptr;
|
2023-01-16 13:55:26 +00:00
|
|
|
size_t size;
|
2023-01-10 00:32:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|