sword::ListKey Class Reference

ListKey is the basis for all types of keys that have lists of specified indexes (e.g. More...

#include <listkey.h>

Inheritance diagram for sword::ListKey:

Inheritance graph
[legend]
Collaboration diagram for sword::ListKey:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ListKey (const char *ikey=0)
 initializes instance of ListKey
 ListKey (ListKey const &k)
virtual ~ListKey ()
 cleans up instance of ListKey
virtual SWKeyclone () const
 Returns a new exact clone of this SWKey object.
virtual void clear ()
 Clears out elements of list.
virtual void ClearList ()
 deprecated, use clear(), instead
virtual int Count ()
 Returns number of elements in list.
virtual void Remove ()
 Removes current element from list.
virtual char SetToElement (int ielement, SW_POSITION=SW_POSITION(((char) 1)))
 Sets key to element number.
virtual SWKeygetElement (int pos=-1)
 Gets a key element number.
virtual SWKeyGetElement (int pos=-1)
ListKeyoperator<< (const SWKey &ikey)
 Adds an element to the list.
virtual void add (const SWKey &ikey)
virtual void copyFrom (const ListKey &ikey)
 Equates this ListKey to another ListKey object.
virtual void copyFrom (const SWKey &ikey)
 Copies as much info (position, range, etc.
virtual void setPosition (SW_POSITION pos)
 Positions this key.
virtual void decrement (int step)
 Decrements a number of elements.
virtual void increment (int step)
 Increments a number of elements.
virtual bool isTraversable () const
 Whether or not this key can be ++ -- incremented.
virtual long Index () const
 Use this function to get an index position within a module.
virtual const char * getRangeText () const
virtual long Index (long index)
 Returns the index for the new one given as as parameter.
virtual const char * getText () const
 returns string representation of this key
virtual void setText (const char *ikey)
 Sets this SWKey with a character string.
virtual void sort ()
SWKeyoperator= (const char *ikey)
SWKeyoperator= (const SWKey &ikey)
SWKeyoperator= (SW_POSITION pos)
 operator const char * () const
bool operator== (const SWKey &ikey)
bool operator!= (const SWKey &ikey)
virtual bool operator> (const SWKey &ikey)
virtual bool operator< (const SWKey &ikey)
virtual bool operator>= (const SWKey &ikey)
virtual bool operator<= (const SWKey &ikey)
SWKeyoperator-= (int steps)
SWKeyoperator+= (int steps)
SWKeyoperator++ (int)
SWKeyoperator-- (int)
ListKeyoperator= (const ListKey &key)

Protected Attributes

int arraypos
int arraymax
int arraycnt
SWKey ** array

Private Member Functions

void init ()

Static Private Attributes

static SWClass classdef

Detailed Description

ListKey is the basis for all types of keys that have lists of specified indexes (e.g.

a list of verses, place, etc.)

Definition at line 38 of file listkey.h.


Constructor & Destructor Documentation

sword::ListKey::ListKey ( const char *  ikey = 0  ) 

initializes instance of ListKey

Parameters:
ikey text key


Member Function Documentation

virtual SWKey* sword::ListKey::clone (  )  const [virtual]

Returns a new exact clone of this SWKey object.

This allocates a new SWKey which must be deleted by the caller

Returns:
new clone of this key

Reimplemented from sword::SWKey.

virtual int sword::ListKey::Count (  )  [virtual]

Returns number of elements in list.

Returns:
number of elements in list

virtual char sword::ListKey::SetToElement ( int  ielement,
SW_POSITION  = SW_POSITION(((char) 1)) 
) [virtual]

Sets key to element number.

Parameters:
ielement element number to set to
Returns:
error status

virtual SWKey* sword::ListKey::getElement ( int  pos = -1  )  [virtual]

Gets a key element number.

Parameters:
pos element number to get (or default current)
Returns:
Key or null on error

ListKey& sword::ListKey::operator<< ( const SWKey ikey  )  [inline]

Adds an element to the list.

Parameters:
ikey the element to add

Definition at line 101 of file listkey.h.

virtual void sword::ListKey::copyFrom ( const ListKey ikey  )  [virtual]

Equates this ListKey to another ListKey object.

Parameters:
ikey other ListKey object

virtual void sword::ListKey::copyFrom ( const SWKey ikey  )  [inline, virtual]

Copies as much info (position, range, etc.

) as possible from another SWKey object

Parameters:
ikey other SWKey object from which to copy

Reimplemented from sword::SWKey.

Definition at line 109 of file listkey.h.

virtual void sword::ListKey::setPosition ( SW_POSITION  pos  )  [virtual]

Positions this key.

Parameters:
pos position
Returns:
*this

Reimplemented from sword::SWKey.

virtual long sword::ListKey::Index (  )  const [inline, virtual]

Use this function to get an index position within a module.

Here's a small example how to use this function and Index(long). This function uses the GerLut module and chooses a random verse from the Bible and returns it.

 const char* randomVerse() {
   VerseKey vk;
   SWMgr mgr;
   LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName("de");

   SWModule* module = mgr->Modules("GerLut");
   srand( time(0) );
   const double newIndex = (double(rand())/RAND_MAX)*(24108+8224);
   vk.Index(newIndex);
   module->setKey(vk);

   char* text;
   sprintf(text, "%s: %s",(const char*)vk ,module->StripText(&vk));
   return text;

Reimplemented from sword::SWKey.

Definition at line 127 of file listkey.h.

virtual long sword::ListKey::Index ( long  index  )  [inline, virtual]

Returns the index for the new one given as as parameter.

The first parameter is the new index.

Reimplemented from sword::SWKey.

Definition at line 134 of file listkey.h.

References sword::SWKey::Index().

virtual void sword::ListKey::setText ( const char *  ikey  )  [virtual]

Sets this SWKey with a character string.

Parameters:
ikey string used to set this key

Reimplemented from sword::SWKey.


The documentation for this class was generated from the following file: