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