#ifndef __BGSTRING_H__ #define __BGSTRING_H__ /* $Id: bgstring.h,v 1.1 2000/02/18 09:04:17 dpfeifle Exp $ */ #include "bgobject.h" #include "bglog.h" #define REALLOCSIZE 32 class BGString : public BGOctet { public: BGString ( ); BGString ( long ); BGString ( const BGString &s ); BGString ( const char *s ); virtual ~BGString ( ); //virtual long // cid ( ) const { return BGCID_BGSTRING; } //virtual BGString // toString ( ) { return BGString(*this); } virtual BGString toString ( ) { return *this; } virtual unsigned long hash ( ); virtual int compare ( BGObject &obj ); virtual BGString className ( ) { return BGString ("BGString");} void set ( const char *s ); virtual char* buffer ( ) const { return buf; } virtual long length ( ) const { return len; } void clear ( ); inline void ensure ( long neededSize ); long indexOf ( char ch, long fromIndex=0 ); long indexOf ( char *s, long fromIndex=0 ); long indexOf ( BGString &s, long fromIndex=0 ); BGString substring ( long beginIndex, long endIndex ); BGString& replace ( char oldch, char newch, long beginIndex=0, long endIndex=0 ); BGString& add ( const char *s ); BGString& add ( char charToAppend ); BGString& add ( const BGString& s ); BGString& trim ( ); BGString& ltrim ( ); BGString& rtrim ( ); char& operator [] (int i); friend BGString operator + (const BGString&, const BGString&); friend BGString operator + (const BGString&, char); void operator = (const BGString&); void operator = (const char*); void operator = (char); // TODO: FIX THAT !!! const static char CR = '\r'; const static char LF = '\n'; const static char CRLF[3] = "\r\n"; protected: //static const long REALLOCSIZE = 32; void realloc ( long plusSize = REALLOCSIZE ); private: char* buf; long len; size_t allocsize; char hashbuf[17]; }; #endif