iisacc logo

LVRS Document Viewer

backend/RouteMatcher.svx

Path: backend/RouteMatcher.svx

Last modified:

RouteMatcher

Location: backend/navigation/routematcher.h / backend/navigation/routematcher.cpp

RouteMatcher is a QML singleton that moves PageRouter path normalization/matching hot paths into C++.

Purpose

  • Apply consistent rules for path normalization (normalizePath).
  • Perform dynamic segment ([id]) and rest segment ([...path]) matching in C++.
  • Reduce repeated string split/join overhead in QML JS loops.

API

  • normalizePath(path): string
    • Normalize empty input to /.
    • Ensure a leading /.
    • Remove trailing / except for root (/).
  • match(path, routePath): map
    • Returns:
      • matched: bool
      • params: map
    • Examples:
      • ("/runs/42", "/runs/[id]") -> matched=true, params.id="42"
      • ("/logs/a/b", "/logs/[...path]") -> matched=true, params.path="a/b"

Notes

  • PageRouter.qml prefers RouteMatcher, and keeps a JS fallback path when unavailable.
  • Match results are stored in the PageRouter route-resolve cache to further reduce repeated lookup cost.