ClickHouse/src/IO/ReadBufferFromMemory.h

25 lines
684 B
C++
Raw Normal View History

2017-01-03 01:42:17 +00:00
#pragma once
#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.
*/
class ReadBufferFromMemory : public SeekableReadBuffer
2017-01-03 01:42:17 +00:00
{
public:
2020-01-03 14:55:22 +00:00
template <typename CharT, typename = std::enable_if_t<sizeof(CharT) == 1>>
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) {}
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
};
}