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
/******************************************************************
* MICROTABLE V1.0 *
* By moyack *
* 2013 *
* =================================== *
* Exclusive resource from wc3jass.com *
* =================================== *
******************************************************************/
library MicroTable
/*
the purpose of this library is to allow the attachment of data
struct by its index in an easy way.
Features:
- One command style to get, retrieve data (GetData, StoreData)
- Automatic flush of data when you call any Remove* or Destroy*
function.
- You can get the main hashtable so in you map you only need one
hastable
- Inline friendly :D
Functions provided:
- GetTable: Returns the main Hashtable so you can use it in
other parts of the code in you map.
- StoreData: Connects the handle with a struct usind an index
value.
- GetData: Retrieves the struct data from the respective handle
and index.
- HasData: Checks if a handle has a struct stored with the
specified index.
- ClearData: Clears the struct info from the handle in the
specified index.
- FlushData: Clear ALL the information related to the handle
(this function is called automatically when you destroy or
remove that handle)
*/
globals
private hashtable H = InitHashtable()
endglobals
constant function GetTable takes nothing returns hashtable
return H
endfunction
function StoreData takes handle h, integer index, integer value returns nothing
call SaveInteger(H, GetHandleId(h), index, value)
endfunction
function GetData takes handle h, integer index returns integer
return LoadInteger(H, GetHandleId(h), index)
endfunction
function HasData takes handle h, integer index returns boolean
return HaveSavedInteger(H, GetHandleId(h), index)
endfunction
function ClearData takes handle h, integer index returns nothing
call RemoveSavedInteger(H, GetHandleId(h), index)
endfunction
function FlushData takes handle h returns nothing
call FlushChildHashtable(H, GetHandleId(h))
endfunction
//==================================================
hook RemoveDestructable FlushData
hook RemoveItem FlushData
hook RemoveLocation FlushData
hook RemoveRect FlushData
hook RemoveRegion FlushData
hook RemoveUnit FlushData
hook RemoveWeatherEffect FlushData
hook DestroyBoolExpr FlushData
hook DestroyCondition FlushData
hook DestroyDefeatCondition FlushData
hook DestroyEffect FlushData
hook DestroyFilter FlushData
hook DestroyForce FlushData
hook DestroyGroup FlushData
hook DestroyImage FlushData
hook DestroyItemPool FlushData
hook DestroyLeaderboard FlushData
hook DestroyLightning FlushData
hook DestroyMultiboard FlushData
hook DestroyQuest FlushData
hook DestroyTextTag FlushData
hook DestroyTimer FlushData
hook DestroyTimerDialog FlushData
hook DestroyTrigger FlushData
hook DestroyUbersplat FlushData
hook DestroyUnitPool FlushData
endlibraryExample
Check the library Hibrid TimerUtils in the related links.
