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;
204inline bool operator==(
const CBofString &s1,
const char *s2) {
205 return s1.compare(s2) == 0;
208inline bool operator==(
const char *s1,
const CBofString &s2) {
209 return s2.compare(s1) == 0;
212inline bool operator!=(
const CBofString &s1,
const CBofString &s2) {
213 return s1.compare(s2) != 0;
216inline bool operator!=(
const CBofString &s1,
const char *s2) {
217 return s1.compare(s2) != 0;
220inline bool operator!=(
const char *s1,
const CBofString &s2) {
221 return s2.compare(s1) != 0;
224inline bool operator<(
const CBofString &s1,
const CBofString &s2) {
225 return s1.compare(s2) < 0;
228inline bool operator<(
const CBofString &s1,
const char *s2) {
229 return s1.compare(s2) < 0;
232inline bool operator<(
const char *s1,
const CBofString &s2) {
233 return s2.compare(s1) > 0;
236inline bool operator>(
const CBofString &s1,
const CBofString &s2) {
237 return s1.compare(s2) > 0;
240inline bool operator>(
const CBofString &s1,
const char *s2) {
241 return s1.compare(s2) > 0;
244inline bool operator>(
const char *s1,
const CBofString &s2) {
245 return s2.compare(s1) < 0;
248inline bool operator<=(
const CBofString &s1,
const CBofString &s2) {
249 return s1.compare(s2) <= 0;
252inline bool operator<=(
const CBofString &s1,
const char *s2) {
253 return s1.compare(s2) <= 0;
256inline bool operator<=(
const char *s1,
const CBofString &s2) {
257 return s2.compare(s1) >= 0;
260inline bool operator>=(
const CBofString &s1,
const CBofString &s2) {
261 return s1.compare(s2) >= 0;
264inline bool operator>=(
const CBofString &s1,
const char *s2) {
265 return s1.compare(s2) >= 0;
268inline bool operator>=(
const char *s1,
const CBofString &s2) {
269 return s2.compare(s1) <= 0;
void copy(const char *pszSourceBuf)
void allocBuffer(int nLen)
CBofString(char *pszBuff, int pszBuffLen)
This modifies the passed source string to null terminate the substring.
CBofString(const char *pszBuf)
CBofString(char ch, int nRepeat=1)
CBofString(const CBofString &stringSrc)
void allocCopy(CBofString &dest, int nCopyLen, int nCopyIndex, int nExtraLen) const