#include <swkey.h>
Inheritance diagram for SWKey:
Public Methods | |
SWKey (const char *ikey=0) | |
initializes instance of SWKey. More... | |
SWKey (SWKey const &k) | |
Copy Constructor. More... | |
virtual | ~SWKey () |
Destructor, cleans up this instance of SWKey. | |
virtual SWKey * | clone () const |
Returns a copy of this SWKey object. More... | |
char | Persist () const |
Gets whether this object itself persists within a module that it was used to SetKey or just a copy. More... | |
char | Persist (signed char ikey) |
Set/gets whether this object itself persists within a module that it was used to SetKey or just a copy. More... | |
virtual char | Error () |
Gets and clears error status. More... | |
virtual void | setText (const char *ikey) |
Equates this SWKey to a character string. More... | |
virtual void | copyFrom (const SWKey &ikey) |
Equates this SWKey to another SWKey object. More... | |
virtual const char * | getText () const |
returns text key if (char *) cast is requested. | |
virtual const char * | getShortText () const |
virtual int | compare (const SWKey &ikey) |
Compares another VerseKey object. More... | |
virtual bool | equals (const SWKey &ikey) |
Compares another VerseKey object. More... | |
virtual void | setPosition (SW_POSITION) |
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 () |
virtual long | Index () const |
Use this function to get te current position withing a module. More... | |
virtual long | Index (long iindex) |
Public Attributes | |
void * | userData |
Protected Attributes | |
char * | keytext |
char | persist |
char | error |
Private Methods | |
void | init () |
Private Attributes | |
long | index |
Static Private Attributes | |
SWClass | classdef |
verse, word, place, etc.)
Definition at line 76 of file swkey.h.
|
initializes instance of SWKey.
Definition at line 20 of file swkey.cpp. Referenced by clone().
00021 { 00022 index = 0; 00023 persist = 0; 00024 keytext = 0; 00025 error = 0; 00026 stdstr(&keytext, ikey); 00027 init(); 00028 } |
|
Copy Constructor.
Definition at line 30 of file swkey.cpp. References error, index, keytext, persist, and userData.
00031 { 00032 index = k.index; 00033 persist = k.persist; 00034 userData = k.userData; 00035 keytext = 0; 00036 error = k.error; 00037 stdstr(&keytext, k.keytext); 00038 init(); 00039 } |
|
Returns a copy of this SWKey object. This is useful to get a 1:1 copy of an SWKey based object.
Reimplemented in ListKey, and VerseKey. Definition at line 45 of file swkey.cpp. References SWKey(). Referenced by ListKey::copyFrom(), and SWModule::Search().
00046 { 00047 return new SWKey(*this); 00048 } |
|
Compares another VerseKey object.
Reimplemented in TreeKey, TreeKeyIdx, and VerseKey. Definition at line 151 of file swkey.cpp. Referenced by TreeKeyIdx::compare().
00152 { 00153 return strcmp((const char *)*this, (const char *)ikey); 00154 } |
|
Equates this SWKey to another SWKey object.
Reimplemented in ListKey, TreeKeyIdx, and VerseKey. Definition at line 126 of file swkey.cpp. References setText(). Referenced by VerseKey::copyFrom(), TreeKeyIdx::copyFrom(), and ListKey::copyFrom().
00126 { 00127 // not desirable Persist(ikey.Persist()); 00128 setText((const char *)ikey); 00129 } |
|
Decrements key a number of entries.
Reimplemented in ListKey, TreeKey, TreeKeyIdx, and VerseKey. Definition at line 194 of file swkey.cpp.
00194 { 00195 error = KEYERR_OUTOFBOUNDS; 00196 } |
|
Compares another VerseKey object.
Definition at line 167 of file swkey.h.
00167 { return !compare(ikey); } |
|
Gets and clears error status.
Definition at line 100 of file swkey.cpp. Referenced by VerseKey::decrement(), ListKey::decrement(), VerseKey::increment(), ListKey::increment(), SWModule::operator+=(), SWModule::operator-=(), SWModule::operator=(), VerseKey::setPosition(), and TreeKeyIdx::setText().
00101 { 00102 char retval = error; 00103 00104 error = 0; 00105 return retval; 00106 } |
|
Increments key a number of entries.
Reimplemented in ListKey, TreeKey, TreeKeyIdx, and VerseKey. Definition at line 181 of file swkey.cpp.
00181 { 00182 error = KEYERR_OUTOFBOUNDS; 00183 } |
|
Use this function to get te current position withing 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::systemLocaleMgr.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 ListKey, TreeKey, and VerseKey. Definition at line 208 of file swkey.h. Referenced by ListKey::Index(), and SWModule::Search().
00208 { return index; } |
|
Set/gets whether this object itself persists within a module that it was used to SetKey or just a copy. (1 - persists in module; 0 - a copy is attempted
Definition at line 85 of file swkey.cpp.
00086 { 00087 if (ipersist != -1) 00088 persist = ipersist; 00089 00090 return persist; 00091 } |
|
Gets whether this object itself persists within a module that it was used to SetKey or just a copy. (1 - persists in module; 0 - a copy is attempted
Definition at line 68 of file swkey.cpp. Referenced by SWLD::KeyText(), SWModule::RenderText(), SWModule::Search(), SWModule::SetKey(), SWModule::StripText(), and SWModule::~SWModule().
00069 { 00070 return persist; 00071 } |
|
Equates this SWKey to a character string.
Reimplemented in TreeKey, TreeKeyIdx, and VerseKey. Definition at line 115 of file swkey.cpp. Referenced by copyFrom(), VerseKey::parse(), and VerseKey::setText().
00115 { 00116 stdstr(&keytext, ikey); 00117 } |