microfmt
Zero-allocation C++ formatting for constrained environments
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
microfmt::gdb::gdb_streaming_decoder Class Reference

Stateful streaming decoder for incoming GDB Remote Serial Protocol packets. More...

#include <gdb_stream.hpp>

Public Types

enum class  status : uint8_t {
  in_progress , ready , error_overflow , error_checksum ,
  error_format
}
 Status returned after feeding a byte into the decoder. More...
 

Public Member Functions

constexpr gdb_streaming_decoder (span< char > payload_scratch RELOCO_LIFETIMEBOUND RELOCO_LIFETIME_CAPTURE_BY_THIS) noexcept
 Constructs a streaming decoder over a caller-provided scratch span.
 
constexpr void reset () noexcept
 Resets the decoder state machine back to waiting for a new packet start ('$').
 
RELOCO_BEGIN_UNSAFE_CODE constexpr status feed (char c) noexcept
 Feeds a single incoming character into the stateful decoder.
 
RELOCO_END_UNSAFE_CODE constexpr string_view payload () const noexcept RELOCO_LIFETIMEBOUND
 Returns a non-owning string view over the fully unescaped packet payload. Valid only when feed() returns status::ready.
 

Detailed Description

Stateful streaming decoder for incoming GDB Remote Serial Protocol packets.

Designed for byte-by-byte ingestion (e.g., from UART RX ring buffers or interrupts) with zero heap allocation and strict stack safety.

Member Enumeration Documentation

◆ status

enum class microfmt::gdb::gdb_streaming_decoder::status : uint8_t
strong

Status returned after feeding a byte into the decoder.

Enumerator
in_progress 
ready 
error_overflow 
error_checksum 
error_format 

Constructor & Destructor Documentation

◆ gdb_streaming_decoder()

constexpr microfmt::gdb::gdb_streaming_decoder::gdb_streaming_decoder ( span< char > payload_scratch RELOCO_LIFETIMEBOUND  RELOCO_LIFETIME_CAPTURE_BY_THIS)
inlineexplicitconstexprnoexcept

Constructs a streaming decoder over a caller-provided scratch span.

Parameters
payload_scratchCaller-owned memory buffer to unescape and store the decoded payload.

Member Function Documentation

◆ feed()

RELOCO_BEGIN_UNSAFE_CODE constexpr status microfmt::gdb::gdb_streaming_decoder::feed ( char  c)
inlineconstexprnoexcept

Feeds a single incoming character into the stateful decoder.

Parameters
cIncoming character from serial/UART stream.
Returns
status indicating whether a complete packet is ready or an error occurred.

◆ payload()

RELOCO_END_UNSAFE_CODE constexpr string_view microfmt::gdb::gdb_streaming_decoder::payload ( ) const
inlineconstexprnoexcept

Returns a non-owning string view over the fully unescaped packet payload. Valid only when feed() returns status::ready.

◆ reset()

constexpr void microfmt::gdb::gdb_streaming_decoder::reset ( )
inlineconstexprnoexcept

Resets the decoder state machine back to waiting for a new packet start ('$').


The documentation for this class was generated from the following file: