ClickHouse/dbms/src/IO/HexWriteBuffer.cpp

36 lines
548 B
C++
Raw Normal View History

2017-06-01 13:41:58 +00:00
#include <Core/Types.h>
#include <Common/hex.h>
#include <Common/Exception.h>
#include <IO/HexWriteBuffer.h>
namespace DB
{
void HexWriteBuffer::nextImpl()
{
if (!offset())
return;
for (Position p = working_buffer.begin(); p != pos; ++p)
{
UInt8 byte = *p;
out.write(hexUppercase(byte / 16));
out.write(hexUppercase(byte % 16));
}
}
HexWriteBuffer::~HexWriteBuffer()
{
try
{
nextImpl();
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
}
}