aboutsummaryrefslogtreecommitdiff
path: root/Src/nde/Index.h
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/nde/Index.h
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/nde/Index.h')
-rw-r--r--Src/nde/Index.h83
1 files changed, 83 insertions, 0 deletions
diff --git a/Src/nde/Index.h b/Src/nde/Index.h
new file mode 100644
index 00000000..1750f44e
--- /dev/null
+++ b/Src/nde/Index.h
@@ -0,0 +1,83 @@
+/* ---------------------------------------------------------------------------
+ Nullsoft Database Engine
+ --------------------
+ codename: Near Death Experience
+--------------------------------------------------------------------------- */
+
+/* ---------------------------------------------------------------------------
+
+ Raw Index Class Prototypes
+
+--------------------------------------------------------------------------- */
+
+#ifndef __RAWINDEX_H
+#define __RAWINDEX_H
+
+#include <stdio.h>
+#ifdef WIN32
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+#include "vfs.h"
+#include "Table.h"
+
+class IndexField;
+#define BLOCK_SIZE 2048 // 8192 entries blocks
+class RecordBase;
+class Index
+{
+public:
+ Index(VFILE *Handle, unsigned char id, int pos, int type, bool newindex, int nentries, Table *parentTable);
+ ~Index();
+ int Get(int Idx);
+ void Set(int Idx, int P);
+
+ void LoadIndex(bool newindex);
+ void WriteIndex(void);
+ int Insert(Index *parindex, int N, bool localonly);
+ int Insert(int N);
+ int Update(int Idx, int Pos, RecordBase *record, bool localonly);
+ int Update(Index *parindex, int paridx, int Idx, int Pos, RecordBase *record, bool forceLast, bool localonly);
+ unsigned char GetId();
+
+ int FindSortedPlace(Field *field, int idx, int *laststate, int start);
+ int FindSortedPlaceEx(Field *field, int idx, int *laststate, int start, int comp_mode);
+ int MoveIndex(int idx, int newidx);
+ void Colaborate(IndexField *secindex);
+ void SetCooperative(int Idx, int secpos);
+ int GetCooperative(int Idx);
+ void UpdateMe(Index *Me, int newidx, int oldidx);
+ Field *QuickFindField(unsigned char Id, int Pos);
+ int QuickFind(int Id, Field *field, int start);
+ int QuickFindEx(int Id, Field *field, int start, int comp_mode);
+ int TranslateIndex(int Pos, Index *index);
+ void Delete(int Idx, int Pos, Record *record);
+ void Shrink(void);
+
+ void Propagate(void);
+ void SetGlobalLocateUpToDate(bool isUptodate);
+ int NeedFix();
+
+public:
+ // TODO: make these protected
+ int NEntries;
+ IndexField *SecIndex;
+ bool locateUpToDate;
+
+protected:
+ VFILE *Handle;
+ VFILE *TableHandle;
+ Table *pTable;
+
+ int *IndexTable;
+ size_t MaxSize;
+ unsigned char Id;
+
+ bool InChain;
+ int Position;
+ bool InInsert;
+ int InChainIdx;
+};
+
+#endif \ No newline at end of file