diff --git a/btree.cpp b/btree.cpp index fc91806..8635805 100644 --- a/btree.cpp +++ b/btree.cpp @@ -36,6 +36,11 @@ } // bTree::calcSize void +bTree::setNull(uPtr & u) { + u.offset = 0; +} // bTree::setNull + +void bTree::InstallUserFunctions(compareKeyFunc cmpFunc, copyKeyProc copyProc, keySizeFunc ksFunc) { compareKey = cmpFunc; copyKey = copyProc; diff --git a/btree.h b/btree.h index 017aa68..371be63 100644 --- a/btree.h +++ b/btree.h @@ -5,66 +5,6 @@ #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; @@ -77,6 +17,7 @@ int align(int); int calcSize(TbNode *); + void setNull(uPtr &); public: bTree(char *, uInt32, treeTypes, bTreeVFS *); void InstallUserFunctions(compareKeyFunc, copyKeyProc, keySizeFunc); diff --git a/btree_types.h b/btree_types.h index 7e0f379..e2d14b6 100644 --- a/btree_types.h +++ b/btree_types.h @@ -10,4 +10,64 @@ typedef unsigned int uInt32; typedef unsigned long long int uInt64; +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__)); + #endif