TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Map.h
Go to the documentation of this file.
1 /*****************************************************************************/
2 /* Map.h Copyright (c) Ladislav Zezula 2014 */
3 /*---------------------------------------------------------------------------*/
4 /* Interface of hash-to-ptr map for CascLib */
5 /*---------------------------------------------------------------------------*/
6 /* Date Ver Who Comment */
7 /* -------- ---- --- ------- */
8 /* 10.06.14 1.00 Lad The first version of Map.h */
9 /*****************************************************************************/
10 
11 #ifndef __HASHTOPTR_H__
12 #define __HASHTOPTR_H__
13 
14 //-----------------------------------------------------------------------------
15 // Structures
16 
17 #define KEY_LENGTH_STRING 0xFFFFFFFF // Pass this to Map_Create as dwKeyLength when you want map of string->object
18 
19 typedef struct _CASC_MAP
20 {
21  size_t TableSize;
22  size_t ItemCount; // Number of items in the map
23  size_t KeyOffset; // How far is the hash from the begin of the structure (in bytes)
24  size_t KeyLength; // Length of the hash key
25  void * HashTable[1]; // Pointer table
26 
28 
29 typedef bool (*MAP_COMPARE)(PCASC_MAP pMap, void * pvObject, void * pvKey);
30 
31 //-----------------------------------------------------------------------------
32 // Functions
33 
34 PCASC_MAP Map_Create(DWORD dwMaxItems, DWORD dwKeyLength, DWORD dwKeyOffset);
35 size_t Map_EnumObjects(PCASC_MAP pMap, void **ppvArray);
36 void * Map_FindObject(PCASC_MAP pMap, void * pvKey, PDWORD PtrIndex);
37 bool Map_InsertObject(PCASC_MAP pMap, void * pvNewObject, void * pvKey);
38 const char * Map_FindString(PCASC_MAP pMap, const char * szString, const char * szStringEnd);
39 bool Map_InsertString(PCASC_MAP pMap, const char * szString, bool bCutExtension);
40 void Map_Free(PCASC_MAP pMap);
41 
42 #endif // __HASHTOPTR_H__
size_t KeyOffset
Definition: Map.h:23
DWORD * PDWORD
Definition: CascPort.h:151
bool Map_InsertString(PCASC_MAP pMap, const char *szString, bool bCutExtension)
Definition: Map.cpp:207
PCASC_MAP Map_Create(DWORD dwMaxItems, DWORD dwKeyLength, DWORD dwKeyOffset)
Definition: Map.cpp:93
struct _CASC_MAP CASC_MAP
void Map_Free(PCASC_MAP pMap)
Definition: Map.cpp:279
const char * Map_FindString(PCASC_MAP pMap, const char *szString, const char *szStringEnd)
Definition: Map.cpp:251
#define bool
Definition: CascPort.h:16
size_t TableSize
Definition: Map.h:21
size_t Map_EnumObjects(PCASC_MAP pMap, void **ppvArray)
Definition: Map.cpp:117
struct _CASC_MAP * PCASC_MAP
bool Map_InsertObject(PCASC_MAP pMap, void *pvNewObject, void *pvKey)
Definition: Map.cpp:170
unsigned int DWORD
Definition: CascPort.h:139
Definition: Map.h:19
void * Map_FindObject(PCASC_MAP pMap, void *pvKey, PDWORD PtrIndex)
Definition: Map.cpp:138
void * HashTable[1]
Definition: Map.h:25
size_t ItemCount
Definition: Map.h:22
size_t KeyLength
Definition: Map.h:24
bool(* MAP_COMPARE)(PCASC_MAP pMap, void *pvObject, void *pvKey)
Definition: Map.h:29