// Represent // // Douglas Thrift // // $Id$ #include "Hexadecimal.hpp" Hexadecimal::Hexadecimal(const ext::String& string, bool signed_) : Binary(string.GetSize() / 2, 0) { if (string.IsEmpty()) { bytes.InsertLast(0); return; } size_t index(string.GetSize() % 2), offset(index); _rmforeach (ext::Vector, byte, bytes) _rfor (byte_t, half, 0, 2) { /* byte_t hex(string[index++]); if (hex >= '0' && hex <= '9') hex -= '0'; else*/ } if (offset != 0) { bytes.InsertLast(0); // index = 0; // } } Hexadecimal::operator ext::String() const { ext::String string; _rforeach (ext::Vector, byte, bytes) _rfor (byte_t, half, 0, 2) { byte_t hex(0xF & *byte >> half * 4); switch (hex) { case 0xA: hex = 'A'; break; case 0xB: hex = 'B'; break; case 0xC: hex = 'C'; break; case 0xD: hex = 'D'; break; case 0xE: hex = 'E'; break; case 0xF: hex = 'F'; break; default: hex += '0'; } string.InsertLast(hex); } return string; }