summaryrefslogtreecommitdiff
path: root/src/T2DLL/CPluginInfoComparator.cpp
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-06-14 00:50:34 +0100
committerAsh Wolf <ninji@wuffs.org>2023-06-14 00:50:34 +0100
commit37e364b2c6cc7487a1c888d256a73e5337bb7189 (patch)
treeeaf6e857382eef16c2dd940eb4125536fbe068bd /src/T2DLL/CPluginInfoComparator.cpp
downloadt2win-37e364b2c6cc7487a1c888d256a73e5337bb7189.tar.gz
t2win-37e364b2c6cc7487a1c888d256a73e5337bb7189.zip
initial commit
Diffstat (limited to '')
-rw-r--r--src/T2DLL/CPluginInfoComparator.cpp34
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;
+}