Skip to content

Latest commit

 

History

History
54 lines (43 loc) · 2.37 KB

File metadata and controls

54 lines (43 loc) · 2.37 KB

FluxParse API Reference

Namespaces

  • fp: Core public API.
  • fp::detail: Internal implementation details and concepts (not for public use).

Enums

fp::ParseResult

Return type for all parsing operations. Annotated with [[nodiscard]].

  • Complete (0): The parser successfully matched the token.
  • Incomplete (1): The fragment ended mid-token. Call feed() again with the next chunk.
  • Mismatch (2): An unexpected byte was encountered. The protocol was violated.
  • ChainComplete (3): All states within a Chain have successfully matched in sequence.
  • ChainAdvanced (4): A single state within a Chain matched, and the chain has advanced to its next state.

Core Types

fp::FragmentContext

A 64-byte stack-allocated structure that preserves parser state across fragmented TCP chunks.

  • Methods:
    • constexpr void reset() noexcept: Resets matched_bytes and state_index to 0. (Does not reset total_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 a Chain.
    • std::uint32_t total_consumed: Bytes consumed across the current feed() loop.

fp::InlineParser<Token, Action>

Atomic parser matching a specific string literal.

  • Template Parameters:
    • Token: An fp::detail::FixedString representing the bytes to match (e.g., "GET").
    • Action: An optional action policy invoked upon a complete match. Defaults to fp::NullAction.
  • Methods:
    • ParseResult feed(std::span<const std::byte> data, FragmentContext& ctx) const noexcept

fp::Chain<Parsers...>

Composes multiple parsers sequentially.

  • Template Parameters:
    • Parsers...: A list of types satisfying fp::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.

Actions & Helpers

fp::NullAction

A zero-overhead, empty action policy. Used by default.

fp::make_parser<Token>(callback)

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"; });