ClickHouse/src/IO/ReadBufferFromMemory.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
812 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:
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) {}
explicit ReadBufferFromMemory(const std::string_view&& str)
: SeekableReadBuffer(const_cast<char *>(str.data()), str.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
};
}