2017-01-03 01:42:17 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-01-22 16:17:25 +00:00
|
|
|
#include "SeekableReadBuffer.h"
|
2017-01-03 01:42:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
/** Allows to read from memory range.
|
|
|
|
* In comparison with just ReadBuffer, it only adds convenient constructors, that do const_cast.
|
|
|
|
* In fact, ReadBuffer will not modify data in buffer, but it requires non-const pointer.
|
|
|
|
*/
|
2020-01-22 16:17:25 +00:00
|
|
|
class ReadBufferFromMemory : public SeekableReadBuffer
|
2017-01-03 01:42:17 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-03-17 18:06:50 +00:00
|
|
|
template <typename CharT>
|
|
|
|
requires (sizeof(CharT) == 1)
|
2020-01-03 14:55:22 +00:00
|
|
|
ReadBufferFromMemory(const CharT * buf, size_t size)
|
2020-02-22 05:46:35 +00:00
|
|
|
: SeekableReadBuffer(const_cast<char *>(reinterpret_cast<const char *>(buf)), size, 0) {}
|
2022-09-08 18:36:21 +00:00
|
|
|
explicit ReadBufferFromMemory(const std::string_view&& str)
|
|
|
|
: SeekableReadBuffer(const_cast<char *>(str.data()), str.size(), 0) {}
|
2020-01-22 16:17:25 +00:00
|
|
|
|
2020-01-28 13:15:47 +00:00
|
|
|
off_t seek(off_t off, int whence) override;
|
2020-02-14 14:28:33 +00:00
|
|
|
|
|
|
|
off_t getPosition() override;
|
2017-01-03 01:42:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|