[sword-devel] NEED A HAND

Troy A. Griffitts sword-devel@crosswire.org
Thu, 20 Feb 2003 00:46:45 -0700

Hey guys.  I just added the new SWBuf class to the API and now need help 
integrating it throughout.


I was going to do it all myself, but realized that we have nearly 50 
filters now!

SO, if you have cvs write access, please post a note claiming a few 
filter that you are working on so we don't overlap our work.

Here is the gist...

SWBuf works pretty much like string, except that it can operate on 
buffers that aren't null terminated, as well.

Have a look at tests/swbuftest.cpp and include/swbuf.h

Up until yesterday there was a FILTER_PAD define that basically told us 
how much to guess at allocating a buffer to be sure we had enough space 
for filter to do their job.  The filters used to take a char *.

Now, FILTER_PAD is gone (hurray!) and we're passing SWBuf & in place of 
char * to the filters.

Headers have been changed to reflect the new sigs, but the .cpp files 
have not.

swbasicfilter.cpp and gbfhtml.cpp are done.

Quick help:

-char Filter::ProcessText(char *text, int maxlen, const SWKey *key,
-   const SWModule *module)
+char Filter::processText(SWBuf &text, const SWKey *key,
+   const SWModule *module)

- pushString(buf, "whatever");
+ buf += "whatever";

- *(*buf)++ = 'x';
+ buf += 'x';

- pushString(buf, "%d %s", 4, "cows");
+ buf.appendFormatted("%d %s", 4, "cows");

-        char *to, *from;
-        len = strlen(text) + 1; 

-        // shift string to right of buffer
-        if (len < maxlen) {
-                memmove(&text[maxlen - len], text, len);
-                from = (unsigned char *)&text[maxlen - len];
-        }
-        else    from = (unsigned char *)text;
-        for (to = (unsigned char *)text; *from; from++) {
+        const char *from;
+        SWBuf orig = text;
+        from = orig.c_str();
+        for (text = ""; *from; from++) {


Thanks for considering helping on this one!

	In His Grace,