diff options
Diffstat (limited to 'src/modules/lexdict/zld/zld.cpp')
-rw-r--r-- | src/modules/lexdict/zld/zld.cpp | 87 |
1 files changed, 26 insertions, 61 deletions
diff --git a/src/modules/lexdict/zld/zld.cpp b/src/modules/lexdict/zld/zld.cpp index 371b8a2..dd3fe8e 100644 --- a/src/modules/lexdict/zld/zld.cpp +++ b/src/modules/lexdict/zld/zld.cpp @@ -14,11 +14,11 @@ #include <unistd.h> #endif -#include <string.h> #include <utilfuns.h> #include <zstr.h> #include <zld.h> +SWORD_NAMESPACE_START /****************************************************************************** * RawLD Constructor - Initializes data for instance of RawLD @@ -29,8 +29,8 @@ * idisp - Display object to use for displaying */ -zLD::zLD(const char *ipath, const char *iname, const char *idesc, long blockCount, SWCompress *icomp, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang) : zStr(ipath, -1, blockCount, icomp), SWLD(iname, idesc, idisp, enc, dir, mark, ilang) -{ +zLD::zLD(const char *ipath, const char *iname, const char *idesc, long blockCount, SWCompress *icomp, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang) : zStr(ipath, -1, blockCount, icomp), SWLD(iname, idesc, idisp, enc, dir, mark, ilang) { + } @@ -38,8 +38,8 @@ zLD::zLD(const char *ipath, const char *iname, const char *idesc, long blockCoun * RawLD Destructor - Cleans up instance of RawLD */ -zLD::~zLD() -{ +zLD::~zLD() { + } @@ -49,8 +49,7 @@ zLD::~zLD() * ENT: buf - buffer to check and pad */ -void zLD::strongsPad(char *buf) -{ +void zLD::strongsPad(char *buf) { const char *check; long size = 0; int len = strlen(buf); @@ -76,8 +75,7 @@ void zLD::strongsPad(char *buf) * RET: error status */ -char zLD::getEntry(long away) -{ +char zLD::getEntry(long away) { char *idxbuf = 0; char *ebuf = 0; char retval = 0; @@ -88,12 +86,13 @@ char zLD::getEntry(long away) strongsPad(buf); - *entrybuf = 0; + entryBuf = ""; if (!(retval = findKeyIndex(buf, &index, away))) { getText(index, &idxbuf, &ebuf); size = strlen(ebuf) + 1; - entrybuf = new char [ size * FILTERPAD ]; - strcpy(entrybuf, ebuf); + entryBuf = ebuf; + + rawFilter(entryBuf, key); entrySize = size; // support getEntrySize call if (!key->Persist()) // If we have our own key @@ -103,11 +102,6 @@ char zLD::getEntry(long away) free(idxbuf); free(ebuf); } - else { - entrybuf = new char [ 5 ]; - entrybuf[0] = 0; - entrybuf[1] = 0; - } delete [] buf; return retval; @@ -115,82 +109,51 @@ char zLD::getEntry(long away) /****************************************************************************** - * zLD::operator char * - Returns the correct entry when char * cast + * zLD::getRawEntry - Returns the correct entry when char * cast * is requested * * RET: string buffer with entry */ -char *zLD::getRawEntry() { - if (!getEntry() && !isUnicode()) { - prepText(entrybuf); +SWBuf &zLD::getRawEntryBuf() { + if (!getEntry() /*&& !isUnicode()*/) { + prepText(entryBuf); } - return entrybuf; + return entryBuf; } /****************************************************************************** - * zLD::operator += - Increments module key a number of entries + * zLD::increment - Increments module key a number of entries * * ENT: increment - Number of entries to jump forward * * RET: *this */ -SWModule &zLD::operator +=(int increment) -{ +void zLD::increment(int steps) { char tmperror; if (key->Traversable()) { - *key += increment; + *key += steps; error = key->Error(); - increment = 0; + steps = 0; } - tmperror = (getEntry(increment)) ? KEYERR_OUTOFBOUNDS : 0; + tmperror = (getEntry(steps)) ? KEYERR_OUTOFBOUNDS : 0; error = (error)?error:tmperror; *key = entkeytxt; - return *this; -} - - -/****************************************************************************** - * zLD::operator =(SW_POSITION) - Positions this key if applicable - */ - -SWModule &zLD::operator =(SW_POSITION p) -{ - if (!key->Traversable()) { - switch (p) { - case POS_TOP: - *key = ""; - break; - case POS_BOTTOM: - *key = "zzzzzzzzz"; - break; - } - } - else *key = p; - return *this; } -SWModule &zLD::setentry(const char *inbuf, long len) { +void zLD::setEntry(const char *inbuf, long len) { setText(*key, inbuf, len); - - return *this; -} - -SWModule &zLD::operator <<(const char *inbuf) { - return setentry(inbuf, 0); } -SWModule &zLD::operator <<(const SWKey *inkey) { - linkEntry(*key, *inkey); - - return *this; +void zLD::linkEntry(const SWKey *inkey) { + zStr::linkEntry(*key, *inkey); } @@ -203,3 +166,5 @@ SWModule &zLD::operator <<(const SWKey *inkey) { void zLD::deleteEntry() { setText(*key, ""); } + +SWORD_NAMESPACE_END |