Delta Chat Core C-API
 All Classes Functions Typedefs Groups Pages
Public Member Functions | List of all members
dc_array_t Class Reference

An object containing a simple array. More...

#include <deltachat.h>

Public Member Functions

size_t dc_array_get_cnt (const dc_array_t *array)
 Find out the number of items in an array. More...
 
uint32_t dc_array_get_id (const dc_array_t *array, size_t index)
 Get the item at the given index as an ID. More...
 
void * dc_array_get_ptr (const dc_array_t *array, size_t index)
 Get the item at the given index as an ID. More...
 
const uintptr_t * dc_array_get_raw (const dc_array_t *array)
 Get raw pointer to the data. More...
 
uintptr_t dc_array_get_uint (const dc_array_t *array, size_t index)
 Get the item at the given index as an unsigned integer. More...
 
void dc_array_unref (dc_array_t *array)
 Free an array object. More...
 

Detailed Description

An object containing a simple array.

This object is used in several places where functions need to return an array. The items of the array are typically IDs. To free an array object, use dc_array_unref().

Member Function Documentation

size_t dc_array_get_cnt ( const dc_array_t array)

Find out the number of items in an array.

Parameters
arrayThe array object.
Returns
Returns the number of items in a dc_array_t object. 0 on errors or if the array is empty.
uint32_t dc_array_get_id ( const dc_array_t array,
size_t  index 
)

Get the item at the given index as an ID.

Parameters
arrayThe array object.
indexIndex of the item to get. Must be between 0 and dc_array_get_cnt()-1.
Returns
Returns the item at the given index. Returns 0 on errors or if the array is empty.
void * dc_array_get_ptr ( const dc_array_t array,
size_t  index 
)

Get the item at the given index as an ID.

Parameters
arrayThe array object.
indexIndex of the item to get. Must be between 0 and dc_array_get_cnt()-1.
Returns
Returns the item at the given index. Returns 0 on errors or if the array is empty.
const uintptr_t * dc_array_get_raw ( const dc_array_t array)

Get raw pointer to the data.

Parameters
arrayThe array object.
Returns
Raw pointer to the array. You MUST NOT free the data. You MUST NOT access the data beyond the current item count. It is not possible to enlarge the array this way. Calling any other dc_array*()-function may discard the returned pointer.
uintptr_t dc_array_get_uint ( const dc_array_t array,
size_t  index 
)

Get the item at the given index as an unsigned integer.

The size of the integer is always larget enough to hold a pointer.

Parameters
arrayThe array object.
indexIndex of the item to get. Must be between 0 and dc_array_get_cnt()-1.
Returns
Returns the item at the given index. Returns 0 on errors or if the array is empty.
void dc_array_unref ( dc_array_t array)

Free an array object.

Does not free any data items.

Parameters
arrayThe array object to free, created eg. by dc_get_chatlist(), dc_get_contacts() and so on. If NULL is given, nothing is done.
Returns
None.

The documentation for this class was generated from the following files: