#ifndef BTREE_H #define BTREE_H #include "btree_types.h" // integer definitions #include "btree_vfs.h" // bTreeVFS class #include "btree_key.h" // bTree key functions enum treeTypes { BT_CUSTOM, BT_PCHAR, BT_STRING, BT_SINGLE, BT_DOUBLE, BT_INT32, BT_INT64 }; typedef struct TblockRun { int32 AG; uInt16 start; uInt16 len; } __attribute__((__packed__)); typedef TblockRun inodeAddr; typedef union { int32 i; uInt32 u; float f; double d; void * p; inodeAddr iAddr; int64 offset; } uPtr; typedef struct bTreeSearch { uPtr value; void * key; int keySize; }; // bTreeSearchRec typedef struct bTreeInfo { int64 magic; uPtr root; uPtr firstDeleted; uInt32 nodes; uInt32 height; uInt32 keys; uInt32 bNodeSize; treeTypes treeType; } __attribute__((__packed__)); typedef struct TbNodeData { uPtr link; union { char str[1]; float f; double d; int32 i; int64 x; } key; } __attribute__((__packed__)); typedef struct TbNode { uInt32 magic; uInt32 tag; uInt32 numKeys; uInt32 size; uPtr left; uPtr right; uPtr parent; uPtr reserved; TbNodeData data; } __attribute__((__packed__)); class bTree { protected: compareKeyFunc compareKey; copyKeyProc copyKey; keySizeFunc keySize; bTreeInfo * info; bTreeVFS * vfs; bool memoryTree; bool treeChanged; int align(int); int calcSize(TbNode *); public: bTree(char *, uInt32, treeTypes, bTreeVFS *); void InstallUserFunctions(compareKeyFunc, copyKeyProc, keySizeFunc); virtual ~bTree(void); };// bTree #endif