diff options
Diffstat (limited to '')
-rw-r--r-- | src/T2DLL/CPluginInfoComparator.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/T2DLL/CPluginInfoComparator.cpp b/src/T2DLL/CPluginInfoComparator.cpp new file mode 100644 index 0000000..1886613 --- /dev/null +++ b/src/T2DLL/CPluginInfoComparator.cpp @@ -0,0 +1,34 @@ +#include "CPluginInfo.h" +#include "CPluginInfoComparator.h" + +/*virtual*/ int CPluginInfoComparator::Compare(const void* inItemOne, const void* inItemTwo, unsigned int inSizeOne, unsigned int inSizeTwo) const { + CPluginInfo *infoOne = *((CPluginInfo **) inItemOne); + CPluginInfo *infoTwo = *((CPluginInfo **) inItemTwo); + + if (!infoTwo) + return -1; + else if (!infoOne) + return 1; + else + return infoOne->GetID() - infoTwo->GetID(); +} + +/*virtual*/ BOOL CPluginInfoComparator::IsEqualTo(const void* inItemOne, const void* inItemTwo, unsigned int inSizeOne, unsigned int inSizeTwo) const { + CPluginInfo *infoOne = *((CPluginInfo **) inItemOne); + CPluginInfo *infoTwo = *((CPluginInfo **) inItemTwo); + return infoOne->GetID() == infoTwo->GetID(); +} + +/*virtual*/ int CPluginInfoComparator::CompareToKey(const void* inItem, unsigned int inSize, const void* inKey) const { + CPluginInfo *item = *((CPluginInfo **) inItem); + DWORD key = *((const DWORD *) inKey); + return item->GetID() - key; +} + +/*static*/ CPluginInfoComparator* CPluginInfoComparator::sCPluginInfoComparator; + +/*static*/ CPluginInfoComparator* CPluginInfoComparator::GetComparator() { + if (!sCPluginInfoComparator) + sCPluginInfoComparator = new CPluginInfoComparator; + return sCPluginInfoComparator; +} |