Skip to content

HexStreamEncoder

INCLUDE FILE
#include "HexStreamEncoder.h"

class HexStreamEncoder

A helper class to encode data a hexadecimal string.

DEFINITION
class HexStreamEncoder;

constructor HexStreamEncoder

Create a new hex stream encoder.

DEFINITION
HexStreamEncoder ( std::ostream & stream,
size_t  line_length = 0,
size_t  indent = 0 );
PARAMETERDESCRIPTION
stream

The stream to write the encoded data to.

line_length

The maximum length of a line. If 0, there is no maximum length.

indent

The number of spaces to indent each continuation line.

method digitstatic private

Convert a value in the range 0-15 to a hexadecimal digit.

DEFINITION
static char  digit ( uint8_t  value );
PARAMETERDESCRIPTION
value

The value to convert.

RETURNSDESCRIPTION
char

The hexadecimal digit corresponding to the value.

THROWSDESCRIPTION
Exception

If the value is not in the range 0-15.

method encode

Encode a character as hexadecimal.

DEFINITION
void  encode ( char  character );
PARAMETERDESCRIPTION
character

The character to encode.

method encode

Encode a string as hexadecimal.

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

The string to encode.

member indentprivate

The indentation string for continuation lines.

DEFINITION
std::string  indent;

member line_lengthprivate

The maximum length of a line. If 0, there is no maximum length.

DEFINITION
size_t  line_length;

member line_positionprivate

The current position in the line.

DEFINITION
size_t  line_position;

member streamprivate

The stream to write the encoded data to.

DEFINITION
std::ostream & stream;