gwenhywfar  4.3.3
Typedefs | Enumerations | Functions
idmap.h File Reference
#include <gwenhywfar/types.h>
#include <stdio.h>

Go to the source code of this file.

Defines

Macros for Typesafe ID maps
#define GWEN_DUMMY_EMPTY_ARG
#define GWEN_IDMAP_FUNCTION_LIB_DEFS(t, pr, decl)
#define GWEN_IDMAP_FUNCTION_DEFS(t, pr)   GWEN_IDMAP_FUNCTION_LIB_DEFS(t, pr, GWEN_DUMMY_EMPTY_ARG)
#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

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

Definition at line 60 of file idmap.h.

Definition at line 85 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 64 of file idmap.h.

#define GWEN_IDMAP_FUNCTIONS (   t,
  pr 
)

Definition at line 89 of file idmap.h.


Typedef Documentation

typedef struct GWEN_IDMAP GWEN_IDMAP

Definition at line 38 of file idmap.h.


Enumeration Type Documentation

Enumerator:
GWEN_IdMapAlgo_Unknown 
GWEN_IdMapAlgo_Hex4 

Definition at line 47 of file idmap.h.

Enumerator:
GWEN_IdMapResult_Ok 
GWEN_IdMapResult_NoFit 
GWEN_IdMapResult_NotFound 

Definition at line 40 of file idmap.h.


Function Documentation

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.

Definition at line 66 of file idmap.c.

References GWEN_FREE_OBJECT.

Referenced by GWEN_IdMap_new().

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

Return the first id in the map.

Parameters:
mapmap to browse
pidpointer 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:
mapmap to browse
pidpointer 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.

Definition at line 86 of file idmap.c.