Home
Base module

hex::Encoder

Hex encoder.

Encoder

#include <icy/hex.h>
struct Encoder

Defined in src/base/include/icy/hex.h:34

Inherits: Encoder

Hex encoder.

List of all members

NameKindOwner
_linePosvariableDeclared here
_lineLengthvariableDeclared here
_uppercasevariableDeclared here
EncoderfunctionDeclared here
encodefunctionDeclared here
finalizefunctionDeclared here
setUppercasefunctionDeclared here
setLineLengthfunctionDeclared here
EncoderfunctionInherited from Encoder
~EncoderfunctionInherited from Encoder
encodefunctionInherited from Encoder
finalizefunctionInherited from Encoder

Inherited from Encoder

KindNameDescription
functionEncoderDefaulted constructor.
function~Encoder virtualDefaulted destructor.
functionencode virtualEncodes nread bytes from inbuf and writes encoded output to outbuf.
functionfinalize virtual inlineFlushes any buffered state and writes final output to outbuf.

Public Attributes

ReturnNameDescription
int_linePos
int_lineLength
int_uppercase

_linePos

int _linePos

Defined in src/base/include/icy/hex.h:83


_lineLength

int _lineLength

Defined in src/base/include/icy/hex.h:84


_uppercase

int _uppercase

Defined in src/base/include/icy/hex.h:85

Public Methods

ReturnNameDescription
Encoder inline
ssize_tencode virtual inline overrideEncodes binary input as lowercase hex characters, optionally inserting newlines every _lineLength output characters.
ssize_tfinalize virtual inline overrideNo-op finalizer; hex encoding has no pending state.
voidsetUppercase inlineControls whether encoded output uses uppercase hex digits (A-F) or lowercase (a-f).
voidsetLineLength inlineSets the maximum number of output characters per line before a newline is inserted. Set to 0 to disable line wrapping.

Encoder

inline

inline Encoder()

Defined in src/base/include/icy/hex.h:36


encode

virtual inline override

virtual inline ssize_t encode(const char * inbuf, size_t nread, char * outbuf) override

Defined in src/base/include/icy/hex.h:49

Encodes binary input as lowercase hex characters, optionally inserting newlines every _lineLength output characters.

Parameters

  • inbuf Input buffer to encode.

  • nread Number of bytes to read from inbuf.

  • outbuf Destination buffer; must have capacity >= nread * 2 + nread/_lineLength + 1.

Returns

Number of bytes written to outbuf.

Reimplements

finalize

virtual inline override

virtual inline ssize_t finalize(char *) override

Defined in src/base/include/icy/hex.h:72

No-op finalizer; hex encoding has no pending state.

Returns

Always 0.

Reimplements

setUppercase

inline

inline void setUppercase(bool flag)

Defined in src/base/include/icy/hex.h:76

Controls whether encoded output uses uppercase hex digits (A-F) or lowercase (a-f).

Parameters

  • flag true for uppercase, false for lowercase.

setLineLength

inline

inline void setLineLength(int lineLength)

Defined in src/base/include/icy/hex.h:81

Sets the maximum number of output characters per line before a newline is inserted. Set to 0 to disable line wrapping.

Parameters

  • lineLength Characters per line.