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;
47 static const uint32
_builtinCapacity = 32 - (
sizeof(uint32) +
sizeof(
char *)) /
sizeof(value_type);
73 mutable int *_refCount;
78 inline bool isStorageIntern()
const {
102 BaseString(
const value_type *beginP,
const value_type *endP);
105 bool operator==(
const value_type *x)
const;
107 bool operator!=(
const value_type *x)
const;
110 bool operator<(
const value_type *x)
const;
112 bool operator<=(
const value_type *x)
const;
114 bool operator>(
const value_type *x)
const;
116 bool operator>=(
const value_type *x)
const;
123 bool equals(
const value_type *x)
const;
124 bool equalsC(
const char *x)
const;
126 int compareTo(
const value_type *x)
const;
127 int compareToC(
const char *x)
const;
130 void setChar(value_type c, uint32 p);
143 void erase(uint32 p, uint32 len = npos);
146 iterator
erase(iterator it);
149 void chop(uint32 len = 1);
165 return begin() + size();
168 const_iterator begin()
const {
172 const_iterator end()
const {
173 return begin() + size();
176 inline const value_type *c_str()
const {
return _str; }
177 inline uint size()
const {
return _size; }
179 inline bool empty()
const {
return (_size == 0); }
180 value_type firstChar()
const {
return (_size > 0) ? _str[0] : 0; }
181 value_type lastChar()
const {
return (_size > 0) ? _str[_size - 1] : 0; }
183 value_type operator[](
int idx)
const {
186 assert(idx < (
int)_size);
198 void insertString(
const value_type *s, uint32 p);
199 void insertString(
const BaseString &s, uint32 p);
202 uint32
find(value_type x, uint32 pos = 0)
const;
204 size_t find(
const value_type *s, uint32 pos = 0)
const;
208 size_t rfind(
const value_type *s)
const;
210 return rfind(s.c_str());
214 size_t rfind(value_type c,
size_t pos = npos)
const;
217 size_t findFirstOf(value_type c,
size_t pos = 0)
const;
220 size_t findFirstOf(
const value_type *chars,
size_t pos = 0)
const;
226 size_t findLastOf(value_type c,
size_t pos = npos)
const;
229 size_t findLastOf(
const value_type *chars,
size_t pos = npos)
const;
238 size_t findFirstNotOf(
const value_type *chars,
size_t pos = 0)
const;
269 void replace(uint32 pos, uint32 count,
const value_type *str);
273 void replace(iterator begin, iterator end,
const value_type *str);
277 uint32 posDest, uint32 countDest);
280 void replace(uint32 posOri, uint32 countOri,
const value_type *str,
281 uint32 posDest, uint32 countDest);
289 void replace(value_type from, value_type to);
292 void append(
const value_type *begin,
const value_type *end);
303 void wordWrap(
const uint32 maxLength);
339 ensureCapacity(_size,
true);
342 void ensureCapacity(uint32 new_size,
bool keep_old);
343 void incRefCount()
const;
344 void decRefCount(
int *oldRefCount);
345 void initWithValueTypeStr(
const value_type *str, uint32 len);
347 void assignInsert(
const value_type *str, uint32 p);
348 void assignInsert(value_type c, uint32 p);
349 void assignInsert(
const BaseString &str, uint32 p);
350 void assignAppend(
const value_type *str);
351 void assignAppend(value_type c);
355 void assign(value_type c);
356 void assign(
const value_type *str);
358 bool pointerInOwnBuffer(
const value_type *str)
const;
360 uint getUnsignedValue(uint pos)
const;
362 void toCase(
int (*caseChangeFunc)(
int));
364 static uint32 cStrLen(
const value_type *str);
365 static const value_type *cMemChr(
const value_type *ptr, value_type c,
size_t count);
366 static value_type *cMemChr(value_type *ptr, value_type c,
size_t count);
367 static int cMemCmp(
const value_type* ptr1,
const value_type* ptr2,
size_t count);
size_t findFirstNotOf(value_type c, size_t pos=0) const
bool equals(const BaseString &x) const
void insertChar(value_type c, uint32 p)
uint64 asUint64Ext() const
void deleteChar(uint32 p)
value_type _storage[_builtinCapacity]
Definition: str-base.h:67
constexpr BaseString(value_type c)
Definition: str-base.h:87
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
uint32 _size
Definition: str-base.h:54
constexpr BaseString()
Definition: str-base.h:84
static const uint32 _builtinCapacity
Definition: str-base.h:47
Definition: algorithm.h:29
void deleteLastChar()
Definition: str-base.h:140
void erase(uint32 p, uint32 len=npos)
size_t rfind(const value_type *s) const
void replace(uint32 pos, uint32 count, const BaseString &str)
void append(const value_type *begin, const value_type *end)
void setChar(value_type c, uint32 p)
value_type * _str
Definition: str-base.h:60
void wordWrap(const uint32 maxLength)
bool contains(const BaseString &otherString) const