23 #ifndef BAGEL_BOFLIB_STRING_H 24 #define BAGEL_BOFLIB_STRING_H 26 #include "common/system.h" 27 #include "bagel/boflib/object.h" 33 #define mUseStackMem 0x8000 34 #define NORMALIZEBUFFERSIZE() (_nBufferSize & ~mUseStackMem) 35 #define SETBUFFERSIZE(size, usestackmem) (_nBufferSize = (uint16)((size) + ((usestackmem) ? mUseStackMem : 0))) 36 #define USESSTACKMEM() (_nBufferSize & mUseStackMem) 85 int getBufferSize()
const {
86 return NORMALIZEBUFFERSIZE();
88 int getLength()
const {
91 bool isEmpty()
const {
100 void growTo(
int nNewSize);
102 char getAt(
int nIndex);
103 char operator[](
int nIndex);
105 operator const char *()
const {
106 return (
const char *)_pszData;
108 const char *getBuffer()
const {
121 void copy(
const char *pszSourceBuf);
130 const CBofString &operator+=(
const char *psz);
139 int compare(
const char *lpsz)
const;
140 int compareNoCase(
const char *lpsz)
const;
149 void deleteLastChar();
156 int find(
const char *lpszSub)
const;
157 int findNumOccurrences(
const char *pszSub);
160 void replaceCharAt(
int,
char);
161 void replaceChar(
char chOld,
char chNew);
162 void replaceStr(
const char *pszOld,
const char *pszNew);
186 void concatCopy(
int nSrc1Len,
const char *lpszSrc1Data,
int nSrc2Len,
const char *lpszSrc2Data,
int nAllocLen = 0);
187 void concatInPlace(
int nSrcLen,
const char *lpszSrcData);
188 static int safeStrlen(
const char *lpsz);
201 return s1.compare(s2) == 0;
204 inline bool operator==(
const CBofString &s1,
const char *s2) {
205 return s1.compare(s2) == 0;
208 inline bool operator==(
const char *s1,
const CBofString &s2) {
209 return s2.compare(s1) == 0;
213 return s1.compare(s2) != 0;
216 inline bool operator!=(
const CBofString &s1,
const char *s2) {
217 return s1.compare(s2) != 0;
220 inline bool operator!=(
const char *s1,
const CBofString &s2) {
221 return s2.compare(s1) != 0;
225 return s1.compare(s2) < 0;
228 inline bool operator<(
const CBofString &s1,
const char *s2) {
229 return s1.compare(s2) < 0;
232 inline bool operator<(
const char *s1,
const CBofString &s2) {
233 return s2.compare(s1) > 0;
237 return s1.compare(s2) > 0;
240 inline bool operator>(
const CBofString &s1,
const char *s2) {
241 return s1.compare(s2) > 0;
244 inline bool operator>(
const char *s1,
const CBofString &s2) {
245 return s2.compare(s1) < 0;
249 return s1.compare(s2) <= 0;
252 inline bool operator<=(
const CBofString &s1,
const char *s2) {
253 return s1.compare(s2) <= 0;
256 inline bool operator<=(
const char *s1,
const CBofString &s2) {
257 return s2.compare(s1) >= 0;
261 return s1.compare(s2) >= 0;
264 inline bool operator>=(
const CBofString &s1,
const char *s2) {
265 return s1.compare(s2) >= 0;
268 inline bool operator>=(
const char *s1,
const CBofString &s2) {
269 return s2.compare(s1) <= 0;
void allocBuffer(int nLen)
void copy(const char *pszSourceBuf)
void allocCopy(CBofString &dest, int nCopyLen, int nCopyIndex, int nExtraLen) const