2023-04-18 11:11:42 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2023-05-15 12:41:51 +00:00
|
|
|
/// StdIStreamFromMemory is used in WriteBufferFromS3 as a stream which is passed to the S3::Client
|
|
|
|
/// It provides istream interface (only reading) over the memory.
|
|
|
|
/// However S3::Client requires iostream interface it only reads from the stream
|
|
|
|
|
|
|
|
class StdIStreamFromMemory : public std::iostream
|
2023-04-18 11:11:42 +00:00
|
|
|
{
|
|
|
|
struct MemoryBuf: std::streambuf
|
|
|
|
{
|
|
|
|
MemoryBuf(char * begin_, size_t size_);
|
|
|
|
|
|
|
|
int_type underflow() override;
|
|
|
|
|
|
|
|
pos_type seekoff(off_type off, std::ios_base::seekdir way,
|
|
|
|
std::ios_base::openmode mode) override;
|
|
|
|
|
|
|
|
pos_type seekpos(pos_type sp,
|
|
|
|
std::ios_base::openmode mode) override;
|
|
|
|
|
|
|
|
char * begin = nullptr;
|
|
|
|
size_t size = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
MemoryBuf mem_buf;
|
2023-05-15 12:41:51 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
StdIStreamFromMemory(char * begin_, size_t size_);
|
2023-04-18 11:11:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|