1 | #pragma once |
2 | |
3 | #include <IO/ReadBuffer.h> |
4 | |
5 | |
6 | namespace DB |
7 | { |
8 | |
9 | /** Allows to read from memory range. |
10 | * In comparison with just ReadBuffer, it only adds convenient constructors, that do const_cast. |
11 | * In fact, ReadBuffer will not modify data in buffer, but it requires non-const pointer. |
12 | */ |
13 | class ReadBufferFromMemory : public ReadBuffer |
14 | { |
15 | public: |
16 | ReadBufferFromMemory(const char * buf, size_t size) |
17 | : ReadBuffer(const_cast<char *>(buf), size, 0) {} |
18 | |
19 | ReadBufferFromMemory(const unsigned char * buf, size_t size) |
20 | : ReadBuffer(const_cast<char *>(reinterpret_cast<const char *>(buf)), size, 0) {} |
21 | |
22 | ReadBufferFromMemory(const signed char * buf, size_t size) |
23 | : ReadBuffer(const_cast<char *>(reinterpret_cast<const char *>(buf)), size, 0) {} |
24 | }; |
25 | |
26 | } |
27 | |