/* BString.h Replacement of the MFC CString class May 12 2004 Created by Bill arden www.billarden.com Relesed into public domain (have fun) *////////////////////////////////////////////////////////////////////// #if !defined(AFX_BSTRING_H__A12064A3_A460_11D8_BBC7_00A0CCA1D9EC__INCLUDED_) #define AFX_BSTRING_H__A12064A3_A460_11D8_BBC7_00A0CCA1D9EC__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 struct BStringDataStruct{ long nCount; //how many classes have this? int nStrLen; //length with terminator int nAllocLen; //memory bytes allocated char* pstr; //pointer to the string }; class BString { //simplifyed string for Ansi portibility public: //Constructors BString(); BString(const BString& StrSrc); //copy BString(char CharStr); // BString(char* CharStr); // virtual ~BString(); //low level functions void Empty(void); //clear string int GetLength(); void SetLength(int len); char* GetBuffer(int len); void ReleaseBuffer(int nNewLength = -1); int Delete(int nIndex, int nCount = 1); char GetAt(int nIndex); char operator[](int nIndex); //higer level functions (uses above) BString Mid(int nFirst, int nCount = -1); BString Left(int nCount); BString Right(int nCount); void TrimLeft(char chTarget = 32); void TrimRight(char chTarget = 32); void MakeUpper(); //void MakeLower(); //to do //void MakeReverse(); //to do int Find(char ch, int nStart = 0); int Find(char* ch, int nStart = 0); int Remove(char chRemove); bool FormatV(const char * pFormat,va_list ArgList); bool Format(const char * pFormat,...); BString& operator=( BString& StrSrc); BString& operator=(char* charStr); BString& operator=(char Achar); BString& operator+=( BString& string); BString& operator+=(char Achar); BString& operator+=(char* charStr); //BString operator+( BString& string1, BString& string2); // BString operator+( BString& string, TCHAR ch); protected: //internal BStringDataStruct* m_StringData; void Create(void); void Destroy(void); void BreakTie(void); void GrowBuffer(int newSize); void CopyStr(int nStart,char* NewCharStr,int nCharLength = -1); }; //global operators bool operator==(BString& s1, BString& s2); bool operator==(BString& s1, char* s2); bool operator==(char* s1, BString& s2); bool operator!=(BString& s1, BString& s2); bool operator!=(BString& s1, char* s2); bool operator!=(char* s1, BString& s2); #endif // !defined(AFX_BSTRING_H__A12064A3_A460_11D8_BBC7_00A0CCA1D9EC__INCLUDED_)