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.

Classes

struct  CNArray
 Array of pointers. More...
 

Typedefs

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

Functions

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
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.

Parameters
dstDestination array
resourceResource to allocate array

Referenced by CNInitObjectArray().

void CNDestroyArray ( struct CNArray dst)

Release all resource the array.

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

Get resource of array.

Returns
Resource of array
Parameters
srcSource array

References CNArray::resource.

Referenced by CNResourceOfObjectArray().

static uint64_t CNCountOfArray ( const struct CNArray src)
inlinestatic

Get the count of elements in the array.

Returns
Count of elements
Parameters
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.

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

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

static void CNAddPointerToArray ( struct CNArray dst,
void *  src 
)
inlinestatic

Add pointer as the last element of the array.

Parameters
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
Parameters
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
Parameters
srcSource array
visitfuncFunction which is called foreach elements
infoAdditiona parameter for visit function

Referenced by CNVisitElementOfObjectArray().