Delta Chat Core C-API
mrarray.h
1 /*******************************************************************************
2  *
3  * Delta Chat Core
4  * Copyright (C) 2017 Björn Petersen
5  * Contact: r10s@b44t.com, http://b44t.com
6  *
7  * This program is free software: you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later
10  * version.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program. If not, see http://www.gnu.org/licenses/ .
19  *
20  ******************************************************************************/
21 
22 
23 #ifndef __MRARRAY_H__
24 #define __MRARRAY_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 typedef struct _mrmailbox mrmailbox_t;
31 
32 
41 typedef struct _mrarray mrarray_t;
42 
43 
44 mrarray_t* mrarray_new (mrmailbox_t*, size_t initsize);
45 void mrarray_empty (mrarray_t*);
46 void mrarray_unref (mrarray_t*);
47 
48 void mrarray_add_uint (mrarray_t*, uintptr_t);
49 void mrarray_add_id (mrarray_t*, uint32_t);
50 void mrarray_add_ptr (mrarray_t*, void*);
51 
52 size_t mrarray_get_cnt (mrarray_t*);
53 uintptr_t mrarray_get_uint (mrarray_t*, size_t index);
54 uint32_t mrarray_get_id (mrarray_t*, size_t index);
55 void* mrarray_get_ptr (mrarray_t*, size_t index);
56 
57 int mrarray_search_id (mrarray_t*, uint32_t needle, size_t* indx);
58 const uintptr_t* mrarray_get_raw (mrarray_t*);
59 
60 
61 #ifdef __cplusplus
62 } /* /extern "C" */
63 #endif
64 #endif /* __MRARRAY_H__ */
65 
An object containing a simple array.
uintptr_t mrarray_get_uint(mrarray_t *array, size_t index)
Get the item at the given index as an unsigned integer.
Definition: mrarray.c:195
An object representing a single mailbox.
void * mrarray_get_ptr(mrarray_t *array, size_t index)
Get the item at the given index as an ID.
Definition: mrarray.c:235
size_t mrarray_get_cnt(mrarray_t *array)
Find out the number of items in an array.
Definition: mrarray.c:174
uint32_t mrarray_get_id(mrarray_t *array, size_t index)
Get the item at the given index as an ID.
Definition: mrarray.c:215
void mrarray_unref(mrarray_t *array)
Free an array object.
Definition: mrarray.c:71