idmap.h File Reference

#include <gwenhywfar/types.h>
#include <stdio.h>
Include dependency graph for idmap.h:

Go to the source code of this file.

Defines

Macros for Typesafe ID maps

#define GWEN_DUMMY_EMPTY_ARG
#define GWEN_IDMAP_FUNCTION_DEFS(t, pr)   GWEN_IDMAP_FUNCTION_LIB_DEFS(t, pr, GWEN_DUMMY_EMPTY_ARG)
#define GWEN_IDMAP_FUNCTION_LIB_DEFS(t, pr, decl)
#define GWEN_IDMAP_FUNCTIONS(t, pr)

Typedefs

typedef struct GWEN_IDMAP GWEN_IDMAP

Enumerations

enum  GWEN_IDMAP_ALGO { GWEN_IdMapAlgo_Unknown = 0, GWEN_IdMapAlgo_Hex4 }
enum  GWEN_IDMAP_RESULT { GWEN_IdMapResult_Ok = 0, GWEN_IdMapResult_NoFit, GWEN_IdMapResult_NotFound }

Functions

GWENHYWFAR_API void GWEN_IdMap_Clear (GWEN_IDMAP *map)
GWENHYWFAR_API void GWEN_IdMap_Dump (GWEN_IDMAP *map, FILE *f, int indent)
GWENHYWFAR_API void * GWEN_IdMap_Find (GWEN_IDMAP *map, uint32_t id)
GWENHYWFAR_API void GWEN_IdMap_free (GWEN_IDMAP *map)
GWENHYWFAR_API GWEN_IDMAP_RESULT GWEN_IdMap_GetFirst (const GWEN_IDMAP *map, uint32_t *pid)
GWENHYWFAR_API GWEN_IDMAP_RESULT GWEN_IdMap_GetNext (const GWEN_IDMAP *map, uint32_t *pid)
GWENHYWFAR_API uint32_t GWEN_IdMap_GetSize (const GWEN_IDMAP *map)
GWENHYWFAR_API GWEN_IDMAP_RESULT GWEN_IdMap_Insert (GWEN_IDMAP *map, uint32_t id, void *ptr)
GWENHYWFAR_API GWEN_IDMAPGWEN_IdMap_new (GWEN_IDMAP_ALGO algo)
GWENHYWFAR_API GWEN_IDMAP_RESULT GWEN_IdMap_Remove (GWEN_IDMAP *map, uint32_t id)

Define Documentation

#define GWEN_DUMMY_EMPTY_ARG

Necessary for MSVC compiler because it does not accept a left-out macro argument.

Definition at line 63 of file idmap.h.

#define GWEN_IDMAP_FUNCTION_DEFS ( t,
pr   )     GWEN_IDMAP_FUNCTION_LIB_DEFS(t, pr, GWEN_DUMMY_EMPTY_ARG)

Definition at line 88 of file idmap.h.

#define GWEN_IDMAP_FUNCTION_LIB_DEFS ( t,
pr,
decl   ) 
Value:
typedef GWEN_IDMAP t##_IDMAP;                                       \
                                                                      \
  decl t##_IDMAP *pr##_IdMap_new(GWEN_IDMAP_ALGO algo);               \
  decl void pr##_IdMap_free(t##_IDMAP *l);                            \
  decl void pr##_IdMap_freeAll(t##_IDMAP *l);                         \
  decl void pr##_IdMap_FreeItems(t##_IDMAP *l);                       \
  decl GWEN_IDMAP_RESULT pr##_IdMap_Insert(t##_IDMAP *l,              \
                                           uint32_t id,       \
                                           t* ptr);                   \
  decl GWEN_IDMAP_RESULT pr##_IdMap_Remove(t##_IDMAP *l,              \
                                           uint32_t id);      \
  decl t* pr##_IdMap_Find(t##_IDMAP *l, uint32_t id);         \
  decl GWEN_IDMAP_RESULT pr##_IdMap_GetFirst(const t##_IDMAP *map,    \
                                              uint32_t *pid); \
  decl GWEN_IDMAP_RESULT pr##_IdMap_GetNext(const t##_IDMAP *map,     \
                                             uint32_t *pid);  \
  decl uint32_t pr##_IdMap_GetSize(const GWEN_IDMAP *map);    \
  decl void pr##_IdMap_Clear(GWEN_IDMAP *l);

Definition at line 67 of file idmap.h.

#define GWEN_IDMAP_FUNCTIONS ( t,
pr   ) 

Definition at line 92 of file idmap.h.


Typedef Documentation

typedef struct GWEN_IDMAP GWEN_IDMAP

Definition at line 41 of file idmap.h.


Enumeration Type Documentation

Enumerator:
GWEN_IdMapAlgo_Unknown 
GWEN_IdMapAlgo_Hex4 

Definition at line 50 of file idmap.h.

Enumerator:
GWEN_IdMapResult_Ok 
GWEN_IdMapResult_NoFit 
GWEN_IdMapResult_NotFound 

Definition at line 43 of file idmap.h.


Function Documentation

GWENHYWFAR_API void GWEN_IdMap_Clear ( GWEN_IDMAP map  ) 

Definition at line 128 of file idmap.c.

References DBG_ERROR, GWEN_IdMapAlgo_Hex4, GWEN_IdMapAlgo_Unknown, GWEN_IdMapHex4_Extend(), and GWEN_LOGDOMAIN.

Here is the call graph for this function:

GWENHYWFAR_API void GWEN_IdMap_Dump ( GWEN_IDMAP map,
FILE *  f,
int  indent 
)

Definition at line 146 of file idmap.c.

References DBG_ERROR, and GWEN_LOGDOMAIN.

GWENHYWFAR_API void* GWEN_IdMap_Find ( GWEN_IDMAP map,
uint32_t  id 
)

Definition at line 95 of file idmap.c.

GWENHYWFAR_API void GWEN_IdMap_free ( GWEN_IDMAP map  ) 

Definition at line 66 of file idmap.c.

References GWEN_FREE_OBJECT.

Referenced by GWEN_IdMap_new().

Here is the caller graph for this function:

GWENHYWFAR_API GWEN_IDMAP_RESULT GWEN_IdMap_GetFirst ( const GWEN_IDMAP map,
uint32_t *  pid 
)

Return the first id in the map.

Parameters:
map map to browse
pid pointer to a variable to receive the first id in the map. Upon return this variable will be updated to the first id in the map if the result is GWEN_IdMapResult_Ok.

Definition at line 103 of file idmap.c.

GWENHYWFAR_API GWEN_IDMAP_RESULT GWEN_IdMap_GetNext ( const GWEN_IDMAP map,
uint32_t *  pid 
)

Return the next id in the map.

Parameters:
map map to browse
pid pointer to the id retrieved via GWEN_IdMap_GetFirst. Upon return this variable will be updated to the next id in the map if the result is GWEN_IdMapResult_Ok.

Definition at line 112 of file idmap.c.

GWENHYWFAR_API uint32_t GWEN_IdMap_GetSize ( const GWEN_IDMAP map  ) 

Definition at line 121 of file idmap.c.

GWENHYWFAR_API GWEN_IDMAP_RESULT GWEN_IdMap_Insert ( GWEN_IDMAP map,
uint32_t  id,
void *  ptr 
)

Definition at line 75 of file idmap.c.

GWENHYWFAR_API GWEN_IDMAP* GWEN_IdMap_new ( GWEN_IDMAP_ALGO  algo  ) 

Definition at line 45 of file idmap.c.

References DBG_ERROR, GWEN_IdMap_free(), GWEN_IdMapAlgo_Hex4, GWEN_IdMapAlgo_Unknown, GWEN_IdMapHex4_Extend(), GWEN_LOGDOMAIN, and GWEN_NEW_OBJECT.

Here is the call graph for this function:

GWENHYWFAR_API GWEN_IDMAP_RESULT GWEN_IdMap_Remove ( GWEN_IDMAP map,
uint32_t  id 
)

Definition at line 86 of file idmap.c.

Generated on Mon Jul 5 22:53:25 2010 for gwenhywfar by  doxygen 1.6.3