AtxMap.h

00001 /*****************************************************************
00002 |
00003 |   Atomix - Maps
00004 |
00005 |   (c) 2002-2006 Gilles Boccon-Gibod
00006 |   Author: Gilles Boccon-Gibod (bok@bok.net)
00007 |
00008 ****************************************************************/
00009 
00010 #ifndef _ATX_MAP_H_
00011 #define _ATX_MAP_H_
00012 
00013 /*----------------------------------------------------------------------
00014 |    includes
00015 +---------------------------------------------------------------------*/
00016 #include "AtxTypes.h"
00017 #include "AtxDefs.h"
00018 #include "AtxResults.h"
00019 #include "AtxUtils.h"
00020 #include "AtxList.h"
00021 
00022 /*----------------------------------------------------------------------
00023 |    types
00024 +---------------------------------------------------------------------*/
00025 typedef struct ATX_Map ATX_Map;
00026 typedef struct ATX_MapEntry ATX_MapEntry;
00027 
00028 typedef struct {
00029     ATX_Boolean is_set;
00030     ATX_Any     data;
00031     ATX_UInt32  type;
00032 } ATX_MapEntryInfo;
00033 
00034 /*----------------------------------------------------------------------
00035 |    constants
00036 +---------------------------------------------------------------------*/
00037 #define ATX_MAP_ITEM_TYPE_UNKNOWN 0
00038 
00039 /*----------------------------------------------------------------------
00040 |    prototypes
00041 +---------------------------------------------------------------------*/
00042 #ifdef __cplusplus
00043 extern "C" {
00044 #endif /* __cplusplus */
00045 
00046 ATX_Result    ATX_Map_Create(ATX_Map** map);
00047 ATX_Result    ATX_Map_CreateEx(const ATX_ListDataDestructor* destructor, ATX_Map** map);
00048 ATX_Result    ATX_Map_Destroy(ATX_Map* self);
00049 ATX_Result    ATX_Map_Clear(ATX_Map* self);
00050 ATX_Result    ATX_Map_Put(ATX_Map*          self, 
00051                           ATX_CString       key, 
00052                           ATX_Any           data, 
00053                           ATX_MapEntryInfo* previous);
00054 ATX_Result    ATX_Map_PutTyped(ATX_Map*          self, 
00055                                ATX_CString       key, 
00056                                ATX_Any           data, 
00057                                ATX_UInt32        type,
00058                                ATX_MapEntryInfo* previous);
00059 ATX_MapEntry* ATX_Map_Get(ATX_Map* self, const char* key);
00060 ATX_Result    ATX_Map_Remove(ATX_Map* self, ATX_CString key, ATX_MapEntryInfo* entry_info);
00061 ATX_Boolean   ATX_Map_HasKey(ATX_Map* self, ATX_CString key);
00062 ATX_List*     ATX_Map_AsList(ATX_Map* self);
00063 
00064 ATX_CString   ATX_MapEntry_GetKey(ATX_MapEntry* self);
00065 ATX_Any       ATX_MapEntry_GetData(ATX_MapEntry* self);
00066 ATX_Result    ATX_MapEntry_SetData(ATX_MapEntry* self, ATX_Any data);
00067 ATX_UInt32    ATX_MapEntry_GetType(ATX_MapEntry* self);
00068 ATX_Result    ATX_MapEntry_SetType(ATX_MapEntry* self, ATX_UInt32 type);
00069 
00070 #ifdef __cplusplus
00071 }
00072 #endif /* __cplusplus */
00073 
00074 #endif /* _ATX_MAP_H_ */