The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ListKey Class Reference

#include <listkey.h>

+ Inheritance diagram for ListKey:
+ Collaboration diagram for ListKey:

Public Member Functions

virtual void add (const SWKey &ikey)
 
virtual void clear ()
 
virtual void clearBounds () const
 
virtual SWDEPRECATED void ClearList ()
 
virtual SWKeyclone () const
 
virtual int compare (const SWKey &ikey)
 
virtual void copyFrom (const ListKey &ikey)
 
virtual void copyFrom (const SWKey &ikey)
 
virtual SWDEPRECATED int Count ()
 
virtual void decrement (int step=1)
 
virtual bool equals (const SWKey &ikey)
 
SWDEPRECATED char Error ()
 
const SWClassgetClass () const
 
virtual int getCount () const
 
virtual SWKeygetElement (int pos=-1)
 
virtual const SWKeygetElement (int pos=-1) const
 
virtual SWDEPRECATED SWKeyGetElement (int pos=-1)
 
virtual char getError () const
 
virtual long getIndex () const
 
char * getLocale () const
 
virtual const char * getOSISRefRangeText () const
 
virtual const char * getRangeText () const
 
virtual const char * getShortRangeText () const
 
virtual const char * getShortText () const
 
virtual const char * getText () const
 
virtual void increment (int step=1)
 
virtual bool isBoundSet () const
 
bool isPersist () const
 
virtual bool isTraversable () const
 
 ListKey (const char *ikey=0)
 
 ListKey (ListKey const &k)
 
virtual void nextElement ()
 
ListKeyoperator<< (const SWKey &ikey)
 
SWKEY_OPERATORS ListKeyoperator= (const ListKey &key)
 
SWDEPRECATED char Persist () const
 
SWDEPRECATED char Persist (signed char ipersist)
 
virtual char popError ()
 
virtual void positionFrom (const SWKey &ikey)
 
virtual void remove ()
 
virtual SWDEPRECATED void Remove ()
 
virtual void setError (char err)
 
virtual void setIndex (long index)
 
void setLocale (const char *name)
 
void setPersist (bool ipersist)
 
virtual void setPosition (SW_POSITION pos)
 
virtual void setText (const char *ikey)
 
virtual char setToElement (int ielement, SW_POSITION pos=TOP)
 
virtual SWDEPRECATED char SetToElement (int ielement, SW_POSITION pos=TOP)
 
virtual void sort ()
 
virtual ~ListKey ()
 

Public Attributes

SW_u64 userData
 

Protected Member Functions

SWLocalegetPrivateLocale () const
 

Protected Attributes

SWKey ** array
 
int arraycnt
 
int arraymax
 
int arraypos
 
bool boundSet
 
char error
 
char * keytext
 
char * localeName
 
const SWClassmyClass
 
bool persist
 
char * rangeText
 

Private Member Functions

void init ()
 

Detailed Description

ListKey is a container SWKey which faciliates a list of SWKey objects

Definition at line 38 of file listkey.h.

Constructor & Destructor Documentation

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

initializes instance of ListKey

Parameters
ikeytext key

Definition at line 43 of file listkey.cpp.

43  : SWKey(ikey) {
44  arraymax = 0;
45  clear();
46  init();
47 }
SWKey(const char *ikey=0)
Definition: swkey.cpp:43
virtual void clear()
Definition: listkey.cpp:87
int arraymax
Definition: listkey.h:44
void init()
Definition: listkey.cpp:61
ListKey::ListKey ( ListKey const k)

Definition at line 50 of file listkey.cpp.

50  : SWKey(k.keytext) {
51  arraymax = k.arraymax;
52  arraypos = k.arraypos;
53  arraycnt = k.arraycnt;
54  array = (arraymax)?(SWKey **)malloc(k.arraymax * sizeof(SWKey *)):0;
55  for (int i = 0; i < arraycnt; i++)
56  array[i] = k.array[i]->clone();
57  init();
58 }
int arraycnt
Definition: listkey.h:45
SWKey(const char *ikey=0)
Definition: swkey.cpp:43
virtual SWKey * clone() const
Definition: swkey.cpp:75
int arraymax
Definition: listkey.h:44
char * malloc()
int arraypos
Definition: listkey.h:43
SWKey ** array
Definition: listkey.h:46
void init()
Definition: listkey.cpp:61
Definition: swkey.h:77
ListKey::~ListKey ( )
virtual

cleans up instance of ListKey

Definition at line 77 of file listkey.cpp.

78 {
79  clear();
80 }
virtual void clear()
Definition: listkey.cpp:87

Member Function Documentation

void ListKey::add ( const SWKey ikey)
virtual

Definition at line 128 of file listkey.cpp.

128  {
129  if (++arraycnt > arraymax) {
130  array = (SWKey **) ((array) ? realloc(array, (arraycnt + 32) * sizeof(SWKey *)) : calloc(arraycnt + 32, sizeof(SWKey *)));
131  arraymax = arraycnt + 32;
132  }
133  array[arraycnt-1] = ikey.clone();
135 }
int arraycnt
Definition: listkey.h:45
virtual SWKey * clone() const
Definition: swkey.cpp:75
virtual char setToElement(int ielement, SW_POSITION pos=TOP)
Definition: listkey.cpp:225
int arraymax
Definition: listkey.h:44
char * realloc()
SWKey ** array
Definition: listkey.h:46
Definition: swkey.h:77
void ListKey::clear ( )
virtual

Clears out elements of list

Definition at line 87 of file listkey.cpp.

88 {
89  int loop;
90 
91  if (arraymax) {
92  for (loop = 0; loop < arraycnt; loop++)
93  delete array[loop];
94 
95  free(array);
96  arraymax = 0;
97  }
98  arraycnt = 0;
99  arraypos = 0;
100  array = 0;
101 }
int arraycnt
Definition: listkey.h:45
int arraymax
Definition: listkey.h:44
free(preg->fastmap)
int arraypos
Definition: listkey.h:43
SWKey ** array
Definition: listkey.h:46
virtual void SWKey::clearBounds ( ) const
inlinevirtualinherited

Reimplemented in VerseKey.

Definition at line 190 of file swkey.h.

190 { boundSet = false; }
bool boundSet
Definition: swkey.h:104
virtual SWDEPRECATED void ListKey::ClearList ( )
inlinevirtual
Deprecated:
, use clear(), instead

Definition at line 70 of file listkey.h.

70 { clear(); }
virtual void clear()
Definition: listkey.cpp:87
SWKey * 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 SWKey.

Definition at line 68 of file listkey.cpp.

69 {
70  return new ListKey(*this);
71 }
ListKey(const char *ikey=0)
Definition: listkey.cpp:43
int SWKey::compare ( const SWKey ikey)
virtualinherited

Compares this key object to another SWKey object

Parameters
ikeykey 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

Reimplemented in VerseKey, TreeKey, and TreeKeyIdx.

Definition at line 218 of file swkey.cpp.

219 {
220  return strcmp((const char *)*this, (const char *)ikey);
221 }
void ListKey::copyFrom ( const ListKey ikey)
virtual

Equates this ListKey to another ListKey object

Parameters
ikeyother ListKey object

Definition at line 110 of file listkey.cpp.

110  {
111  clear();
112 
113  arraymax = ikey.arraymax;
114  arraypos = ikey.arraypos;
115  arraycnt = ikey.arraycnt;
116  array = (arraymax)?(SWKey **)malloc(ikey.arraymax * sizeof(SWKey *)):0;
117  for (int i = 0; i < arraycnt; i++)
118  array[i] = ikey.array[i]->clone();
119 
120  setToElement(0);
121 }
int arraycnt
Definition: listkey.h:45
virtual void clear()
Definition: listkey.cpp:87
virtual SWKey * clone() const
Definition: swkey.cpp:75
virtual char setToElement(int ielement, SW_POSITION pos=TOP)
Definition: listkey.cpp:225
int arraymax
Definition: listkey.h:44
char * malloc()
int arraypos
Definition: listkey.h:43
SWKey ** array
Definition: listkey.h:46
Definition: swkey.h:77
virtual void ListKey::copyFrom ( const SWKey ikey)
inlinevirtual

Copies as much info (position, range, etc.) as possible from another SWKey object

Parameters
ikeyother SWKey object from which to copy

Reimplemented from SWKey.

Definition at line 130 of file listkey.h.

130 { SWKey::copyFrom(ikey); }
virtual void copyFrom(const SWKey &ikey)
Definition: swkey.cpp:173
virtual SWDEPRECATED int ListKey::Count ( )
inlinevirtual
Deprecated:
Use getCount

Definition at line 80 of file listkey.h.

80 { return getCount(); }
virtual int getCount() const
Definition: listkey.cpp:211
void ListKey::decrement ( int  step = 1)
virtual

Decrements a number of elements

Reimplemented from SWKey.

Definition at line 187 of file listkey.cpp.

187  {
188  if (step < 0) {
189  increment(step*-1);
190  return;
191  }
192  popError(); // clear error
193  for(; step && !popError(); step--) {
194  if (arraypos > -1 && arraycnt) {
195  if (array[arraypos]->isBoundSet())
196  (*(array[arraypos]))--;
197  if ((array[arraypos]->popError()) || (!array[arraypos]->isBoundSet())) {
198  setToElement(arraypos-1, BOTTOM);
199  }
200  else SWKey::setText((const char *)(*array[arraypos]));
201  }
202  else error = KEYERR_OUTOFBOUNDS;
203  }
204 }
virtual void setText(const char *ikey)
Definition: swkey.cpp:162
virtual bool isBoundSet() const
Definition: swkey.h:189
int arraycnt
Definition: listkey.h:45
#define BOTTOM
Definition: swkey.h:69
virtual char setToElement(int ielement, SW_POSITION pos=TOP)
Definition: listkey.cpp:225
int arraypos
Definition: listkey.h:43
virtual void increment(int step=1)
Definition: listkey.cpp:163
#define KEYERR_OUTOFBOUNDS
Definition: swkey.h:35
virtual char popError()
Definition: swkey.cpp:147
SWKey ** array
Definition: listkey.h:46
char error
Definition: swkey.h:106
virtual bool SWKey::equals ( const SWKey ikey)
inlinevirtualinherited

test equality of this SWKey object's position with another SWKey

Parameters
ikeykey to compare with this one
Returns
true if the key positions are equal

Definition at line 204 of file swkey.h.

204 { return !compare(ikey); }
virtual int compare(const SWKey &ikey)
Definition: swkey.cpp:218
SWDEPRECATED char SWKey::Error ( )
inlineinherited
Deprecated:
Use popError and getError instead

Definition at line 169 of file swkey.h.

169 { return popError(); }
virtual char popError()
Definition: swkey.cpp:147
const SWClass* SWObject::getClass ( ) const
inlineinherited

Use this to get the class definition and inheritance order.

Returns
The class definition of this object

Definition at line 63 of file swobject.h.

63  {
64  return myClass;
65  }
const SWClass * myClass
Definition: swobject.h:55
int ListKey::getCount ( ) const
virtual

Returns number of key elements in list

Returns
number of key elements in list

Definition at line 211 of file listkey.cpp.

211  {
212  return arraycnt;
213 }
int arraycnt
Definition: listkey.h:45
SWKey * ListKey::getElement ( int  pos = -1)
virtual

Gets a key element number

Parameters
poselement number to get (or default current)
Returns
Key or null on error

Definition at line 270 of file listkey.cpp.

270  {
271  const ListKey &self = *this;
272  return const_cast<SWKey *>(self.getElement(pos));
273 }
int pos
Definition: regex.c:5534
Definition: swkey.h:77
const SWKey * ListKey::getElement ( int  pos = -1) const
virtual

Definition at line 260 of file listkey.cpp.

260  {
261  if (pos < 0)
262  pos = arraypos;
263 
264  if (pos >=arraycnt)
266 
267  return (error) ? 0:array[pos];
268 }
int arraycnt
Definition: listkey.h:45
int pos
Definition: regex.c:5534
int arraypos
Definition: listkey.h:43
#define KEYERR_OUTOFBOUNDS
Definition: swkey.h:35
SWKey ** array
Definition: listkey.h:46
char error
Definition: swkey.h:106
virtual SWDEPRECATED SWKey* ListKey::GetElement ( int  pos = -1)
inlinevirtual
Deprecated:
Use getElement

Definition at line 117 of file listkey.h.

117 { return getElement(pos); }
int pos
Definition: regex.c:5534
virtual SWKey * getElement(int pos=-1)
Definition: listkey.cpp:270
virtual char SWKey::getError ( ) const
inlinevirtualinherited

Definition at line 164 of file swkey.h.

164 { return error; }
char error
Definition: swkey.h:106
virtual long ListKey::getIndex ( ) const
inlinevirtual

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

Reimplemented from SWKey.

Definition at line 149 of file listkey.h.

149 { return arraypos; }
int arraypos
Definition: listkey.h:43
char* SWKey::getLocale ( ) const
inlineinherited

Definition at line 224 of file swkey.h.

224 { return localeName; }
char * localeName
Definition: swkey.h:108
const char * ListKey::getOSISRefRangeText ( ) const
virtual

Reimplemented from SWKey.

Definition at line 315 of file listkey.cpp.

315  {
316  char *buf = new char[(arraycnt + 1) * 255];
317  buf[0] = 0;
318  for (int i = 0; i < arraycnt; i++) {
319  strcat(buf, array[i]->getOSISRefRangeText());
320  if (i < arraycnt-1)
321  strcat(buf, ";");
322  }
323  stdstr(&rangeText, buf);
324  delete [] buf;
325  return rangeText;
326 }
int arraycnt
Definition: listkey.h:45
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
SWKey ** array
Definition: listkey.h:46
char * rangeText
Definition: swkey.h:103
virtual const char * getOSISRefRangeText() const
Definition: listkey.cpp:315
SWLocale * SWKey::getPrivateLocale ( ) const
protectedinherited

Definition at line 111 of file swkey.cpp.

111  {
112  if (!locale) {
113  if ((!localeCache.name) || (strcmp(localeCache.name, localeName))) {
115  // this line is the entire bit of work we're trying to avoid with the cache
116  // worth it? compare time examples/cmdline/search KJV "God love world" to
117  // same with this method reduced to:
118  // if (!local) local = ... (call below); return locale;
120  }
122  }
123  return locale;
124 }
SWLocale * locale
Definition: swkey.h:82
char * localeName
Definition: swkey.h:108
char * name
Definition: swkey.h:81
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
virtual SWLocale * getLocale(const char *name)
Definition: localemgr.cpp:210
static LocaleMgr * getSystemLocaleMgr()
Definition: localemgr.cpp:54
SWLocale * locale
Definition: swkey.h:94
static LocaleCache localeCache
Definition: swkey.h:92
const char * ListKey::getRangeText ( ) const
virtual

Reimplemented from SWKey.

Definition at line 297 of file listkey.cpp.

297  {
298  char *buf = new char[(arraycnt + 1) * 255];
299  buf[0] = 0;
300  for (int i = 0; i < arraycnt; i++) {
301  strcat(buf, array[i]->getRangeText());
302  if (i < arraycnt-1)
303  strcat(buf, "; ");
304  }
305  stdstr(&rangeText, buf);
306  delete [] buf;
307  return rangeText;
308 }
int arraycnt
Definition: listkey.h:45
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
SWKey ** array
Definition: listkey.h:46
char * rangeText
Definition: swkey.h:103
virtual const char * getRangeText() const
Definition: listkey.cpp:297
const char * ListKey::getShortRangeText ( ) const
virtual

Reimplemented from SWKey.

Definition at line 333 of file listkey.cpp.

333  {
334  SWBuf buf;
335  for (int i = 0; i < arraycnt; i++) {
336  buf += array[i]->getShortRangeText();
337  if (i < arraycnt-1)
338  buf += "; ";
339  }
340  stdstr(&rangeText, buf.c_str());
341  return rangeText;
342 }
virtual const char * getShortRangeText() const
Definition: swkey.h:187
Definition: swbuf.h:47
int arraycnt
Definition: listkey.h:45
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
const char * c_str() const
Definition: swbuf.h:158
SWKey ** array
Definition: listkey.h:46
char * rangeText
Definition: swkey.h:103
const char * ListKey::getShortText ( ) const
virtual

Reimplemented from SWKey.

Definition at line 355 of file listkey.cpp.

355  {
356  int pos = arraypos;
357  SWKey *key = (pos >= arraycnt || !arraycnt) ? 0:array[pos];
358  return (key) ? key->getShortText() : keytext;
359 }
virtual const char * getShortText() const
Definition: swkey.h:185
int arraycnt
Definition: listkey.h:45
int pos
Definition: regex.c:5534
char * keytext
Definition: swkey.h:102
int arraypos
Definition: listkey.h:43
SWKey ** array
Definition: listkey.h:46
Definition: swkey.h:77
const char * ListKey::getText ( ) const
virtual

returns string representation of this key

Reimplemented from SWKey.

Definition at line 349 of file listkey.cpp.

349  {
350  int pos = arraypos;
351  SWKey *key = (pos >= arraycnt || !arraycnt) ? 0:array[pos];
352  return (key) ? key->getText() : keytext;
353 }
int arraycnt
Definition: listkey.h:45
int pos
Definition: regex.c:5534
char * keytext
Definition: swkey.h:102
virtual const char * getText() const
Definition: swkey.cpp:184
int arraypos
Definition: listkey.h:43
SWKey ** array
Definition: listkey.h:46
Definition: swkey.h:77
void ListKey::increment ( int  step = 1)
virtual

Increments a number of elements

Reimplemented from SWKey.

Definition at line 163 of file listkey.cpp.

163  {
164  if (step < 0) {
165  decrement(step*-1);
166  return;
167  }
168  popError(); // clear error
169  for(; step && !popError(); step--) {
170  if (arraypos < arraycnt && arraycnt) {
171  if (array[arraypos]->isBoundSet())
172  (*(array[arraypos]))++;
173  if ((array[arraypos]->popError()) || (!array[arraypos]->isBoundSet())) {
174  setToElement(arraypos+1);
175  }
176  else SWKey::setText((const char *)(*array[arraypos]));
177  }
178  else error = KEYERR_OUTOFBOUNDS;
179  }
180 }
virtual void setText(const char *ikey)
Definition: swkey.cpp:162
virtual bool isBoundSet() const
Definition: swkey.h:189
virtual void decrement(int step=1)
Definition: listkey.cpp:187
int arraycnt
Definition: listkey.h:45
virtual char setToElement(int ielement, SW_POSITION pos=TOP)
Definition: listkey.cpp:225
int arraypos
Definition: listkey.h:43
#define KEYERR_OUTOFBOUNDS
Definition: swkey.h:35
virtual char popError()
Definition: swkey.cpp:147
SWKey ** array
Definition: listkey.h:46
char error
Definition: swkey.h:106
void ListKey::init ( )
private

Definition at line 61 of file listkey.cpp.

61  {
62  myClass = &classdef;
63  // this is a listkey, bound is always set
64  boundSet = true;
65 }
const SWClass * myClass
Definition: swobject.h:55
static const SWClass classdef(classes)
bool boundSet
Definition: swkey.h:104
virtual bool SWKey::isBoundSet ( ) const
inlinevirtualinherited

Definition at line 189 of file swkey.h.

189 { return boundSet; }
bool boundSet
Definition: swkey.h:104
bool SWKey::isPersist ( ) const
inherited

Gets whether this key should persist in any module to which it is set otherwise just a copy will be used in the module.

Returns
1 - persists in module; 0 - a copy is attempted

Definition at line 99 of file swkey.cpp.

100 {
101  return persist;
102 }
bool persist
Definition: swkey.h:105
virtual bool ListKey::isTraversable ( ) const
inlinevirtual

Whether or not this key can be ++ – incremented

Reimplemented from SWKey.

Definition at line 148 of file listkey.h.

148 { return true; }
virtual void ListKey::nextElement ( )
inlinevirtual

Definition at line 146 of file listkey.h.

146 { setToElement(arraypos + 1); }
virtual char setToElement(int ielement, SW_POSITION pos=TOP)
Definition: listkey.cpp:225
int arraypos
Definition: listkey.h:43
ListKey& ListKey::operator<< ( const SWKey ikey)
inline

Adds an element to the list

Parameters
ikeythe element to add

Definition at line 122 of file listkey.h.

122 { add(ikey); return *this; }
virtual void add(const SWKey &ikey)
Definition: listkey.cpp:128
SWKEY_OPERATORS ListKey& ListKey::operator= ( const ListKey key)
inline

Definition at line 165 of file listkey.h.

165 { copyFrom(key); return *this; }
virtual void copyFrom(const ListKey &ikey)
Definition: listkey.cpp:110
SWDEPRECATED char SWKey::Persist ( ) const
inlineinherited
Deprecated:
Use isPersist

Definition at line 148 of file swkey.h.

148 { return isPersist(); }
bool isPersist() const
Definition: swkey.cpp:99
SWDEPRECATED char SWKey::Persist ( signed char  ipersist)
inlineinherited
Deprecated:
Use setPersist and isPersist instead.

Definition at line 158 of file swkey.h.

158 { setPersist(ipersist!=0); return isPersist(); }
void setPersist(bool ipersist)
Definition: swkey.cpp:135
bool isPersist() const
Definition: swkey.cpp:99
char SWKey::popError ( )
virtualinherited

Gets and clears error status

Returns
error status

Definition at line 147 of file swkey.cpp.

148 {
149  char retval = error;
150 
151  error = 0;
152  return retval;
153 }
char error
Definition: swkey.h:106
virtual void SWKey::positionFrom ( const SWKey ikey)
inlinevirtualinherited

Reimplemented in VerseKey.

Definition at line 180 of file swkey.h.

180 { copyFrom(ikey); }
virtual void copyFrom(const SWKey &ikey)
Definition: swkey.cpp:173
void ListKey::remove ( )
virtual

Removes current element from list

Definition at line 281 of file listkey.cpp.

281  {
282  if ((arraypos > -1) && (arraypos < arraycnt)) {
283  delete array[arraypos];
284  if (arraypos < arraycnt - 1)
285  memmove(&array[arraypos], &array[arraypos+1], (arraycnt - arraypos - 1) * sizeof(SWKey *));
286  arraycnt--;
287 
288  setToElement((arraypos)?arraypos-1:0);
289  }
290 }
int arraycnt
Definition: listkey.h:45
virtual char setToElement(int ielement, SW_POSITION pos=TOP)
Definition: listkey.cpp:225
int arraypos
Definition: listkey.h:43
SWKey ** array
Definition: listkey.h:46
Definition: swkey.h:77
virtual SWDEPRECATED void ListKey::Remove ( )
inlinevirtual
Deprecated:
Use remove

Definition at line 88 of file listkey.h.

88 { remove(); }
virtual void SWKey::setError ( char  err)
inlinevirtualinherited

Definition at line 165 of file swkey.h.

165 { error = err; }
char error
Definition: swkey.h:106
virtual void ListKey::setIndex ( long  index)
inlinevirtual

Returns the index for the new one given as as parameter. The first parameter is the new index.

Reimplemented from SWKey.

Definition at line 159 of file listkey.h.

159 { setToElement((int)index); }
virtual char setToElement(int ielement, SW_POSITION pos=TOP)
Definition: listkey.cpp:225
long index
Definition: swkey.h:97
void SWKey::setLocale ( const char *  name)
inlineinherited

Definition at line 225 of file swkey.h.

225 { stdstr(&localeName, name); locale = 0; } // this will force an on demand lookup of our locale
char * localeName
Definition: swkey.h:108
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
SWLocale * locale
Definition: swkey.h:94
void SWKey::setPersist ( bool  ipersist)
inherited

Sets whether this key should persist in any module to which it is set otherwise just a copy will be used in the module.

Parameters
ipersistvalue which to set persist;

Definition at line 135 of file swkey.cpp.

136 {
137  persist = ipersist;
138 }
bool persist
Definition: swkey.h:105
void ListKey::setPosition ( SW_POSITION  pos)
virtual

Positions this key

Parameters
posposition

Reimplemented from SWKey.

Definition at line 147 of file listkey.cpp.

147  {
148  switch (p) {
149  case 1: // GCC won't compile P_TOP
150  setToElement(0, p);
151  break;
152  case 2: // GCC won't compile P_BOTTOM
153  setToElement(arraycnt-1, p);
154  break;
155  }
156 }
int arraycnt
Definition: listkey.h:45
virtual char setToElement(int ielement, SW_POSITION pos=TOP)
Definition: listkey.cpp:225
void ListKey::setText ( const char *  ikey)
virtual

Sets this SWKey with a character string

Parameters
ikeystring used to set this key

Reimplemented from SWKey.

Definition at line 362 of file listkey.cpp.

362  {
363  // at least try to set the current element to this text
364  for (arraypos = 0; arraypos < arraycnt; arraypos++) {
365  SWKey *key = array[arraypos];
366  if (key) {
367  if (key->isTraversable() && key->isBoundSet()) {
368  key->setText(ikey);
369  if (!key->popError())
370  break;
371  }
372  else {
373  if (!strcmp(key->getText(), ikey))
374  break;
375  }
376  }
377  }
378  if (arraypos >= arraycnt) {
379  error = 1;
380  arraypos = arraycnt-1;
381  }
382 
383  SWKey::setText(ikey);
384 }
virtual void setText(const char *ikey)
Definition: swkey.cpp:162
virtual bool isBoundSet() const
Definition: swkey.h:189
int arraycnt
Definition: listkey.h:45
virtual const char * getText() const
Definition: swkey.cpp:184
int arraypos
Definition: listkey.h:43
virtual char popError()
Definition: swkey.cpp:147
SWKey ** array
Definition: listkey.h:46
char error
Definition: swkey.h:106
virtual bool isTraversable() const
Definition: swkey.h:222
Definition: swkey.h:77
char ListKey::setToElement ( int  ielement,
SW_POSITION  pos = TOP 
)
virtual

Sets container to subkey element number and repositions that subkey to either top or bottom

Parameters
ielement- element number to set to
pos- set the subkey element to position (TOP) or BOTTOM
Returns
error status deprecated use setToElement

Definition at line 225 of file listkey.cpp.

225  {
226  arraypos = ielement;
227  if (arraypos >= arraycnt) {
228  arraypos = (arraycnt>0)?arraycnt - 1:0;
230  }
231  else {
232  if (arraypos < 0) {
233  arraypos = 0;
235  }
236  else {
237  error = 0;
238  }
239  }
240 
241  if (arraycnt) {
242  if (array[arraypos]->isBoundSet())
243  (*array[arraypos]) = pos;
244  SWKey::setText((const char *)(*array[arraypos]));
245  }
246  else SWKey::setText("");
247 
248  return error;
249 }
virtual void setText(const char *ikey)
Definition: swkey.cpp:162
virtual bool isBoundSet() const
Definition: swkey.h:189
int arraycnt
Definition: listkey.h:45
int pos
Definition: regex.c:5534
int arraypos
Definition: listkey.h:43
#define KEYERR_OUTOFBOUNDS
Definition: swkey.h:35
SWKey ** array
Definition: listkey.h:46
char error
Definition: swkey.h:106
virtual SWDEPRECATED char ListKey::SetToElement ( int  ielement,
SW_POSITION  pos = TOP 
)
inlinevirtual
Deprecated:
Use setToElement

Definition at line 102 of file listkey.h.

102 { return setToElement(ielement, pos); }
virtual char setToElement(int ielement, SW_POSITION pos=TOP)
Definition: listkey.cpp:225
void ListKey::sort ( )
virtual

Definition at line 387 of file listkey.cpp.

387  {
388  for (int i = 0; i < arraycnt; i++) {
389  for (int j = i; j < arraycnt; j++) {
390  if (*array[j] < *array[i]) {
391  SWKey *tmp = array[i];
392  array[i] = array[j];
393  array[j] = tmp;
394  }
395  }
396  }
397 }
int arraycnt
Definition: listkey.h:45
SWKey ** array
Definition: listkey.h:46
Definition: swkey.h:77

Member Data Documentation

SWKey** ListKey::array
protected

Definition at line 46 of file listkey.h.

int ListKey::arraycnt
protected

Definition at line 45 of file listkey.h.

int ListKey::arraymax
protected

Definition at line 44 of file listkey.h.

int ListKey::arraypos
protected

Definition at line 43 of file listkey.h.

bool SWKey::boundSet
mutableprotectedinherited

Definition at line 104 of file swkey.h.

char SWKey::error
mutableprotectedinherited

Definition at line 106 of file swkey.h.

char* SWKey::keytext
protectedinherited

Definition at line 102 of file swkey.h.

char* SWKey::localeName
protectedinherited

Definition at line 108 of file swkey.h.

const SWClass* SWObject::myClass
protectedinherited

Definition at line 55 of file swobject.h.

bool SWKey::persist
protectedinherited

Definition at line 105 of file swkey.h.

char* SWKey::rangeText
mutableprotectedinherited

Definition at line 103 of file swkey.h.

SW_u64 SWKey::userData
inherited

Definition at line 115 of file swkey.h.


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