22 #ifndef COMMON_STR_BASE_H 23 #define COMMON_STR_BASE_H 25 #include "common/scummsys.h" 26 #include "common/str-enc.h" 34 static void releaseMemoryPoolMutex();
36 static const uint32 npos = 0xFFFFFFFF;
39 typedef const T * const_iterator;
40 typedef size_t size_type;
48 static const uint32
_builtinCapacity = 32 - (
sizeof(uint32) +
sizeof(
char *)) /
sizeof(value_type);
74 mutable int *_refCount;
79 inline bool isStorageIntern()
const {
103 BaseString(
const value_type *str, uint32 len);
106 BaseString(
const value_type *beginP,
const value_type *endP);
109 bool operator==(
const value_type *x)
const;
111 bool operator!=(
const value_type *x)
const;
114 bool operator<(
const value_type *x)
const;
116 bool operator<=(
const value_type *x)
const;
118 bool operator>(
const value_type *x)
const;
120 bool operator>=(
const value_type *x)
const;
127 bool equals(
const value_type *x)
const;
128 bool equalsC(
const char *x)
const;
130 int compareTo(
const value_type *x)
const;
131 int compareToC(
const char *x)
const;
134 void setChar(value_type c, uint32 p);
147 void erase(uint32 p, uint32 len = npos);
150 iterator
erase(iterator it);
153 void chop(uint32 len = 1);
169 return begin() + size();
172 const_iterator begin()
const {
176 const_iterator end()
const {
177 return begin() + size();
180 inline const value_type *c_str()
const {
return _str; }
181 inline uint size()
const {
return _size; }
183 inline bool empty()
const {
return (_size == 0); }
184 value_type firstChar()
const {
return (_size > 0) ? _str[0] : 0; }
185 value_type lastChar()
const {
return (_size > 0) ? _str[_size - 1] : 0; }
218 void insertString(
const value_type *s, uint32 p);
219 void insertString(
const BaseString &s, uint32 p);
222 uint32
find(value_type x, uint32 pos = 0)
const;
224 size_t find(
const value_type *s, uint32 pos = 0)
const;
228 size_t rfind(
const value_type *s)
const;
230 return rfind(s.c_str());
234 size_t rfind(value_type c,
size_t pos = npos)
const;
237 size_t findFirstOf(value_type c,
size_t pos = 0)
const;
240 size_t findFirstOf(
const value_type *chars,
size_t pos = 0)
const;
246 size_t findLastOf(value_type c,
size_t pos = npos)
const;
249 size_t findLastOf(
const value_type *chars,
size_t pos = npos)
const;
258 size_t findFirstNotOf(
const value_type *chars,
size_t pos = 0)
const;
289 void replace(uint32 pos, uint32 count,
const value_type *str);
293 void replace(iterator begin, iterator end,
const value_type *str);
297 uint32 posDest, uint32 countDest);
300 void replace(uint32 posOri, uint32 countOri,
const value_type *str,
301 uint32 posDest, uint32 countDest);
309 void replace(value_type from, value_type to);
316 void assign(
size_t count, value_type c);
317 void assign(
const value_type *str);
318 void assign(
const value_type *str,
size_t count);
323 void append(
const value_type *str);
324 void append(
size_t count, value_type c);
328 void append(
const value_type *begin,
const value_type *end);
346 void wordWrap(
const uint32 maxLength);
382 ensureCapacity(_size,
true);
385 void ensureCapacity(uint32 new_size,
bool keep_old);
386 void incRefCount()
const;
387 void decRefCount(
int *oldRefCount);
388 void initWithValueTypeChar(
size_t count, value_type c);
389 void initWithValueTypeStr(
const value_type *str, uint32 len);
391 void assignInsert(
const value_type *str, uint32 p);
392 void assignInsert(value_type c, uint32 p);
393 void assignInsert(
const BaseString &str, uint32 p);
395 bool pointerInOwnBuffer(
const value_type *str)
const;
397 uint getUnsignedValue(uint pos)
const;
399 void toCase(
int (*caseChangeFunc)(
int));
401 static size_t cStrLen(
const value_type *str);
402 static const value_type *cMemChr(
const value_type *ptr, value_type c,
size_t count);
403 static value_type *cMemChr(value_type *ptr, value_type c,
size_t count);
404 static int cMemCmp(
const value_type* ptr1,
const value_type* ptr2,
size_t count);
405 static void cMemSet(value_type *ptr, value_type c,
size_t count);
value_type operator[](size_t idx) const
Definition: str-base.h:199
value_type & operator[](size_t idx)
Definition: str-base.h:190
size_t findFirstNotOf(value_type c, size_t pos=0) const
bool equals(const BaseString &x) const
value_type at(size_t idx) const
Definition: str-base.h:208
void insertChar(value_type c, uint32 p)
uint64 asUint64Ext() const
void deleteChar(uint32 p)
value_type _storage[_builtinCapacity]
Definition: str-base.h:68
constexpr BaseString(value_type c)
Definition: str-base.h:88
size_t findLastOf(value_type c, size_t pos=npos) const
size_t findLastNotOf(value_type c) const
uint32 find(value_type x, uint32 pos=0) const
size_t findFirstOf(value_type c, size_t pos=0) const
Definition: str-base.h:32
struct Common::BaseString::@23::@25 _extern
void push_back(value_type c)
Definition: str-base.h:333
uint32 _size
Definition: str-base.h:55
constexpr BaseString()
Definition: str-base.h:85
static const uint32 _builtinCapacity
Definition: str-base.h:48
Definition: algorithm.h:29
void deleteLastChar()
Definition: str-base.h:144
void erase(uint32 p, uint32 len=npos)
size_t rfind(const value_type *s) const
void append(const value_type *str)
void assign(const BaseString &str)
void replace(uint32 pos, uint32 count, const BaseString &str)
void setChar(value_type c, uint32 p)
value_type * _str
Definition: str-base.h:61
void wordWrap(const uint32 maxLength)
bool contains(const BaseString &otherString) const