KeyExpr constructor

KeyExpr(
  1. String expr
)

Creates a KeyExpr from the given key expression string.

Throws ZenohException if expr is not a valid key expression (e.g., empty string).

Implementation

KeyExpr(String expr)
  : _kePtr = calloc.allocate(bindings.zd_view_keyexpr_sizeof()),
    _nativeStr = expr.toNativeUtf8() {
  final rc = bindings.zd_view_keyexpr_from_str(
    _kePtr.cast(),
    _nativeStr.cast(),
  );
  if (rc != 0) {
    malloc.free(_nativeStr);
    calloc.free(_kePtr);
    throw ZenohException('Invalid key expression: "$expr"', rc);
  }
}