#include <icy/hex.h>Inherits:
Decoder
Hex decoder.
| Return | Name | Description |
|---|---|---|
char | lastbyte |
char lastbyte| Return | Name | Description |
|---|---|---|
Decoder inline | ||
ssize_t | decode virtual inline | 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 | 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). |
inline
inline Decoder()virtual inline
virtual inline ssize_t decode(const char * inbuf, size_t nread, char * outbuf)Decodes hex-encoded input to binary. Whitespace in the input is ignored. A trailing unpaired nibble is buffered and prepended on the next call.
inbuf Hex-encoded input buffer.
nread Number of bytes to read from inbuf.
outbuf Destination buffer; must have capacity >= nread / 2.
Number of decoded bytes written to outbuf.
virtual inline
virtual inline ssize_t finalize(char *)No-op finalizer; hex decoding has no pending output state.
Always 0.
inline
inline bool readnext(const char * inbuf, size_t nread, size_t & rpos, char & c)Reads the next non-whitespace character from inbuf, prepending any buffered lastbyte before consuming from the stream.
inbuf Input buffer.
nread Total bytes in inbuf.
rpos Current read position; advanced on each consumed byte.
c Output: the next non-whitespace character.
true if more input remains after c was read, false otherwise.
inline
inline int nybble(const int n)Converts an ASCII hex character to its 4-bit integer value.
n ASCII character ('0'-'9', 'a'-'f', 'A'-'F').Integer value in the range [0, 15].
std::runtime_error if n is not a valid hex character.inline
inline bool iswspace(const char c)Returns true if c is an ASCII whitespace character (space, CR, tab, LF).
c Character to test.true if c is whitespace.