13 years
edited 8 years
Description
This small library allows to attach data structs in a easy way.
Requirements:
- nothing
Actual Code
Example
Check the library Hibrid TimerUtils in the related links.
This small library allows to attach data structs in a easy way.
Requirements:
- nothing
Actual Code
1 /******************************************************************2 * MICROTABLE V1.0 *3 * By moyack *4 * 2013 *5 * =================================== *6 * Exclusive resource from wc3jass.com *7 * =================================== *8 ******************************************************************/9 library MicroTable10 /*11 the purpose of this library is to allow the attachment of data12 struct by its index in an easy way.13 14 Features:15 - One command style to get, retrieve data (GetData, StoreData)16 - Automatic flush of data when you call any Remove* or Destroy*17 function.18 - You can get the main hashtable so in you map you only need one 19 hastable20 - Inline friendly 
21 22 Functions provided:23 - GetTable: Returns the main Hashtable so you can use it in24 other parts of the code in you map.25 - StoreData: Connects the handle with a struct usind an index26 value.27 - GetData: Retrieves the struct data from the respective handle28 and index.29 - HasData: Checks if a handle has a struct stored with the30 specified index.31 - ClearData: Clears the struct info from the handle in the 32 specified index.33 - FlushData: Clear ALL the information related to the handle34 (this function is called automatically when you destroy or35 remove that handle)36 */37 38 globals39 private hashtable H = InitHashtable()
40 endglobals41 42 constant function GetTable takes nothing returns hashtable
43 return H44 endfunction45 46 function StoreData takes handle h, integer index, integer value returns nothing
47 call SaveInteger(H, GetHandleId(h), index, value)
48 endfunction49 50 function GetData takes handle h, integer index returns integer
51 return LoadInteger(H, GetHandleId(h), index)
52 endfunction53 54 function HasData takes handle h, integer index returns boolean
55 return HaveSavedInteger(H, GetHandleId(h), index)
56 endfunction57 58 function ClearData takes handle h, integer index returns nothing
59 call RemoveSavedInteger(H, GetHandleId(h), index)
60 endfunction61 62 function FlushData takes handle h returns nothing
63 call FlushChildHashtable(H, GetHandleId(h))
64 endfunction65 66 //==================================================67 hook RemoveDestructable FlushData
68 hook RemoveItem FlushData
69 hook RemoveLocation FlushData
70 hook RemoveRect FlushData
71 hook RemoveRegion FlushData
72 hook RemoveUnit FlushData
73 hook RemoveWeatherEffect FlushData
74 hook DestroyBoolExpr FlushData
75 hook DestroyCondition FlushData
76 hook DestroyDefeatCondition FlushData
77 hook DestroyEffect FlushData
78 hook DestroyFilter FlushData
79 hook DestroyForce FlushData
80 hook DestroyGroup FlushData
81 hook DestroyImage FlushData
82 hook DestroyItemPool FlushData
83 hook DestroyLeaderboard FlushData
84 hook DestroyLightning FlushData
85 hook DestroyMultiboard FlushData
86 hook DestroyQuest FlushData
87 hook DestroyTextTag FlushData
88 hook DestroyTimer FlushData
89 hook DestroyTimerDialog FlushData
90 hook DestroyTrigger FlushData
91 hook DestroyUbersplat FlushData
92 hook DestroyUnitPool FlushData
93 94 endlibrary
Example
Check the library Hibrid TimerUtils in the related links.
