hex::Decoder
Decoder
#include <icy/hex.h>
struct DecoderDefined in src/base/include/icy/hex.h:111
- Inherits
Decoder
List of all members
| Name | Kind | Owner |
|---|---|---|
lastbyte | variable | Declared here |
Decoder | function | Declared here |
~Decoder | function | Declared here |
decode | function | Declared here |
finalize | function | Declared here |
readnext | function | Declared here |
nybble | function | Declared here |
iswspace | function | Declared here |
Decoder | function | Inherited from Decoder |
~Decoder | function | Inherited from Decoder |
decode | function | Inherited from Decoder |
finalize | function | Inherited from Decoder |
Inherited from Decoder
| Kind | Name | Description |
|---|---|---|
function | Decoder | Defaulted constructor. |
function | ~Decoder virtual | Defaulted destructor. |
function | decode virtual | Decodes nread bytes from inbuf and writes decoded output to outbuf. |
function | finalize virtual inline | Flushes any buffered state and writes final output to outbuf. |
Public Attributes
| Return | Name | Description |
|---|---|---|
char | lastbyte |
lastbyte
char lastbyteDefined in src/base/include/icy/hex.h:201
Public Methods
| Return | Name | Description |
|---|---|---|
Decoder inline | ||
~Decoder virtual inline | ||
ssize_t | decode virtual inline override | Decodes hex-encoded input to binary. Whitespace in the input is ignored. A trailing unpaired nibble is buffered and prepended on the next call. |
ssize_t | finalize virtual inline override | No-op finalizer; hex decoding has no pending output state. |
bool | readnext inline | Reads the next non-whitespace character from inbuf, prepending any buffered lastbyte before consuming from the stream. |
int | nybble inline | Converts an ASCII hex character to its 4-bit integer value. |
bool | iswspace inline | Returns true if c is an ASCII whitespace character (space, CR, tab, LF). |
Decoder
inline
inline Decoder()Defined in src/base/include/icy/hex.h:113
~Decoder
virtual inline
virtual inline ~Decoder()Defined in src/base/include/icy/hex.h:117
Reimplements
decode
virtual inline override
virtual inline ssize_t decode(const char * inbuf, size_t nread, char * outbuf) overrideDefined in src/base/include/icy/hex.h:125
Decodes hex-encoded input to binary. Whitespace in the input is ignored. A trailing unpaired nibble is buffered and prepended on the next call.
Returns
Number of decoded bytes written to outbuf.
Reimplements
Parameters
| Parameter | Type | Description |
|---|---|---|
inbuf | const char * | Hex-encoded input buffer. |
nread | size_t | Number of bytes to read from inbuf. |
outbuf | char * | Destination buffer; must have capacity >= nread / 2. |
finalize
virtual inline override
virtual inline ssize_t finalize(char *) overrideDefined in src/base/include/icy/hex.h:152
No-op finalizer; hex decoding has no pending output state.
Returns
Always 0.
Reimplements
readnext
inline
inline bool readnext(const char * inbuf, size_t nread, size_t & rpos, char & c)Defined in src/base/include/icy/hex.h:161
Reads the next non-whitespace character from inbuf, prepending any buffered lastbyte before consuming from the stream.
Returns
true if more input remains after c was read, false otherwise.
Parameters
| Parameter | Type | Description |
|---|---|---|
inbuf | const char * | Input buffer. |
nread | size_t | Total bytes in inbuf. |
rpos | size_t & | Current read position; advanced on each consumed byte. |
c | char & | Output: the next non-whitespace character. |
nybble
inline
inline int nybble(const int n)Defined in src/base/include/icy/hex.h:181
Converts an ASCII hex character to its 4-bit integer value.
Returns
Integer value in the range [0, 15].
Parameters
| Parameter | Type | Description |
|---|---|---|
n | const int | ASCII character ('0'-'9', 'a'-'f', 'A'-'F'). |
Exceptions
| Exception | Description |
|---|---|
std::runtime_error | if n is not a valid hex character. |
iswspace
inline
inline bool iswspace(const char c)Defined in src/base/include/icy/hex.h:196
Returns true if c is an ASCII whitespace character (space, CR, tab, LF).
Returns
true if c is whitespace.
Parameters
| Parameter | Type | Description |
|---|---|---|
c | const char | Character to test. |
