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

#include <strkey.h>

+ Inheritance diagram for StrKey:
+ Collaboration diagram for StrKey:

Public Member Functions

virtual void clearBounds () const
 
virtual SWKeyclone () const
 
virtual int compare (const SWKey &ikey)
 
virtual void copyFrom (const SWKey &ikey)
 
virtual void decrement (int steps=1)
 
virtual bool equals (const SWKey &ikey)
 
SWDEPRECATED char Error ()
 
const SWClassgetClass () const
 
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 steps=1)
 
virtual bool isBoundSet () const
 
bool isPersist () const
 
virtual bool isTraversable () const
 
SWDEPRECATED char Persist () const
 
SWDEPRECATED char Persist (signed char ipersist)
 
virtual char popError ()
 
virtual void positionFrom (const SWKey &ikey)
 
virtual void setError (char err)
 
virtual void setIndex (long iindex)
 
void setLocale (const char *name)
 
void setPersist (bool ipersist)
 
virtual void setPosition (SW_POSITION)
 
virtual void setText (const char *ikey)
 
 StrKey (const char *ikey=0)
 
virtual ~StrKey ()
 

Public Attributes

SW_u64 userData
 

Protected Member Functions

SWLocalegetPrivateLocale () const
 

Protected Attributes

bool boundSet
 
char error
 
char * keytext
 
char * localeName
 
const SWClassmyClass
 
bool persist
 
char * rangeText
 

Private Member Functions

void init ()
 

Detailed Description

a standard string key class (used for modules that index on single strings e.g., for lexicons and dictionaries

Definition at line 37 of file strkey.h.

Constructor & Destructor Documentation

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

c-tor which initialized a StrKey object with a simple string

Parameters
ikeytext key

Definition at line 41 of file strkey.cpp.

41  : SWKey(ikey)
42 {
43  init();
44 }
SWKey(const char *ikey=0)
Definition: swkey.cpp:43
void init()
Definition: strkey.cpp:47
StrKey::~StrKey ( )
virtual

Definition at line 58 of file strkey.cpp.

58  {
59 }

Member Function Documentation

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
SWKey * SWKey::clone ( ) const
virtualinherited

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 in VerseKey, VerseTreeKey, TreeKeyIdx, and ListKey.

Definition at line 75 of file swkey.cpp.

76 {
77  return new SWKey(*this);
78 }
SWKey(const char *ikey=0)
Definition: swkey.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 SWKey::copyFrom ( const SWKey ikey)
virtualinherited

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

Parameters
ikeyother SWKey object from which to copy

Reimplemented in VerseKey, ListKey, and TreeKeyIdx.

Definition at line 173 of file swkey.cpp.

173  {
174 // not desirable Persist(ikey.Persist());
175  setLocale(ikey.getLocale());
176  setText((const char *)ikey);
177 }
virtual void setText(const char *ikey)
Definition: swkey.cpp:162
void setLocale(const char *name)
Definition: swkey.h:225
char * getLocale() const
Definition: swkey.h:224
void SWKey::decrement ( int  steps = 1)
virtualinherited

Decrements key a number of entry positions This is only valid if isTraversable is true

Parameters
stepsNumber of entries to jump backward

Reimplemented in VerseKey, ListKey, TreeKey, TreeKeyIdx, and VerseTreeKey.

Definition at line 261 of file swkey.cpp.

261  {
263 }
#define KEYERR_OUTOFBOUNDS
Definition: swkey.h:35
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
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 SWKey::getIndex ( ) const
inlinevirtualinherited

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

Reimplemented in VerseKey, ListKey, and TreeKey.

Definition at line 229 of file swkey.h.

229 { return index; }
long index
Definition: swkey.h:97
char* SWKey::getLocale ( ) const
inlineinherited

Definition at line 224 of file swkey.h.

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

Reimplemented in VerseKey, and ListKey.

Definition at line 203 of file swkey.cpp.

203  {
204  return getRangeText();
205 }
virtual const char * getRangeText() const
Definition: swkey.cpp:193
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 * SWKey::getRangeText ( ) const
virtualinherited

Reimplemented in VerseKey, and ListKey.

Definition at line 193 of file swkey.cpp.

193  {
195  return rangeText;
196 }
char * keytext
Definition: swkey.h:102
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
char * rangeText
Definition: swkey.h:103
virtual const char* SWKey::getShortRangeText ( ) const
inlinevirtualinherited

Reimplemented in VerseKey, and ListKey.

Definition at line 187 of file swkey.h.

187 { return getRangeText(); }
virtual const char * getRangeText() const
Definition: swkey.cpp:193
virtual const char* SWKey::getShortText ( ) const
inlinevirtualinherited

Reimplemented in VerseKey, and ListKey.

Definition at line 185 of file swkey.h.

185 { return getText(); }
virtual const char * getText() const
Definition: swkey.cpp:184
const char * SWKey::getText ( ) const
virtualinherited

returns string representation of this key

Reimplemented in VerseKey, ListKey, TreeKey, and TreeKeyIdx.

Definition at line 184 of file swkey.cpp.

184  {
185  return keytext;
186 }
char * keytext
Definition: swkey.h:102
void SWKey::increment ( int  steps = 1)
virtualinherited

Increments key a number of entry positions This is only valid if isTraversable is true

Parameters
stepsNumber of entries to jump forward

Reimplemented in VerseKey, ListKey, TreeKey, TreeKeyIdx, and VerseTreeKey.

Definition at line 248 of file swkey.cpp.

248  {
250 }
#define KEYERR_OUTOFBOUNDS
Definition: swkey.h:35
char error
Definition: swkey.h:106
void StrKey::init ( )
private

Definition at line 47 of file strkey.cpp.

47  {
48  myClass = &classdef;
49 }
const SWClass * myClass
Definition: swobject.h:55
static const SWClass classdef(classes)
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 SWKey::isTraversable ( ) const
inlinevirtualinherited

Whether or not this key can be ++ – incremented

Reimplemented in VerseKey, ListKey, TreeKey, TreeKeyIdx, and VerseTreeKey.

Definition at line 222 of file swkey.h.

222 { return false; }
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
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 SWKey::setIndex ( long  iindex)
inlinevirtualinherited

See documentation for Index()

Reimplemented in VerseKey, ListKey, and TreeKey.

Definition at line 233 of file swkey.h.

233 { index = iindex; }
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 SWKey::setPosition ( SW_POSITION  p)
virtualinherited

Reimplemented in VerseKey, ListKey, TreeKey, VerseTreeKey, and TreeKeyIdx.

Definition at line 228 of file swkey.cpp.

228  {
229  switch (p) {
230  case POS_TOP:
231 // *this = "";
232  break;
233  case POS_BOTTOM:
234 // *this = "zzzzzzzzz";
235  break;
236  }
237 }
#define POS_TOP
Definition: swkey.h:65
#define POS_BOTTOM
Definition: swkey.h:66
void SWKey::setText ( const char *  ikey)
virtualinherited

Sets this SWKey with a character string

Parameters
ikeystring used to set this key

Reimplemented in VerseKey, ListKey, TreeKey, and TreeKeyIdx.

Definition at line 162 of file swkey.cpp.

162  {
163  stdstr(&keytext, ikey);
164 }
char * keytext
Definition: swkey.h:102
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44

Member Data Documentation

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: