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
00029 SWORD_NAMESPACE_START
00030
00031 class FileDesc;
00032
00037 class SWDLLEXPORT TreeKeyIdx : public TreeKey {
00038
00039 class TreeNode {
00040 public:
00041 TreeNode();
00042 ~TreeNode();
00043 void clear();
00044 __s32 offset;
00045 __s32 parent;
00046 __s32 next;
00047 __s32 firstChild;
00048 char *name;
00049 __u16 dsize;
00050 char *userData;
00051 } currentNode;
00052
00053 static SWClass classdef;
00054
00055 char *path;
00056
00057 FileDesc *idxfd;
00058 FileDesc *datfd;
00059
00060 void getTreeNodeFromDatOffset(long ioffset, TreeNode *buf) const;
00061 char getTreeNodeFromIdxOffset(long ioffset, TreeNode *node) const;
00062 void saveTreeNode(TreeNode *node);
00063 void saveTreeNodeOffsets(TreeNode *node);
00064 void init();
00065
00066 public:
00067 TreeKeyIdx(const TreeKeyIdx &ikey);
00068 TreeKeyIdx (const char *idxPath, int fileMode = -1);
00069 ~TreeKeyIdx ();
00070
00071 virtual SWKey *clone() const;
00072
00073 virtual const char *getLocalName();
00074 virtual const char *setLocalName(const char *);
00075
00076 virtual const char *getUserData(int *size = 0);
00077 virtual void setUserData(const char *userData, int size = 0);
00078
00079 virtual void root();
00080 virtual bool parent();
00081
00082 virtual bool firstChild();
00083 virtual bool nextSibling();
00084 virtual bool previousSibling();
00085
00086 virtual bool hasChildren();
00087
00088 virtual void append();
00089 virtual void appendChild();
00090 virtual void insertBefore();
00091
00092 virtual void remove();
00093 virtual void save();
00094
00095 virtual void copyFrom(const TreeKeyIdx &ikey);
00096 virtual void copyFrom(const SWKey &ikey);
00097
00098 void setOffset(unsigned long offset);
00099 unsigned long getOffset() const;
00100
00101
00102
00103
00104
00105 virtual SWKey &operator = (const TreeKeyIdx &ikey) { copyFrom(ikey); return *this; }
00106 SWKEY_OPERATORS
00107
00108 virtual void setText(const char *ikey);
00109 virtual void setPosition(SW_POSITION p);
00110 virtual const char *getText() const;
00111 virtual int _compare (const TreeKeyIdx & ikey);
00112 virtual int compare(const SWKey &ikey);
00113 virtual void decrement(int steps = 1);
00114 virtual void increment(int steps = 1);
00115 virtual bool isTraversable() const { return true; }
00116
00117 static signed char create(const char *path);
00118 };
00119
00120 SWORD_NAMESPACE_END
00121
00122 #endif