[sword-cvs] sword/include swbuf.h,1.5,1.6
sword@www.crosswire.org
sword@www.crosswire.org
Thu, 27 Feb 2003 03:41:20 -0700
Update of /usr/local/cvsroot/sword/include
In directory www:/tmp/cvs-serv739/include
Modified Files:
swbuf.h
Log Message:
Index: swbuf.h
===================================================================
RCS file: /usr/local/cvsroot/sword/include/swbuf.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** swbuf.h 25 Feb 2003 05:01:14 -0000 1.5
--- swbuf.h 27 Feb 2003 10:41:18 -0000 1.6
***************
*** 24,27 ****
--- 24,28 ----
#include <defs.h>
+ #include <stdlib.h>
SWORD_NAMESPACE_START
***************
*** 38,42 ****
static char junkBuf[JUNKBUFSIZE];
! void assureSize(unsigned int size);
void init();
--- 39,50 ----
static char junkBuf[JUNKBUFSIZE];
! inline void assureSize(unsigned int size) {
! if (size > allocSize) {
! allocSize = size + 5;
! end = (char *)(end - buf);
! buf = (char *)realloc(buf, allocSize);
! end = (buf + (unsigned int)end);
! }
! }
void init();
***************
*** 46,59 ****
SWBuf(const SWBuf &other);
! void setFillByte(char ch) { fillByte = ch; }
! char getFillByte() { return fillByte; }
virtual ~SWBuf();
! const char *c_str() const { return buf; }
! char &charAt(unsigned int pos) { return ((pos <= (end - buf)) ? buf[pos] : nullStr[0]); }
! unsigned int size() const { return length(); }
! unsigned int length() const { return end - buf; }
void set(const char *newVal);
void set(const SWBuf &newVal);
--- 54,67 ----
SWBuf(const SWBuf &other);
! inline void setFillByte(char ch) { fillByte = ch; }
! inline char getFillByte() { return fillByte; }
virtual ~SWBuf();
! inline const char *c_str() const { return buf; }
! inline char &charAt(unsigned int pos) { return ((pos <= (end - buf)) ? buf[pos] : nullStr[0]); }
! inline unsigned int size() const { return length(); }
! inline unsigned int length() const { return end - buf; }
void set(const char *newVal);
void set(const SWBuf &newVal);
***************
*** 61,80 ****
void append(const char *str);
void append(const SWBuf &str);
! void append(char ch);
void appendFormatted(const char *format, ...);
! char *getRawData() { return buf; } // be careful! Probably setSize needs to be called in conjunction before and maybe after
! operator const char *() const { return c_str(); }
! char &operator[](unsigned int pos) { return charAt(pos); }
! char &operator[](int pos) { return charAt((unsigned int)pos); }
! SWBuf &operator =(const char *newVal) { set(newVal); return *this; }
! SWBuf &operator =(const SWBuf &other) { set(other); return *this; }
! SWBuf &operator +=(const char *str) { append(str); return *this; }
! SWBuf &operator +=(char ch) { append(ch); return *this; }
! SWBuf &operator -=(unsigned int len) { setSize(length()-len); return *this; }
! SWBuf &operator --(int) { operator -=(1); return *this; }
! SWBuf operator +(const SWBuf &other) const;
! SWBuf operator +(char ch) const { return (*this) + SWBuf(ch); }
};
--- 69,97 ----
void append(const char *str);
void append(const SWBuf &str);
! inline void append(char ch) {
! assureSize((end-buf)+1);
! *end = ch;
! end++;
! *end = 0;
! }
void appendFormatted(const char *format, ...);
! inline char *getRawData() { return buf; } // be careful! Probably setSize needs to be called in conjunction before and maybe after
! inline operator const char *() const { return c_str(); }
! inline char &operator[](unsigned int pos) { return charAt(pos); }
! inline char &operator[](int pos) { return charAt((unsigned int)pos); }
! inline SWBuf &operator =(const char *newVal) { set(newVal); return *this; }
! inline SWBuf &operator =(const SWBuf &other) { set(other); return *this; }
! inline SWBuf &operator +=(const char *str) { append(str); return *this; }
! inline SWBuf &operator +=(char ch) { append(ch); return *this; }
! inline SWBuf &operator -=(unsigned int len) { setSize(length()-len); return *this; }
! inline SWBuf &operator --(int) { operator -=(1); return *this; }
! inline SWBuf operator +(const SWBuf &other) const {
! SWBuf retVal = buf;
! retVal += other;
! return retVal;
! }
! inline SWBuf operator +(char ch) const { return (*this) + SWBuf(ch); }
};