fp: Core public API.fp::detail: Internal implementation details and concepts (not for public use).
Return type for all parsing operations. Annotated with [[nodiscard]].
Complete(0): The parser successfully matched the token.Incomplete(1): The fragment ended mid-token. Callfeed()again with the next chunk.Mismatch(2): An unexpected byte was encountered. The protocol was violated.ChainComplete(3): All states within aChainhave successfully matched in sequence.ChainAdvanced(4): A single state within aChainmatched, and the chain has advanced to its next state.
A 64-byte stack-allocated structure that preserves parser state across fragmented TCP chunks.
- Methods:
constexpr void reset() noexcept: Resetsmatched_bytesandstate_indexto 0. (Does not resettotal_consumed).constexpr bool is_at_start() const noexcept: Returns true if the parser is at its initial state.
- Fields:
std::uint32_t matched_bytes: Bytes consumed in the current token.std::uint32_t state_index: The index of the active parser within aChain.std::uint32_t total_consumed: Bytes consumed across the currentfeed()loop.
Atomic parser matching a specific string literal.
- Template Parameters:
Token: Anfp::detail::FixedStringrepresenting the bytes to match (e.g.,"GET").Action: An optional action policy invoked upon a complete match. Defaults tofp::NullAction.
- Methods:
ParseResult feed(std::span<const std::byte> data, FragmentContext& ctx) const noexcept
Composes multiple parsers sequentially.
- Template Parameters:
Parsers...: A list of types satisfyingfp::detail::ParserUnit. Max depth is 32.
- Methods:
ParseResult feed(std::span<const std::byte> data, FragmentContext& ctx) const noexcept: Loops through the data, advancing the state machine as tokens match.
A zero-overhead, empty action policy. Used by default.
A factory function that automatically wraps a noexcept lambda or function into a CallbackAction.
auto parser = fp::make_parser<"GET">([]() noexcept { std::cout << "Matched!\n"; });