00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef TREEKEYIDX_H
00024 #define TREEKEYIDX_H
00025
00026 #include <treekey.h>
00027 #include <sysdata.h>
00028 #include <filemgr.h>
00029
00030 SWORD_NAMESPACE_START
00031
00036 class SWDLLEXPORT TreeKeyIdx : public TreeKey {
00037
00038 class TreeNode {
00039 public:
00040 TreeNode();
00041 ~TreeNode();
00042 void clear();
00043 __u32 offset;
00044 __s32 parent;
00045 __s32 next;
00046 __s32 firstChild;
00047 char *name;
00048 __u16 dsize;
00049 char *userData;
00050 } currentNode;
00051
00052 static SWClass classdef;
00053
00054 char *path;
00055
00056 FileDesc *idxfd;
00057 FileDesc *datfd;
00058
00059 void getTreeNodeFromDatOffset(long ioffset, TreeNode *buf) const;
00060 char getTreeNodeFromIdxOffset(long ioffset, TreeNode *node) const;
00061 void saveTreeNode(TreeNode *node);
00062 void saveTreeNodeOffsets(TreeNode *node);
00063 void init();
00064
00065 public:
00066 TreeKeyIdx(const TreeKeyIdx &ikey);
00067 TreeKeyIdx (const char *idxPath, int fileMode = -1);
00068 ~TreeKeyIdx ();
00069
00070 virtual SWKey *clone() const;
00071
00072 virtual const char *getLocalName();
00073 virtual const char *setLocalName(const char *);
00074
00075 virtual const char *getUserData(int *size = 0);
00076 virtual void setUserData(const char *userData, int size = 0);
00077
00078 virtual const char *getFullName() const;
00079
00080 virtual void root();
00081 virtual bool parent();
00082
00083 virtual bool firstChild();
00084 virtual bool nextSibling();
00085 virtual bool previousSibling();
00086
00087 virtual bool hasChildren();
00088
00089 virtual void append();
00090 virtual void appendChild();
00091 virtual void insertBefore();
00092
00093 virtual void remove();
00094 virtual void save();
00095
00096 virtual void copyFrom(const TreeKeyIdx &ikey);
00097 virtual void copyFrom(const SWKey & ikey);
00098
00099 void setOffset(unsigned long offset);
00100 unsigned long getOffset() const;
00101
00102
00103
00104
00105
00106
00107 virtual SWKey &operator = (const TreeKeyIdx &ikey) { copyFrom(ikey); return *this; }
00108 SWKEY_OPERATORS
00109
00110 virtual void setText(const char *ikey);
00111 virtual void setPosition(SW_POSITION p);
00112 virtual const char *getText() const;
00113 virtual int _compare (const TreeKeyIdx & ikey);
00114 virtual int compare(const SWKey &ikey);
00115 virtual void decrement(int steps = 1);
00116 virtual void increment(int steps = 1);
00117 virtual char Traversable () { return 1; }
00118
00119 static signed char create(const char *path);
00120 };
00121
00122 SWORD_NAMESPACE_END
00123
00124 #endif