Coconut Framework  beta
Classes | Typedefs | Functions
CNArray.h File Reference

Define CNArray data structure. More...

#include "CNForwarders.h"
#include "CNArrayElement.h"
#include <stdint.h>

Go to the source code of this file.


struct  CNArray
 Array of pointers. More...


typedef CNBoolean(* CNVisitElementOfArrayFuncRef )(uint64_t index, void *src, void *info)


void CNInitArray (struct CNArray *dst, struct CNResource *resource)
 Initialize array. More...
void CNDestroyArray (struct CNArray *dst)
 Release all resource the array. More...
static struct CNResource * CNResourceOfArray (const struct CNArray *src)
 Get resource of array. More...
static uint64_t CNCountOfArray (const struct CNArray *src)
 Get the count of elements in the array. More...
void * CNSetPointerToArray (struct CNArray *dst, uint64_t index, void *src)
 Set pointer to the array at the given index. More...
static void CNAddPointerToArray (struct CNArray *dst, void *src)
 Add pointer as the last element of the array. More...
void * CNPointerInArray (const struct CNArray *src, uint64_t index)
 Get element in the array. More...
CNBoolean CNVisitElementOfArray (const struct CNArray *src, CNVisitElementOfArrayFuncRef visitfunc, void *info)
 Visit all elements in the array. More...

Detailed Description

Define CNArray data structure.

Copyright (C) 2011 Steel Wheels Project

Typedef Documentation

typedef CNBoolean(* CNVisitElementOfArrayFuncRef)(uint64_t index, void *src, void *info)

The function to visit the element in CNArray

Function Documentation

void CNInitArray ( struct CNArray dst,
struct CNResource *  resource 

Initialize array.

dstDestination array
resourceResource to allocate array

Referenced by CNInitObjectArray().

void CNDestroyArray ( struct CNArray dst)

Release all resource the array.

dstDestination array
static struct CNResource* CNResourceOfArray ( const struct CNArray src)

Get resource of array.

Resource of array
srcSource array

References CNArray::resource.

Referenced by CNResourceOfObjectArray().

static uint64_t CNCountOfArray ( const struct CNArray src)

Get the count of elements in the array.

Count of elements
srcSource array

References CNArray::currentNum.

Referenced by CNCountOfObjectArray().

void* CNSetPointerToArray ( struct CNArray dst,
uint64_t  index,
void *  src 

Set pointer to the array at the given index.

Original value in the element
dstDestination array
indexIndex to set the source
srcSource pointer

Referenced by CNAddObjectToArray(), CNAddPointerToArray(), and CNSetObjectToArray().

static void CNAddPointerToArray ( struct CNArray dst,
void *  src 

Add pointer as the last element of the array.

dstDestination array
srcSource pointer

References CNSetPointerToArray(), and CNArray::currentNum.

void* CNPointerInArray ( const struct CNArray src,
uint64_t  index 

Get element in the array.

Return values
ptrElement of the array.
NULLThe element has NULL pointer or the index is out of range
srcSource array
indexIndex for array access

Referenced by CNObjectInArray().

CNBoolean CNVisitElementOfArray ( const struct CNArray src,
CNVisitElementOfArrayFuncRef  visitfunc,
void *  info 

Visit all elements in the array.

Return values
TRUEAll elements are visited
FALSEAll elements are NOT visited
srcSource array
visitfuncFunction which is called foreach elements
infoAdditiona parameter for visit function

Referenced by CNVisitElementOfObjectArray().