FreeBASIC  0.91.0
fb_array.h
Go to the documentation of this file.
1 typedef struct _FBARRAYDIM {
2  size_t elements;
3  ssize_t lbound;
4  ssize_t ubound;
5 } FBARRAYDIM;
6 
7 typedef struct _FBARRAY {
8  void *data; /* ptr + diff, must be at ofs 0! */
9  void *ptr;
10  size_t size;
11  size_t element_len;
12  size_t dimensions;
13  FBARRAYDIM dimTB[1]; /* dimtb[dimensions] */
14 } FBARRAY;
15 
17 typedef struct _FB_ARRAY_TMPDESC {
19 
25 typedef void (*FB_DEFCTOR) ( const void *this_ );
26 typedef void (*FB_DTORMULT) ( FBARRAY *array, FB_DEFCTOR dtor, size_t base_idx );
27 
28 
29 #define FB_ARRAY_SETDESC(_array, _elen, _dims, _size, _diff) \
30  do { \
31  _array->element_len = _elen; \
32  _array->dimensions = _dims; \
33  _array->size = _size; \
34  \
35  if( _array->ptr != NULL ) \
36  _array->data = ((unsigned char*) _array->ptr) + (_diff); \
37  else \
38  _array->data = NULL; \
39  } while (0)
40 
42  (
43  ssize_t idx,
44  ssize_t lbound,
45  ssize_t ubound,
46  int linenum,
47  const char *fname
48  );
49 
51  (
52  size_t idx,
53  size_t ubound,
54  int linenum,
55  const char *fname
56  );
57 
58  void fb_hArrayCtorObj ( FBARRAY *array, FB_DEFCTOR ctor, size_t base_idx );
59  void fb_hArrayDtorObj ( FBARRAY *array, FB_DEFCTOR dtor, size_t base_idx );
60  void fb_hArrayDtorStr ( FBARRAY *array, FB_DEFCTOR dtor, size_t base_idx );
61 FBCALL void fb_ArrayDestructObj ( FBARRAY *array, FB_DEFCTOR dtor );
62 FBCALL void fb_ArrayDestructStr ( FBARRAY *array );
63 FBCALL int fb_ArrayClear ( FBARRAY *array, int isvarlen );
64 FBCALL int fb_ArrayClearObj ( FBARRAY *array, FB_DEFCTOR ctor, FB_DEFCTOR dtor, int dofill );
65 FBCALL int fb_ArrayErase ( FBARRAY *array, int isvarlen );
66 FBCALL int fb_ArrayEraseObj ( FBARRAY *array, FB_DEFCTOR dtor );
67 FBCALL void fb_ArrayStrErase ( FBARRAY *array );
68  int fb_ArrayRedim ( FBARRAY *array, size_t element_len, int preserve, size_t dimensions, ... );
69  int fb_ArrayRedimEx ( FBARRAY *array, size_t element_len, int doclear, int isvarlen, size_t dimensions, ... );
70  int fb_ArrayRedimObj ( FBARRAY *array, size_t element_len, FB_DEFCTOR ctor, FB_DEFCTOR dtor, size_t dimensions, ... );
71  int fb_ArrayRedimPresv ( FBARRAY *array, size_t element_len, int preserve, size_t dimensions, ... );
72  int fb_ArrayRedimPresvEx ( FBARRAY *array, size_t element_len, int doclear, int isvarlen, size_t dimensions, ... );
73  int fb_ArrayRedimPresvObj( FBARRAY *array, size_t element_len, FB_DEFCTOR ctor, FB_DEFCTOR dtor, size_t dimensions, ... );
74 FBCALL void fb_ArrayResetDesc ( FBARRAY *array );
75 FBCALL ssize_t fb_ArrayLBound ( FBARRAY *array, ssize_t dimension );
76 FBCALL ssize_t fb_ArrayUBound ( FBARRAY *array, ssize_t dimension );
77  size_t fb_hArrayCalcElements( size_t dimensions, const ssize_t *lboundTB, const ssize_t *uboundTB );
78  ssize_t fb_hArrayCalcDiff ( size_t dimensions, const ssize_t *lboundTB, const ssize_t *uboundTB );
79 
81  (
82  FBARRAY *array,
83  size_t element_len,
84  int doclear,
85  FB_DEFCTOR ctor,
86  size_t dimensions,
87  va_list ap
88  );
89 
91  (
92  FBARRAY *array,
93  size_t element_len,
94  int doclear,
95  FB_DEFCTOR ctor,
96  FB_DTORMULT dtor_mult,
97  FB_DEFCTOR dtor,
98  size_t dimensions,
99  va_list ap
100  );