1
/******************************************************************************
2
* swkey.cpp - code for base class 'SWKey'. SWKey is the basis for all
3
* types of keys for indexing into modules (e.g. verse, word,
12
static const char *classes[] = {"SWKey", "SWObject", 0};
13
SWClass SWKey::classdef(classes);
15
/******************************************************************************
16
* SWKey Constructor - initializes instance of SWKey
18
* ENT: ikey - text key
21
SWKey::SWKey(const char *ikey)
29
stdstr(&keytext, ikey);
33
SWKey::SWKey(SWKey const &k)
37
userData = k.userData;
50
SWKey *SWKey::clone() const
52
return new SWKey(*this);
55
/******************************************************************************
56
* SWKey Destructor - cleans up instance of SWKey
67
/******************************************************************************
68
* SWKey::Persist - Gets whether this object itself persists within a
69
* module that it was used to setKey or just a copy.
70
* (1 - persists in module; 0 - a copy is attempted
72
* RET: value of persist
75
char SWKey::Persist() const
81
/******************************************************************************
82
* SWKey::Persist - Set/gets whether this object itself persists within a
83
* module that it was used to setKey or just a copy.
84
* (1 - persists in module; 0 - a copy is attempted
86
* ENT: ipersist - value which to set persist
89
* RET: value of persist
92
char SWKey::Persist(signed char ipersist)
101
/******************************************************************************
102
* SWKey::Error - Gets and clears error status
116
/******************************************************************************
117
* SWKey::setText Equates this SWKey to a character string
119
* ENT: ikey - other swkey object
122
void SWKey::setText(const char *ikey) {
123
stdstr(&keytext, ikey);
127
/******************************************************************************
128
* SWKey::copyFrom Equates this SWKey to another SWKey object
130
* ENT: ikey - other swkey object
133
void SWKey::copyFrom(const SWKey &ikey) {
134
// not desirable Persist(ikey.Persist());
135
setText((const char *)ikey);
139
/******************************************************************************
140
* SWKey::getText - returns text key if (const char *) cast is requested
143
const char *SWKey::getText() const {
148
/******************************************************************************
149
* SWKey::getRangeText - returns parsable range text for this key
152
const char *SWKey::getRangeText() const {
153
stdstr(&rangeText, keytext);
158
/******************************************************************************
159
* SWKey::compare - Compares another VerseKey object
161
* ENT: ikey - key to compare with this one
163
* RET: > 0 if this key is greater than compare key
168
int SWKey::compare(const SWKey &ikey)
170
return strcmp((const char *)*this, (const char *)ikey);
174
/******************************************************************************
175
* SWKey::setPosition(SW_POSITION) - Positions this key if applicable
178
void SWKey::setPosition(SW_POSITION p) {
184
// *this = "zzzzzzzzz";
190
/******************************************************************************
191
* SWKey::increment - Increments key a number of entries
193
* ENT: increment - Number of entries to jump forward
198
void SWKey::increment(int) {
199
error = KEYERR_OUTOFBOUNDS;
203
/******************************************************************************
204
* SWKey::decrement - Decrements key a number of entries
206
* ENT: decrement - Number of entries to jump backward
211
void SWKey::decrement(int) {
212
error = KEYERR_OUTOFBOUNDS;