Skip to content

HexStringDecoder

INCLUDE FILE
#include "HexStringDecoder.h"

class HexStringDecoder

A helper class to decode hexadecimal strings.

DEFINITION
class HexStringDecoder;

method decode

Decode a single hexadecimal character, ignoring whitespace characters.

DEFINITION
void  decode ( char  character );
PARAMETERDESCRIPTION
character

The character to decode.

THROWSDESCRIPTION
Exception

If the character is not a valid character.

method decode

Decode a partial hexadecimal string, ignoring whitespace characters.

DEFINITION
void  decode ( const std::string & string );
PARAMETERDESCRIPTION
string

The string to decode.

THROWSDESCRIPTION
Exception

If the string contains an invalid character.

method end

Finish decoding and return the resulting string.

DEFINITION
std::string  end ( );
RETURNSDESCRIPTION
std::string

The decoded string.

THROWSDESCRIPTION
Exception

If there is a partial hexadecimal left.

method valuestatic private

Get the numeric value of a hexadecimal digit.

DEFINITION
static uint8_t  value ( char  digit );
PARAMETERDESCRIPTION
digit

The hexadecimal digit.

RETURNSDESCRIPTION
uint8_t

The numeric value of the digit.

member partialprivate

The partial value of the last decoded hexadecimal digit, if any.

DEFINITION
std::optional< uint8_t >  partial;

member stringprivate

The decoded string so far.

DEFINITION
std::string  string;