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

TreeKeyIdx Class Reference

Class VerseKey The SWKey implementation used for verse based modules like Bibles or commentaries. More...

#include <treekeyidx.h>

Inheritance diagram for TreeKeyIdx:

Inheritance graph
[legend]
Collaboration diagram for TreeKeyIdx:

Collaboration graph
[legend]
List of all members.

Public Methods

 TreeKeyIdx (const TreeKeyIdx &ikey)
 TreeKeyIdx (const char *idxPath, int fileMode=-1)
 ~TreeKeyIdx ()
virtual const char * getLocalName ()
virtual const char * setLocalName (const char *)
virtual const char * getUserData (int *size=0)
virtual void setUserData (const char *userData, int size=0)
virtual const char * getFullName () const
virtual void root ()
virtual bool parent ()
virtual bool firstChild ()
virtual bool nextSibling ()
virtual bool previousSibling ()
virtual bool hasChildren ()
virtual void append ()
virtual void appendChild ()
virtual void insertBefore ()
virtual void remove ()
virtual void save ()
virtual void copyFrom (const TreeKeyIdx &ikey)
virtual void copyFrom (const SWKey &ikey)
 Equates this SWKey to another SWKey object. More...

virtual SWKeyoperator= (const TreeKeyIdx &ikey)
void setOffset (unsigned long offset)
unsigned long getOffset () const
virtual SWKEY_OPERATORS void setText (const char *ikey)
 Equates this SWKey to a character string. More...

virtual void setPosition (SW_POSITION p)
virtual const char * getText () const
 returns text key if (char *) cast is requested.

virtual int _compare (const TreeKeyIdx &ikey)
virtual int compare (const SWKey &ikey)
 Compares another VerseKey object. More...

virtual void decrement (int steps=1)
 Decrements key a number of entries. More...

virtual void increment (int steps=1)
 Increments key a number of entries. More...

virtual char Traversable ()

Static Public Methods

signed char create (const char *path)

Private Methods

void getTreeNodeFromDatOffset (long ioffset, TreeNode *buf) const
char getTreeNodeFromIdxOffset (long ioffset, TreeNode *node) const
void saveTreeNode (TreeNode *node)
void saveTreeNodeOffsets (TreeNode *node)

Private Attributes

TreeKeyIdx::TreeNode currentNode
char * path
FileDesc * idxfd
FileDesc * datfd

Static Private Attributes

SWClass classdef

Detailed Description

Class VerseKey The SWKey implementation used for verse based modules like Bibles or commentaries.

Definition at line 35 of file treekeyidx.h.


Member Function Documentation

int TreeKeyIdx::compare const SWKey   ikey [virtual]
 

Compares another VerseKey object.

Parameters:
ikey  key to compare with this one
Returns:
>0 if this key is greater than compare key; <0 if this key is smaller than compare key; 0 if the keys are the same

Implements TreeKey.

Definition at line 511 of file treekeyidx.cpp.

References SWKey::compare.

00511                                          {
00512         TreeKeyIdx *treeKey = SWDYNAMIC_CAST(TreeKeyIdx, (&ikey));
00513         if (treeKey)
00514                 return _compare(*treeKey);
00515         return SWKey::compare(ikey);
00516 }

void TreeKeyIdx::copyFrom const SWKey   ikey [virtual]
 

Equates this SWKey to another SWKey object.

Parameters:
ikey  other swkey object

Reimplemented from SWKey.

Definition at line 485 of file treekeyidx.cpp.

References SWKey::copyFrom.

00485                                            {
00486         SWKey::copyFrom(ikey);
00487 }

void TreeKeyIdx::decrement int    steps = 1 [virtual]
 

Decrements key a number of entries.

Parameters:
steps  Number of entries to jump backward
Returns:
*this

Implements TreeKey.

Definition at line 519 of file treekeyidx.cpp.

00519                                     {
00520         error = getTreeNodeFromIdxOffset(currentNode.offset - (4*steps), &currentNode);
00521 }

void TreeKeyIdx::increment int    steps = 1 [virtual]
 

Increments key a number of entries.

Parameters:
increment  Number of entries to jump forward
Returns:
*this

Implements TreeKey.

Definition at line 523 of file treekeyidx.cpp.

00523                                     {
00524         error = getTreeNodeFromIdxOffset(currentNode.offset + (4*steps), &currentNode);
00525 
00526 /*
00527         // assert positive
00528         if (steps < 0) {
00529                 decrement(steps * -1);
00530                 return;
00531         }
00532 
00533         while (steps > 0) {
00534                 if (!firstChild()) {
00535                         if (!nextSibbling() {
00536                                 error = KEYERR_OUTOFBOUNDS;
00537                                 return;
00538                         }
00539                 }
00540                 steps--;
00541         }
00542 */
00543 }

void TreeKeyIdx::setText const char *    ikey [virtual]
 

Equates this SWKey to a character string.

Parameters:
ikey  string to set this key to

Implements TreeKey.

Definition at line 457 of file treekeyidx.cpp.

References SWKey::Error.

00457                                          {
00458         char *buf = 0;
00459         stdstr(&buf, ikey);
00460         char *leaf = strtok(buf, "/");
00461         root();
00462         while ((leaf) && (!Error())) {
00463                 bool ok, inChild = false;
00464                 for (ok = firstChild(); ok; ok = nextSibling()) {
00465                         inChild = true;
00466                         if (!stricmp(leaf, getLocalName()))
00467                                 break;
00468                 }
00469                 leaf = strtok(0, "/");
00470                 if (!ok) {
00471                         if (inChild) {  // if we didn't find a matching child node, default to first child
00472                                 parent();
00473                                 firstChild();
00474                         }
00475                         if (leaf)
00476                                 error = KEYERR_OUTOFBOUNDS;
00477                         break;
00478                 }
00479         }
00480         delete [] buf;
00481 }


The documentation for this class was generated from the following files:
Generated on Wed Apr 3 22:34:19 2002 for The Sword Project by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002