1 |
douglas |
371 |
// Represent |
2 |
|
|
// |
3 |
|
|
// Douglas Thrift |
4 |
|
|
// |
5 |
|
|
// $Id$ |
6 |
|
|
|
7 |
|
|
#ifndef _Hexadecimal_hpp_ |
8 |
|
|
#define _Hexadecimal_hpp_ |
9 |
|
|
|
10 |
|
|
#include "Binary.hpp" |
11 |
|
|
|
12 |
|
|
#ifdef MENES_PRAGMA_ONCE |
13 |
|
|
#pragma once |
14 |
|
|
#endif |
15 |
|
|
|
16 |
|
|
class Hexadecimal : public Binary |
17 |
|
|
{ |
18 |
|
|
private: |
19 |
douglas |
373 |
byte_t hex(const ext::CodePoint& atom); |
20 |
douglas |
371 |
public: |
21 |
|
|
Hexadecimal() : Binary() {} |
22 |
|
|
Hexadecimal(const Binary& binary) : Binary(binary) {} |
23 |
|
|
Hexadecimal(const ext::String& string, bool signed_); |
24 |
|
|
template <typename Type> Hexadecimal(const Type& type) : Binary(type) {} |
25 |
|
|
virtual operator ext::String() const; |
26 |
|
|
}; |
27 |
|
|
|
28 |
douglas |
379 |
inline byte_t Hexadecimal::hex(const ext::CodePoint& atom) |
29 |
|
|
{ |
30 |
|
|
if (atom >= '0' && atom <= '9') return atom - '0'; else if (atom >= 'a' && atom <= 'f') return atom - 'a' + 0xA; else if (atom >= 'A' && atom <= 'F') return atom - 'A' + 0xA; else return 0; |
31 |
|
|
} |
32 |
|
|
|
33 |
douglas |
371 |
#endif // _Hexadecimal_hpp_ |