37 void Push(
const uint8_t* data, std::size_t length);
39 void Reset(
bool resetErrorState =
true);
48 void EmitError(
PacketError error, std::size_t offset);
50 void WriteToBuffer(
const uint8_t* data, std::size_t length);
51 void CopyOut(std::size_t offset, std::size_t length, uint8_t* dest)
const;
52 void Discard(std::size_t count);
53 void ParseBuffer(std::size_t& iterationBudget);
54 std::size_t FindNextHeaderCandidate()
const;
60 std::vector<uint8_t> m_buffer;
61 std::vector<uint8_t> m_decodeScratch;
62 std::size_t m_head{0};
63 std::size_t m_size{0};
64 std::size_t m_streamOffset{0};
65 uint64_t m_consecutiveErrors{0};
Parses a byte stream into BCNP packets.
static constexpr std::size_t kMaxParseIterationsPerPush
std::function< void(const PacketView &)> PacketCallback
void SetWireSizeLookup(WireSizeLookup lookup)
Set custom wire size lookup (for testing with custom message types)
StreamParser(PacketCallback onPacket, ErrorCallback onError={}, std::size_t bufferSize=4096)
Construct a stream parser with callbacks and buffer size.
void Reset(bool resetErrorState=true)
Reset the parser to its initial state.
std::function< std::size_t(MessageTypeId)> WireSizeLookup
std::function< void(const ErrorInfo &)> ErrorCallback
void Push(const uint8_t *data, std::size_t length)
Push raw bytes into the parser for processing.
PacketError
Error codes returned by packet decoding operations.
@ None
No error - packet decoded successfully.
BCNP packet structures, encoding, and decoding utilities.
Zero-copy view into a decoded packet buffer.
uint64_t consecutiveErrors