Home About Applications Software License Documentation Download Community



Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

contain.h

Go to the documentation of this file.
00001 #ifndef I_CONTAINER
00002 #define I_CONTAINER
00003 
00004 #include "environ.h"
00005 
00006 /*>>>obj_sid if debug build*/
00007 /*>>>LISTITEM, preprocessor needs to be smarter*/
00008 typedef struct tagLISTITEM {
00009    struct tagLISTITEM *next, *previous;
00010 } TListItem;
00011 
00012 typedef struct tagLIST {
00013    TListItem *first, *last;            /* macro's depend on this being first */
00014    int itemsize;
00015    int count;
00016 } TList;
00017 
00018 void LIST_new(TList *this, int itemsize) SECTION_FRAMEWORK;
00019 void *LIST_item_add(TList *this, TListItem *item,
00020                     TListItem *ref, bool front) SECTION_FRAMEWORK;
00021 void *LIST_n_item(TList *this, int n) SECTION_FRAMEWORK;
00022 int  LIST_item_n(TList *this, TListItem *item) SECTION_FRAMEWORK;
00023 bool LIST_item_exists(TList *this, TListItem *item) SECTION_FRAMEWORK;
00024 void LIST_item_remove(TList *this, TListItem *item) SECTION_FRAMEWORK;
00025 void LIST_delete(TList *this) SECTION_FRAMEWORK;
00026 
00027 /*----------------------------- Dynamic Arrays -----------------------------*/
00028 
00029 #if DEBUG
00030 #define ARRAY_DEBUG ulong obj_sid;
00031 #else
00032 #define ARRAY_DEBUG
00033 #endif
00034 
00035 typedef struct {
00036    ulong obj_sid;
00037    int element_size;
00038    int allocated, used;
00039    bool mem_dynamic;
00040    void *data;
00041 } TArray;
00042 
00043 /*>>>find a method of allocating array memory dynamically using OBJ_mem_alloc()*/
00044 void ARRAY_new(TArray *this, int element_size) SECTION_FRAMEWORK;
00045 void ARRAY_delete(TArray *this) SECTION_FRAMEWORK;
00046 void ARRAY_copy(TArray *this, TArray *src) SECTION_FRAMEWORK;
00047 void ARRAY_used_set(TArray *this, int count) SECTION_FRAMEWORK;
00048 void ARRAY_item_remove(TArray *this, void *item) SECTION_FRAMEWORK;
00049 
00050 /*------------------------------- Bitfields --------------------------------*/
00051 
00052 /*>>>variable size bitfields*/
00053 typedef struct {
00054    byte data[4];
00055    int count;
00056 } TBitfield;
00057 
00058 static inline void BITFIELD_new(TBitfield *this) {}
00059 static inline void BITFIELD_delete(TBitfield *this) {}
00060 static inline int BITFIELD_count(TBitfield *this) {
00061    return this->count;
00062 }
00063 static inline void BITFIELD_count_set(TBitfield *this, int count) {
00064    this->count = count;
00065 }
00066 static inline void BITFIELD_set(TBitfield *this, int index, bool value) {
00067    if (value) {
00068       this->data[index >> 3] |= (1 << (index & 7));
00069    }
00070    else {
00071       this->data[index >> 3] &= ~(1 << (index & 7));
00072    }
00073 }
00074 static inline bool BITFIELD_get(TBitfield *this, int index) {
00075    return (this->data[index >> 3] & (1 << (index & 7))) ? TRUE : FALSE;
00076 }
00077 #endif

Generated on Sat Feb 26 15:54:37 2005 for Keystone by  doxygen 1.4.1