map.h
[voxelands-alt.git] / inc / array.h
blob4e83af51ca3e5762ca682cd30765253d76787d92
1 #ifndef _ARRAY_H_
2 #define _ARRAY_H_
4 #include "common.h"
6 #include <stdint.h>
8 #define ARRAY_TYPE_NONE 0
9 #define ARRAY_TYPE_INT 1
10 #define ARRAY_TYPE_STRING 2
11 #define ARRAY_TYPE_FLOAT 3
12 #define ARRAY_TYPE_PTR 4
14 #ifndef _HAVE_ARRAY_TYPE
15 #define _HAVE_ARRAY_TYPE
16 typedef struct array_s {
17 uint32_t type;
18 uint32_t length;
19 uint32_t size;
20 void *data;
21 } array_t;
22 #endif
24 /* defined in array.c */
25 void array_init(array_t *a, uint32_t type);
26 array_t *array_create(uint32_t type);
27 array_t *array_copy(array_t *a);
28 int array_cmp(array_t *a1, array_t *a2);
29 void array_free(array_t *a, int freestruct);
30 int array_push_int(array_t *a, uint32_t v);
31 int array_push_float(array_t *a, float v);
32 int array_push_string(array_t *a, char* v);
33 int array_push_ptr(array_t *a, void *v);
34 int array_push_colour(array_t *a, colour_t *c);
35 int array_push_v3t(array_t *a, v3_t *v);
36 int array_push_v2t(array_t *a, v2_t *v);
37 int array_set_int(array_t *a, uint32_t v, int i);
38 int array_set_float(array_t *a, float v, int i);
39 int array_set_string(array_t *a, char* v, int i);
40 int array_set_ptr(array_t *a, void* v, int i);
41 uint32_t array_pop_int(array_t *a);
42 float array_pop_float(array_t *a);
43 char* array_pop_string(array_t *a);
44 void *array_pop_ptr(array_t *a);
45 uint32_t array_get_int(array_t *a, int i);
46 float array_get_float(array_t *a, int i);
47 char* array_get_string(array_t *a, int i);
48 void *array_get_ptr(array_t *a, int i);
49 int array_find_int(array_t *a, uint32_t v);
50 int array_find_float(array_t *a, float v);
51 int array_find_string(array_t *a, char* v);
52 int array_find_ptr(array_t *a, void *v);
53 int array_remove_string(array_t *a, char* v);
54 array_t *array_split(char* str, char* s);
55 char* array_join(array_t *a, char* glue, int start);
57 #endif