Coconut Framework  beta
CNArray.h
Go to the documentation of this file.
1 
8 #ifndef CNARRAY_H
9 #define CNARRAY_H
10 
11 #include "CNForwarders.h"
12 #include "CNArrayElement.h"
13 #include <stdint.h>
14 
18 struct CNArray {
20  struct CNResource * resource ;
22  uint64_t depth ;
24  uint64_t currentNum ;
27 } ;
28 
30 typedef CNBoolean (*CNVisitElementOfArrayFuncRef)(uint64_t index, void * src, void * info) ;
31 
37 void
38 CNInitArray(struct CNArray * dst, struct CNResource * resource) ;
39 
44 void
45 CNDestroyArray(struct CNArray * dst) ;
46 
52 static inline struct CNResource *
53 CNResourceOfArray(const struct CNArray * src)
54 {
55  return src->resource ;
56 }
57 
63 static inline uint64_t
64 CNCountOfArray(const struct CNArray * src)
65 {
66  return src->currentNum ;
67 }
68 
76 void *
77 CNSetPointerToArray(struct CNArray * dst, uint64_t index, void * src) ;
78 
84 static inline void
85 CNAddPointerToArray(struct CNArray * dst, void * src)
86 {
87  CNSetPointerToArray(dst, dst->currentNum, src) ;
88 }
89 
97 void *
98 CNPointerInArray(const struct CNArray * src, uint64_t index) ;
99 
108 CNBoolean
109 CNVisitElementOfArray(const struct CNArray * src, CNVisitElementOfArrayFuncRef visitfunc, void * info) ;
110 
111 #endif /* CNARRAY_H */
112 
struct CNArrayElement * topElement
Definition: CNArray.h:26
void CNDestroyArray(struct CNArray *dst)
Release all resource the array.
Array of pointers.
Definition: CNArray.h:18
void * CNPointerInArray(const struct CNArray *src, uint64_t index)
Get element in the array.
Forward declaration of data types.
void * CNSetPointerToArray(struct CNArray *dst, uint64_t index, void *src)
Set pointer to the array at the given index.
static uint64_t CNCountOfArray(const struct CNArray *src)
Get the count of elements in the array.
Definition: CNArray.h:64
CNBoolean CNVisitElementOfArray(const struct CNArray *src, CNVisitElementOfArrayFuncRef visitfunc, void *info)
Visit all elements in the array.
static struct CNResource * CNResourceOfArray(const struct CNArray *src)
Get resource of array.
Definition: CNArray.h:53
void CNInitArray(struct CNArray *dst, struct CNResource *resource)
Initialize array.
CNBoolean(* CNVisitElementOfArrayFuncRef)(uint64_t index, void *src, void *info)
Definition: CNArray.h:30
static void CNAddPointerToArray(struct CNArray *dst, void *src)
Add pointer as the last element of the array.
Definition: CNArray.h:85
struct CNResource * resource
Definition: CNArray.h:20
Define CNArrayElement data structure.
Definition: CNArrayElement.h:23
unsigned int CNBoolean
Boolean type.
Definition: CNType.h:14
uint64_t depth
Definition: CNArray.h:22
uint64_t currentNum
Definition: CNArray.h:24