ClickHouse/src/IO/StdStreamBufFromReadBuffer.h
Vitaly Baranov 1c845185c1 Split upload into parts of the same size for smooth uploading.
Correctly use AbortMultipleUpload request.
Support std::ios_base::end StdStreamBufFromReadBuffer::seekpos().
2023-01-17 09:35:43 +01:00

40 lines
1.1 KiB
C++

#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;
explicit StdStreamBufFromReadBuffer(std::unique_ptr<ReadBuffer> read_buffer_, size_t size_);
explicit StdStreamBufFromReadBuffer(ReadBuffer & read_buffer_, size_t size_);
~StdStreamBufFromReadBuffer() override;
private:
int underflow() override;
std::streamsize showmanyc() override;
std::streamsize xsgetn(char* s, std::streamsize count) override;
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;
std::streamsize xsputn(const char* s, std::streamsize n) override;
int overflow(int c) override;
std::streampos getCurrentPosition() const;
std::unique_ptr<ReadBuffer> read_buffer;
SeekableReadBuffer * seekable_read_buffer = nullptr;
size_t size;
};
}