Skip to content

Commit

Permalink
feat: add keyexpr_was_declared api function
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Jan 9, 2024
1 parent 7d79a14 commit 10d2f2e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/zenoh-pico/api/primitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ z_owned_str_t z_keyexpr_to_string(z_keyexpr_t keyexpr);
*/
z_bytes_t z_keyexpr_as_bytes(z_keyexpr_t keyexpr);

/**
* Indicates if the key expression has been declared but don't guarantee it's still in session.
*
* Parameters:
* keyexpr: A loaned instance of :c:type:`z_keyexpr_t`
*
* Returns:
* Returns ``true`` if the keyexpr was declared or ``false`` otherwise.
*/
_Bool zp_keyexpr_was_declared(const z_keyexpr_t *keyexpr);

/**
* Constructs a null-terminated string departing from a :c:type:`z_keyexpr_t` for a given :c:type:`z_session_t`.
* The user is responsible of dropping the returned string using ``z_free``.
Expand Down
8 changes: 8 additions & 0 deletions src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ z_bytes_t z_keyexpr_as_bytes(z_keyexpr_t keyexpr) {
}
}

_Bool zp_keyexpr_was_declared(const z_keyexpr_t *keyexpr) {

Check warning

Code scanning / Cppcheck (reported by Codacy)

misra violation 804 with no text in the supplied rule-texts-file Warning

misra violation 804 with no text in the supplied rule-texts-file
_Bool ret = false;
if (keyexpr->_id != Z_RESOURCE_ID_NONE) {
ret = true;
}
return ret;
}

z_owned_str_t zp_keyexpr_resolve(z_session_t zs, z_keyexpr_t keyexpr) {
z_owned_str_t ret = {._value = NULL};

Expand Down

0 comments on commit 10d2f2e

Please sign in to comment.