35        template<
class T, 
class TR, 
class AX>
 
   36        void encode(_Inout_ std::basic_string<T, TR, AX> &out, _In_bytecount_(size) 
const void *data, _In_ 
size_t size)
 
   38            stdex_assert(data || !size);
 
   41            out.reserve(out.size() + 
enc_size(size));
 
   44            for (
size_t i = 0; i < size; i++) {
 
   46                    x   = 
reinterpret_cast<const uint8_t*
>(data)[i],
 
   47                    x_h = ((x & 0xf0) >> 4),
 
   50                out += x_h < 10 ? 
'0' + x_h : 
'A' - 10 + x_h;
 
   51                out += x_l < 10 ? 
'0' + x_l : 
'A' - 10 + x_l;
 
 
   62        size_t enc_size(_In_ 
size_t size) 
const noexcept 
 
 
   90        template<
class T_to, 
class AX, 
class T_from>
 
   91        void decode(_Inout_ std::vector<T_to, AX> &out, _Out_ 
bool &is_last, _In_z_count_(size) 
const T_from *data, _In_ 
size_t size)
 
   96            for (
size_t k = 0; k < size; k++)
 
   97                if (!data[k]) { size = k; 
break; }
 
  100            out.reserve(out.size() + 
dec_size(size));
 
  102            for (
size_t i = 0;; i++) {
 
  115                if (
'0' <= x && x <= 
'9') {
 
  116                    buf = ((
buf & 0xf) << 4) | 
static_cast<uint8_t
>(x - 
'0');
 
  118                } 
else if (
'A' <= x && x <= 
'F') {
 
  119                    buf = ((
buf & 0xf) << 4) | 
static_cast<uint8_t
>(x - (
'A' - 10));
 
  121                } 
else if (
'a' <= x && x <= 
'f') {
 
  122                    buf = ((
buf & 0xf) << 4) | 
static_cast<uint8_t
>(x - (
'a' - 10));
 
 
 
Hexadecimal decoding session.
Definition hex.hpp:72
 
void clear() noexcept
Resets decoding session.
Definition hex.hpp:131
 
uint8_t buf
Internal buffer.
Definition hex.hpp:149
 
hex_dec() noexcept
Constructs blank decoding session.
Definition hex.hpp:77
 
void decode(std::vector< T_to, AX > &out, bool &is_last, const T_from *data, size_t size)
Decodes one block of information, and appends it to the output.
Definition hex.hpp:91
 
size_t num
Number of nibbles used in buf
Definition hex.hpp:150
 
size_t dec_size(size_t size) const noexcept
Returns maximum decoded size.
Definition hex.hpp:143
 
Hexadecimal encoding session.
Definition hex.hpp:20
 
size_t enc_size(size_t size) const noexcept
Returns maximum encoded size.
Definition hex.hpp:62
 
void encode(std::basic_string< T, TR, AX > &out, const void *data, size_t size)
Encodes one block of information, and appends it to the output.
Definition hex.hpp:36
 
hex_enc() noexcept
Constructs blank encoding session.
Definition hex.hpp:25