From 37e364b2c6cc7487a1c888d256a73e5337bb7189 Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Wed, 14 Jun 2023 00:50:34 +0100 Subject: initial commit --- src/T2DLL/CPluginInfoComparator.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/T2DLL/CPluginInfoComparator.cpp (limited to 'src/T2DLL/CPluginInfoComparator.cpp') 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; +} -- cgit v1.2.3