Skip to content

Commit

Permalink
Merge pull request #624 from ZettaScaleLabs/add_z_string_as_slice
Browse files Browse the repository at this point in the history
Add z_string_as_slice
  • Loading branch information
milyin authored Sep 5, 2024
2 parents 8b1e207 + 4e1eb02 commit 8af6e78
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ Primitives
.. autocfunction:: primitives.h::z_string_copy_from_substr
.. autocfunction:: primitives.h::z_string_empty
.. autocfunction:: primitives.h::z_string_is_empty
.. autocfunction:: primitives.h::z_string_as_slice
.. autocfunction:: primitives.h::z_hello_zid
.. autocfunction:: primitives.h::z_hello_whatami
.. autocfunction:: primitives.h::z_hello_locators
Expand Down
10 changes: 10 additions & 0 deletions include/zenoh-pico/api/primitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,16 @@ int8_t z_string_copy_from_substr(z_owned_string_t *str, const char *value, size_
*/
bool z_string_is_empty(const z_loaned_string_t *str);

/**
* Returns :c:type:`z_loaned_slice_t` for the string
*
* Parameters:
* str: Pointer to a :c:type:`z_loaned_string_t` to get slice.
* Return:
* slice containing string data
*/
const z_loaned_slice_t *z_string_as_slice(const z_loaned_string_t *str);

/**
* Returns id of Zenoh entity that transmitted hello message.
*
Expand Down
2 changes: 2 additions & 0 deletions src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,8 @@ int8_t z_string_copy_from_substr(z_owned_string_t *str, const char *value, size_

bool z_string_is_empty(const z_loaned_string_t *str) { return _z_string_is_empty(str); }

const z_loaned_slice_t *z_string_as_slice(const z_loaned_string_t *str) { return &str->_slice; }

#if Z_FEATURE_PUBLICATION == 1
int8_t _z_undeclare_and_clear_publisher(_z_publisher_t *pub) {
int8_t ret = _Z_RES_OK;
Expand Down

0 comments on commit 8af6e78

Please sign in to comment.