mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
ClickMapBLOB: using DB::IO [#CONV-2807].
This commit is contained in:
parent
44fdb6c7d1
commit
b0cfa59a40
38
dbms/include/DB/IO/HexWriteBuffer.h
Normal file
38
dbms/include/DB/IO/HexWriteBuffer.h
Normal file
@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include <DB/IO/BufferWithOwnMemory.h>
|
||||
#include <DB/IO/WriteBuffer.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
/** Всё что в него пишут, переводит в HEX (большими буквами) и пишет в другой WriteBuffer.
|
||||
*/
|
||||
class HexWriteBuffer : public BufferWithOwnMemory<WriteBuffer>
|
||||
{
|
||||
protected:
|
||||
WriteBuffer & out;
|
||||
|
||||
void nextImpl()
|
||||
{
|
||||
if (!offset())
|
||||
return;
|
||||
|
||||
for (Position pos = working_buffer.begin(); pos != working_buffer.end(); ++pos)
|
||||
{
|
||||
out.write("0123456789ABCDEF"[static_cast<unsigned char>(*pos) >> 4]);
|
||||
out.write("0123456789ABCDEF"[static_cast<unsigned char>(*pos) & 0xF]);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
HexWriteBuffer(WriteBuffer & out_) : out(out_) {}
|
||||
|
||||
virtual ~HexWriteBuffer()
|
||||
{
|
||||
nextImpl();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user