Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

treekeyidx.h

00001 /******************************************************************************
00002  *  versekey.h - code for class 'versekey'- a standard Biblical verse key
00003  *
00004  * $Id: treekeyidx_8h-source.html,v 1.1 2003/02/28 21:22:14 mgruner Exp $
00005  *
00006  * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
00007  *      CrossWire Bible Society
00008  *      P. O. Box 2528
00009  *      Tempe, AZ  85280-2528
00010  *
00011  * This program is free software; you can redistribute it and/or modify it
00012  * under the terms of the GNU General Public License as published by the
00013  * Free Software Foundation version 2.
00014  *
00015  * This program is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * General Public License for more details.
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         // OPERATORS ------------------------------------------------------------
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

Generated on Fri Feb 28 22:01:39 2003 for The Sword Project by doxygen1.3-rc3