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)
void init ()

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 520 of file treekeyidx.cpp.

References SWKey::compare().

00520                                          {
00521         TreeKeyIdx *treeKey = SWDYNAMIC_CAST(TreeKeyIdx, (&ikey));
00522         if (treeKey)
00523                 return _compare(*treeKey);
00524         return SWKey::compare(ikey);
00525 }

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 494 of file treekeyidx.cpp.

References SWKey::copyFrom().

00494                                            {
00495         SWKey::copyFrom(ikey);
00496 }

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 528 of file treekeyidx.cpp.

00528                                     {
00529         error = getTreeNodeFromIdxOffset(currentNode.offset - (4*steps), &currentNode);
00530 }

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 532 of file treekeyidx.cpp.

00532                                     {
00533         error = getTreeNodeFromIdxOffset(currentNode.offset + (4*steps), &currentNode);
00534 
00535 /*
00536         // assert positive
00537         if (steps < 0) {
00538                 decrement(steps * -1);
00539                 return;
00540         }
00541 
00542         while (steps > 0) {
00543                 if (!firstChild()) {
00544                         if (!nextSibbling() {
00545                                 error = KEYERR_OUTOFBOUNDS;
00546                                 return;
00547                         }
00548                 }
00549                 steps--;
00550         }
00551 */
00552 }

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 466 of file treekeyidx.cpp.

References SWKey::Error().

00466                                          {
00467         char *buf = 0;
00468         stdstr(&buf, ikey);
00469         char *leaf = strtok(buf, "/");
00470         root();
00471         while ((leaf) && (!Error())) {
00472                 bool ok, inChild = false;
00473                 for (ok = firstChild(); ok; ok = nextSibling()) {
00474                         inChild = true;
00475                         if (!stricmp(leaf, getLocalName()))
00476                                 break;
00477                 }
00478                 leaf = strtok(0, "/");
00479                 if (!ok) {
00480                         if (inChild) {  // if we didn't find a matching child node, default to first child
00481                                 parent();
00482                                 firstChild();
00483                         }
00484                         if (leaf)
00485                                 error = KEYERR_OUTOFBOUNDS;
00486                         break;
00487                 }
00488         }
00489         delete [] buf;
00490 }


The documentation for this class was generated from the following files:
Generated on Thu Jun 20 22:13:05 2002 for The Sword Project by doxygen1.2.15