Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add z_string_array documentation #684

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,12 @@ Primitives
.. autocfunction:: primitives.h::z_keyexpr_from_substr
.. autocfunction:: primitives.h::z_keyexpr_from_str_autocanonize
.. autocfunction:: primitives.h::z_keyexpr_from_substr_autocanonize
.. autocfunction:: primitives.h::z_string_array_new
.. autocfunction:: primitives.h::z_string_array_push_by_alias
.. autocfunction:: primitives.h::z_string_array_push_by_copy
.. autocfunction:: primitives.h::z_string_array_get
.. autocfunction:: primitives.h::z_string_array_len
.. autocfunction:: primitives.h::z_string_array_is_empty
.. autocfunction:: primitives.h::z_declare_keyexpr
.. autocfunction:: primitives.h::z_undeclare_keyexpr
.. autocfunction:: primitives.h::z_subscriber_options_default
Expand Down
54 changes: 54 additions & 0 deletions include/zenoh-pico/api/primitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -2142,6 +2142,60 @@ z_result_t z_declare_keyexpr(z_owned_keyexpr_t *declared_keyexpr, const z_loaned
*/
z_result_t z_undeclare_keyexpr(z_moved_keyexpr_t *keyexpr, const z_loaned_session_t *zs);

/**
* Constructs a new empty string array.
*
* Parameters:
* a: Pointer to an uninitialized :c:type:`z_owned_string_array_t` to store the array of strings.
*/
void z_string_array_new(z_owned_string_array_t *a);

/**
* Appends specified value to the end of the string array by alias.
*
* Parameters:
* a: Pointer to :c:type:`z_loaned_string_array_t`.
* value: Pointer to the string to be add.
*
* Return:
* the new length of the array.
*/
size_t z_string_array_push_by_alias(z_loaned_string_array_t *a, const z_loaned_string_t *value);

/**
* Appends specified value to the end of the string array by copying.
*
* Parameters:
* a: Pointer to :c:type:`z_loaned_string_array_t`.
* value: Pointer to the string to be add.
*
* Return:
* the new length of the array.
*/
size_t z_string_array_push_by_copy(z_loaned_string_array_t *a, const z_loaned_string_t *value);

/**
* Returns the value at the position of index in the string array.
*
* Parameters:
* a: Pointer to :c:type:`z_loaned_string_array_t`.
* k: index value.
*
* Return:
* `NULL` if the index is out of bounds.
*/
const z_loaned_string_t *z_string_array_get(const z_loaned_string_array_t *a, size_t k);

/**
* Returns number of elements in the array.
*/
size_t z_string_array_len(const z_loaned_string_array_t *a);

/**
* Returns ``true`` if the array is empty, ``false`` otherwise.
*/
bool z_string_array_is_empty(const z_loaned_string_array_t *a);

#if Z_FEATURE_SUBSCRIPTION == 1
/**
* Builds a :c:type:`z_subscriber_options_t` with default values.
Expand Down
7 changes: 0 additions & 7 deletions include/zenoh-pico/api/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,13 +487,6 @@ _Z_OWNED_TYPE_VALUE(_z_reply_t, reply)
_Z_OWNED_TYPE_VALUE(_z_string_svec_t, string_array)
_Z_VIEW_TYPE(_z_string_svec_t, string_array)

void z_string_array_new(z_owned_string_array_t *a);
size_t z_string_array_push_by_alias(z_loaned_string_array_t *a, const z_loaned_string_t *value);
size_t z_string_array_push_by_copy(z_loaned_string_array_t *a, const z_loaned_string_t *value);
const z_loaned_string_t *z_string_array_get(const z_loaned_string_array_t *a, size_t k);
size_t z_string_array_len(const z_loaned_string_array_t *a);
bool z_string_array_is_empty(const z_loaned_string_array_t *a);

typedef void (*z_dropper_handler_t)(void *arg);
typedef _z_data_handler_t z_data_handler_t;

Expand Down
Loading