The Sword Project: sword::SWKey Class Reference |
#include <swkey.h>
Inheritance diagram for sword::SWKey:
Public Member Functions | |
SWKey (const char *ikey=0) | |
initializes instance of SWKey from a string All keys can be reduced to a string representation which should be able to be used to again set the key to the same position | |
SWKey (SWKey const &k) | |
Copy Constructor. | |
virtual | ~SWKey () |
Destructor, cleans up this instance of SWKey. | |
virtual SWKey * | clone () const |
Returns a new exact clone of this SWKey object. | |
char | Persist () const |
Gets whether this key should persist in any module to which it is set otherwise just a copy will be used in the module. | |
char | Persist (signed char ipersist) |
Sets whether this key should persist in any module to which it is set otherwise just a copy will be used in the module. | |
virtual char | Error () |
Gets and clears error status. | |
virtual void | setText (const char *ikey) |
Sets this SWKey with a character string. | |
virtual void | copyFrom (const SWKey &ikey) |
Copies as much info (position, range, etc. | |
virtual const char * | getText () const |
returns string representation of this key | |
virtual const char * | getShortText () const |
virtual const char * | getRangeText () const |
virtual bool | isBoundSet () const |
virtual int | compare (const SWKey &ikey) |
Compares this key object to another SWKey object. | |
virtual bool | equals (const SWKey &ikey) |
test equality of this SWKey object's position with another SWKey | |
virtual void | setPosition (SW_POSITION) |
virtual void | decrement (int steps=1) |
Decrements key a number of entry positions This is only valid if isTraversable is true. | |
virtual void | increment (int steps=1) |
Increments key a number of entry positions This is only valid if isTraversable is true. | |
char | Traversable () |
deprecated, use isTraversible | |
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 long | Index (long iindex) |
See documentation for Index(). | |
SWKey & | operator= (const char *ikey) |
SWKey & | operator= (const SWKey &ikey) |
SWKey & | operator= (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) |
SWKey & | operator-= (int steps) |
SWKey & | operator+= (int steps) |
SWKey & | operator++ (int) |
SWKey & | operator-- (int) |
Public Attributes | |
void * | userData |
Protected Attributes | |
char * | keytext |
char * | rangeText |
bool | boundSet |
char | persist |
char | error |
Private Member Functions | |
void | init () |
Private Attributes | |
long | index |
Static Private Attributes | |
static SWClass | classdef |
It always represents a possible location into a module and can additionally represent a domain of entries (e.g. "John 3:16" in the domain "John 1:1 - Mark 5:25")
Definition at line 71 of file swkey.h.
sword::SWKey::SWKey | ( | const char * | ikey = 0 |
) |
initializes instance of SWKey from a string All keys can be reduced to a string representation which should be able to be used to again set the key to the same position
ikey | string to use for initializing this new key |
virtual SWKey* sword::SWKey::clone | ( | ) | const [virtual] |
Returns a new exact clone of this SWKey object.
This allocates a new SWKey which must be deleted by the caller
Reimplemented in sword::ListKey, sword::TreeKeyIdx, sword::VerseKey, and sword::VerseTreeKey.
char sword::SWKey::Persist | ( | ) | const |
Gets whether this key should persist in any module to which it is set otherwise just a copy will be used in the module.
char sword::SWKey::Persist | ( | signed char | ipersist | ) |
Sets whether this key should persist in any module to which it is set otherwise just a copy will be used in the module.
ipersist | value which to set persist; |
virtual char sword::SWKey::Error | ( | ) | [virtual] |
Gets and clears error status.
virtual void sword::SWKey::setText | ( | const char * | ikey | ) | [virtual] |
Sets this SWKey with a character string.
ikey | string used to set this key |
Reimplemented in sword::ListKey, sword::TreeKey, sword::TreeKeyIdx, and sword::VerseKey.
virtual void sword::SWKey::copyFrom | ( | const SWKey & | ikey | ) | [virtual] |
Copies as much info (position, range, etc.
) as possible from another SWKey object
ikey | other SWKey object from which to copy |
Reimplemented in sword::ListKey, sword::TreeKeyIdx, and sword::VerseKey.
Referenced by sword::VerseKey::operator=(), sword::TreeKeyIdx::operator=(), and sword::ListKey::operator=().
virtual int sword::SWKey::compare | ( | const SWKey & | ikey | ) | [virtual] |
Compares this key object to another SWKey object.
ikey | key to compare with this one |
Reimplemented in sword::TreeKey, sword::TreeKeyIdx, and sword::VerseKey.
virtual bool sword::SWKey::equals | ( | const SWKey & | ikey | ) | [inline, virtual] |
virtual void sword::SWKey::decrement | ( | int | steps = 1 |
) | [virtual] |
Decrements key a number of entry positions This is only valid if isTraversable is true.
steps | Number of entries to jump backward |
Reimplemented in sword::ListKey, sword::TreeKey, sword::TreeKeyIdx, and sword::VerseKey.
virtual void sword::SWKey::increment | ( | int | steps = 1 |
) | [virtual] |
Increments key a number of entry positions This is only valid if isTraversable is true.
steps | Number of entries to jump forward |
Reimplemented in sword::ListKey, sword::TreeKey, sword::TreeKeyIdx, and sword::VerseKey.
virtual long sword::SWKey::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 in sword::ListKey, sword::TreeKey, and sword::VerseKey.
Definition at line 202 of file swkey.h.
Referenced by sword::ListKey::Index().
The SWORD Project; P. O. Box 2528; Tempe, AZ 85280-2528 USA |