11# Writing a MessageParser Plugin
22
3- > ** Tracks the v4 plugin ABI** (` PJ_ABI_VERSION == 4 ` ). The parser
3+ > ** Tracks the v5 plugin ABI** (` PJ_ABI_VERSION == 5 ` ). The parser
44> write-host supports per-record writes and an optional Arrow stream
55> batch path for parser-shaped formats that naturally decode batches.
66> For ABI evolution rules, error semantics, and noexcept discipline see
@@ -534,21 +534,18 @@ depth image, point cloud, image annotations, frame transforms) returned by name
534534from the parser, decoded once, and visualised by widgets that never learn the
535535wire format.
536536
537- Three optional virtual entry points on ` MessageParserPluginBase `
537+ The table-driven ` SchemaHandler ` routes on ` MessageParserPluginBase `
538538participate:
539539
540540``` cpp
541- // In your subclass — every override is optional. The base provides
542- // safe `unexpected(...)` defaults so legacy parsers compile unchanged.
543- PJ ::Expected<PJ ::sdk::SchemaClassification>
544- classifySchema (std::string_view type_name,
545- PJ::Span<const uint8_t > schema) override;
546-
547- PJ::Expected< std::vector<PJ::sdk::NamedFieldValue > >
548- parseScalars(PJ::Timestamp ts, PJ::sdk::PayloadView payload) override;
549-
550- PJ::Expected< PJ::sdk::BuiltinObject >
551- parseObject(PJ::Timestamp ts, PJ::sdk::PayloadView payload) override;
541+ PJ ::sdk::SchemaHandler handler;
542+ handler.object_type = PJ ::sdk::BuiltinObjectType::kImage ;
543+ handler.parse_scalars =
544+ [](PJ ::Timestamp ts, PJ ::Span<const uint8_t > payload)
545+ -> PJ ::Expected<PJ ::sdk::ScalarRecord> { /* ... * / };
546+ handler.parse_object =
547+ [ ] (PJ::Timestamp ts, PJ::sdk::PayloadView payload)
548+ -> PJ::Expected< PJ::sdk::ObjectRecord > { /* ... * / };
552549```
553550
554551- `classifySchema` is the *a-priori* declaration — given a type name +
@@ -557,12 +554,13 @@ parseObject(PJ::Timestamp ts, PJ::sdk::PayloadView payload) override;
557554 `kNone`) this schema produces. The host consults the answer **before** it
558555 ever sees the payload, so it can pick the right `ObjectIngestPolicy` for the
559556 topic.
560- - `parseScalars` writes the small-metadata fields (`width`, `height`,
561- `frame_id`, …) that should land in the curve tree as scalar columns.
562- - `parseObject` returns the actual builtin value, type-erased as
563- `PJ::sdk::BuiltinObject` (which is `std::any`). The host downcasts
564- with `std::any_cast<PJ::sdk::Image>(&obj)` to dispatch to the
565- matching viewer.
557+ - `parse_scalars` returns a `ScalarRecord`: small-metadata fields
558+ (`width`, `height`, `frame_id`, …) plus an optional parser-controlled
559+ timestamp.
560+ - `parse_object` returns an `ObjectRecord`: the actual builtin value,
561+ type-erased as `PJ::sdk::BuiltinObject` (which is `std::any`), plus an
562+ optional parser-controlled timestamp. The host downcasts with
563+ `std::any_cast<PJ::sdk::Image>(&obj)` to dispatch to the matching viewer.
566564
567565Builtin types live under `pj_base/builtin/`, one header per
568566type. `sdk::Image` carries an open-ended `std::string encoding`
0 commit comments