Bike-X  0.8
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
OVR_String.cpp
Go to the documentation of this file.
1 /************************************************************************************
2 
3 Filename : OVR_String.cpp
4 Content : String UTF8 string implementation with copy-on-write semantics
5  (thread-safe for assignment but not modification).
6 Created : September 19, 2012
7 Notes :
8 
9 Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
10 
11 Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
12 you may not use the Oculus VR Rift SDK except in compliance with the License,
13 which is provided at the time of installation or download, or which
14 otherwise accompanies this software in either electronic or hard copy form.
15 
16 You may obtain a copy of the License at
17 
18 http://www.oculusvr.com/licenses/LICENSE-3.1
19 
20 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
21 distributed under the License is distributed on an "AS IS" BASIS,
22 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 See the License for the specific language governing permissions and
24 limitations under the License.
25 
26 ************************************************************************************/
27 
28 #include "OVR_String.h"
29 
30 #include <stdlib.h>
31 #include <ctype.h>
32 
33 #ifdef OVR_OS_QNX
34 # include <strings.h>
35 #endif
36 
37 namespace OVR {
38 
39 #define String_LengthIsSize (UPInt(1) << String::Flag_LengthIsSizeShift)
40 
41 String::DataDesc String::NullData = {String_LengthIsSize, 1, {0} };
42 
43 
45 {
46  pData = &NullData;
47  pData->AddRef();
48 };
49 
50 String::String(const char* pdata)
51 {
52  // Obtain length in bytes; it doesn't matter if _data is UTF8.
53  UPInt size = pdata ? OVR_strlen(pdata) : 0;
54  pData = AllocDataCopy1(size, 0, pdata, size);
55 };
56 
57 String::String(const char* pdata1, const char* pdata2, const char* pdata3)
58 {
59  // Obtain length in bytes; it doesn't matter if _data is UTF8.
60  UPInt size1 = pdata1 ? OVR_strlen(pdata1) : 0;
61  UPInt size2 = pdata2 ? OVR_strlen(pdata2) : 0;
62  UPInt size3 = pdata3 ? OVR_strlen(pdata3) : 0;
63 
64  DataDesc *pdataDesc = AllocDataCopy2(size1 + size2 + size3, 0,
65  pdata1, size1, pdata2, size2);
66  memcpy(pdataDesc->Data + size1 + size2, pdata3, size3);
67  pData = pdataDesc;
68 }
69 
70 String::String(const char* pdata, UPInt size)
71 {
72  OVR_ASSERT((size == 0) || (pdata != 0));
73  pData = AllocDataCopy1(size, 0, pdata, size);
74 };
75 
76 
77 String::String(const InitStruct& src, UPInt size)
78 {
79  pData = AllocData(size, 0);
80  src.InitString(GetData()->Data, size);
81 }
82 
84 {
85  pData = src.GetData();
86  pData->AddRef();
87 }
88 
90 {
91  pData = AllocDataCopy1(src.GetSize(), 0, src.ToCStr(), src.GetSize());
92 }
93 
94 String::String(const wchar_t* data)
95 {
96  pData = &NullData;
97  pData->AddRef();
98  // Simplified logic for wchar_t constructor.
99  if (data)
100  *this = data;
101 }
102 
103 
105 {
106  String::DataDesc* pdesc;
107 
108  if (size == 0)
109  {
110  pdesc = &NullData;
111  pdesc->AddRef();
112  return pdesc;
113  }
114 
115  pdesc = (DataDesc*)OVR_ALLOC(sizeof(DataDesc)+ size);
116  pdesc->Data[size] = 0;
117  pdesc->RefCount = 1;
118  pdesc->Size = size | lengthIsSize;
119  return pdesc;
120 }
121 
122 
124  const char* pdata, UPInt copySize)
125 {
126  String::DataDesc* pdesc = AllocData(size, lengthIsSize);
127  memcpy(pdesc->Data, pdata, copySize);
128  return pdesc;
129 }
130 
132  const char* pdata1, UPInt copySize1,
133  const char* pdata2, UPInt copySize2)
134 {
135  String::DataDesc* pdesc = AllocData(size, lengthIsSize);
136  memcpy(pdesc->Data, pdata1, copySize1);
137  memcpy(pdesc->Data + copySize1, pdata2, copySize2);
138  return pdesc;
139 }
140 
141 
143 {
144  // Optimize length accesses for non-UTF8 character strings.
145  DataDesc* pdata = GetData();
146  UPInt length, size = pdata->GetSize();
147 
148  if (pdata->LengthIsSize())
149  return size;
150 
151  length = (UPInt)UTF8Util::GetLength(pdata->Data, (UPInt)size);
152 
153  if (length == size)
154  pdata->Size |= String_LengthIsSize;
155 
156  return length;
157 }
158 
159 
160 //static UInt32 String_CharSearch(const char* buf, )
161 
162 
164 {
165  SPInt i = (SPInt) index;
166  DataDesc* pdata = GetData();
167  const char* buf = pdata->Data;
168  UInt32 c;
169 
170  if (pdata->LengthIsSize())
171  {
172  OVR_ASSERT(index < pdata->GetSize());
173  buf += i;
175  }
176 
177  c = UTF8Util::GetCharAt(index, buf, pdata->GetSize());
178  return c;
179 }
180 
181 UInt32 String::GetFirstCharAt(UPInt index, const char** offset) const
182 {
183  DataDesc* pdata = GetData();
184  SPInt i = (SPInt) index;
185  const char* buf = pdata->Data;
186  const char* end = buf + pdata->GetSize();
187  UInt32 c;
188 
189  do
190  {
192  i--;
193 
194  if (buf >= end)
195  {
196  // We've hit the end of the string; don't go further.
197  OVR_ASSERT(i == 0);
198  return c;
199  }
200  } while (i >= 0);
201 
202  *offset = buf;
203 
204  return c;
205 }
206 
207 UInt32 String::GetNextChar(const char** offset) const
208 {
209  return UTF8Util::DecodeNextChar(offset);
210 }
211 
212 
213 
215 {
216  DataDesc* pdata = GetData();
217  UPInt size = pdata->GetSize();
218  char buff[8];
219  SPInt encodeSize = 0;
220 
221  // Converts ch into UTF8 string and fills it into buff.
222  UTF8Util::EncodeChar(buff, &encodeSize, ch);
223  OVR_ASSERT(encodeSize >= 0);
224 
225  SetData(AllocDataCopy2(size + (UPInt)encodeSize, 0,
226  pdata->Data, size, buff, (UPInt)encodeSize));
227  pdata->Release();
228 }
229 
230 
231 void String::AppendString(const wchar_t* pstr, SPInt len)
232 {
233  if (!pstr)
234  return;
235 
236  DataDesc* pdata = GetData();
237  UPInt oldSize = pdata->GetSize();
238  UPInt encodeSize = (UPInt)UTF8Util::GetEncodeStringSize(pstr, len);
239 
240  DataDesc* pnewData = AllocDataCopy1(oldSize + (UPInt)encodeSize, 0,
241  pdata->Data, oldSize);
242  UTF8Util::EncodeString(pnewData->Data + oldSize, pstr, len);
243 
244  SetData(pnewData);
245  pdata->Release();
246 }
247 
248 
249 void String::AppendString(const char* putf8str, SPInt utf8StrSz)
250 {
251  if (!putf8str || !utf8StrSz)
252  return;
253  if (utf8StrSz == -1)
254  utf8StrSz = (SPInt)OVR_strlen(putf8str);
255 
256  DataDesc* pdata = GetData();
257  UPInt oldSize = pdata->GetSize();
258 
259  SetData(AllocDataCopy2(oldSize + (UPInt)utf8StrSz, 0,
260  pdata->Data, oldSize, putf8str, (UPInt)utf8StrSz));
261  pdata->Release();
262 }
263 
264 void String::AssignString(const InitStruct& src, UPInt size)
265 {
266  DataDesc* poldData = GetData();
267  DataDesc* pnewData = AllocData(size, 0);
268  src.InitString(pnewData->Data, size);
269  SetData(pnewData);
270  poldData->Release();
271 }
272 
273 void String::AssignString(const char* putf8str, UPInt size)
274 {
275  DataDesc* poldData = GetData();
276  SetData(AllocDataCopy1(size, 0, putf8str, size));
277  poldData->Release();
278 }
279 
280 void String::operator = (const char* pstr)
281 {
282  AssignString(pstr, pstr ? OVR_strlen(pstr) : 0);
283 }
284 
285 void String::operator = (const wchar_t* pwstr)
286 {
287  DataDesc* poldData = GetData();
288  UPInt size = pwstr ? (UPInt)UTF8Util::GetEncodeStringSize(pwstr) : 0;
289 
290  DataDesc* pnewData = AllocData(size, 0);
291  UTF8Util::EncodeString(pnewData->Data, pwstr);
292  SetData(pnewData);
293  poldData->Release();
294 }
295 
296 
297 void String::operator = (const String& src)
298 {
299  DataDesc* psdata = src.GetData();
300  DataDesc* pdata = GetData();
301 
302  SetData(psdata);
303  psdata->AddRef();
304  pdata->Release();
305 }
306 
307 
309 {
310  DataDesc* polddata = GetData();
311  SetData(AllocDataCopy1(src.GetSize(), 0, src.ToCStr(), src.GetSize()));
312  polddata->Release();
313 }
314 
315 void String::operator += (const String& src)
316 {
317  DataDesc *pourData = GetData(),
318  *psrcData = src.GetData();
319  UPInt ourSize = pourData->GetSize(),
320  srcSize = psrcData->GetSize();
321  UPInt lflag = pourData->GetLengthFlag() & psrcData->GetLengthFlag();
322 
323  SetData(AllocDataCopy2(ourSize + srcSize, lflag,
324  pourData->Data, ourSize, psrcData->Data, srcSize));
325  pourData->Release();
326 }
327 
328 
329 String String::operator + (const char* str) const
330 {
331  String tmp1(*this);
332  tmp1 += (str ? str : "");
333  return tmp1;
334 }
335 
337 {
338  String tmp1(*this);
339  tmp1 += src;
340  return tmp1;
341 }
342 
343 void String::Remove(UPInt posAt, SPInt removeLength)
344 {
345  DataDesc* pdata = GetData();
346  UPInt oldSize = pdata->GetSize();
347  // Length indicates the number of characters to remove.
348  UPInt length = GetLength();
349 
350  // If index is past the string, nothing to remove.
351  if (posAt >= length)
352  return;
353  // Otherwise, cap removeLength to the length of the string.
354  if ((posAt + removeLength) > length)
355  removeLength = length - posAt;
356 
357  // Get the byte position of the UTF8 char at position posAt.
358  SPInt bytePos = UTF8Util::GetByteIndex(posAt, pdata->Data, oldSize);
359  SPInt removeSize = UTF8Util::GetByteIndex(removeLength, pdata->Data + bytePos, oldSize-bytePos);
360 
361  SetData(AllocDataCopy2(oldSize - removeSize, pdata->GetLengthFlag(),
362  pdata->Data, bytePos,
363  pData->Data + bytePos + removeSize, (oldSize - bytePos - removeSize)));
364  pdata->Release();
365 }
366 
367 
369 {
370  UPInt length = GetLength();
371  if ((start >= length) || (start >= end))
372  return String();
373 
374  DataDesc* pdata = GetData();
375 
376  // If size matches, we know the exact index range.
377  if (pdata->LengthIsSize())
378  return String(pdata->Data + start, end - start);
379 
380  // Get position of starting character.
381  SPInt byteStart = UTF8Util::GetByteIndex(start, pdata->Data, pdata->GetSize());
382  SPInt byteSize = UTF8Util::GetByteIndex(end - start, pdata->Data + byteStart, pdata->GetSize()-byteStart);
383  return String(pdata->Data + byteStart, (UPInt)byteSize);
384 }
385 
387 {
388  NullData.AddRef();
389  GetData()->Release();
390  SetData(&NullData);
391 }
392 
393 
395 {
396  UInt32 c;
397  const char* psource = GetData()->Data;
398  const char* pend = psource + GetData()->GetSize();
399  String str;
400  SPInt bufferOffset = 0;
401  char buffer[512];
402 
403  while(psource < pend)
404  {
405  do {
406  c = UTF8Util::DecodeNextChar_Advance0(&psource);
407  UTF8Util::EncodeChar(buffer, &bufferOffset, OVR_towupper(wchar_t(c)));
408  } while ((psource < pend) && (bufferOffset < SPInt(sizeof(buffer)-8)));
409 
410  // Append string a piece at a time.
411  str.AppendString(buffer, bufferOffset);
412  bufferOffset = 0;
413  }
414 
415  return str;
416 }
417 
419 {
420  UInt32 c;
421  const char* psource = GetData()->Data;
422  const char* pend = psource + GetData()->GetSize();
423  String str;
424  SPInt bufferOffset = 0;
425  char buffer[512];
426 
427  while(psource < pend)
428  {
429  do {
430  c = UTF8Util::DecodeNextChar_Advance0(&psource);
431  UTF8Util::EncodeChar(buffer, &bufferOffset, OVR_towlower(wchar_t(c)));
432  } while ((psource < pend) && (bufferOffset < SPInt(sizeof(buffer)-8)));
433 
434  // Append string a piece at a time.
435  str.AppendString(buffer, bufferOffset);
436  bufferOffset = 0;
437  }
438 
439  return str;
440 }
441 
442 
443 
444 String& String::Insert(const char* substr, UPInt posAt, SPInt strSize)
445 {
446  DataDesc* poldData = GetData();
447  UPInt oldSize = poldData->GetSize();
448  UPInt insertSize = (strSize < 0) ? OVR_strlen(substr) : (UPInt)strSize;
449  UPInt byteIndex = (poldData->LengthIsSize()) ?
450  posAt : (UPInt)UTF8Util::GetByteIndex(posAt, poldData->Data, oldSize);
451 
452  OVR_ASSERT(byteIndex <= oldSize);
453 
454  DataDesc* pnewData = AllocDataCopy2(oldSize + insertSize, 0,
455  poldData->Data, byteIndex, substr, insertSize);
456  memcpy(pnewData->Data + byteIndex + insertSize,
457  poldData->Data + byteIndex, oldSize - byteIndex);
458  SetData(pnewData);
459  poldData->Release();
460  return *this;
461 }
462 
463 /*
464 String& String::Insert(const UInt32* substr, UPInt posAt, SPInt len)
465 {
466  for (SPInt i = 0; i < len; ++i)
467  {
468  UPInt charw = InsertCharAt(substr[i], posAt);
469  posAt += charw;
470  }
471  return *this;
472 }
473 */
474 
476 {
477  char buf[8];
478  SPInt index = 0;
479  UTF8Util::EncodeChar(buf, &index, c);
480  OVR_ASSERT(index >= 0);
481  buf[(UPInt)index] = 0;
482 
483  Insert(buf, posAt, index);
484  return (UPInt)index;
485 }
486 
487 
488 int String::CompareNoCase(const char* a, const char* b)
489 {
490  return OVR_stricmp(a, b);
491 }
492 
493 int String::CompareNoCase(const char* a, const char* b, SPInt len)
494 {
495  if (len)
496  {
497  SPInt f,l;
498  SPInt slen = len;
499  const char *s = b;
500  do {
501  f = (SPInt)OVR_tolower((int)(*(a++)));
502  l = (SPInt)OVR_tolower((int)(*(b++)));
503  } while (--len && f && (f == l) && *b != 0);
504 
505  if (f == l && (len != 0 || *b != 0))
506  {
507  f = (SPInt)slen;
508  l = (SPInt)OVR_strlen(s);
509  return int(f - l);
510  }
511 
512  return int(f - l);
513  }
514  else
515  return (0-(int)OVR_strlen(b));
516 }
517 
518 // ***** Implement hash static functions
519 
520 // Hash function
521 UPInt String::BernsteinHashFunction(const void* pdataIn, UPInt size, UPInt seed)
522 {
523  const UByte* pdata = (const UByte*) pdataIn;
524  UPInt h = seed;
525  while (size > 0)
526  {
527  size--;
528  h = ((h << 5) + h) ^ (unsigned) pdata[size];
529  }
530 
531  return h;
532 }
533 
534 // Hash function, case-insensitive
535 UPInt String::BernsteinHashFunctionCIS(const void* pdataIn, UPInt size, UPInt seed)
536 {
537  const UByte* pdata = (const UByte*) pdataIn;
538  UPInt h = seed;
539  while (size > 0)
540  {
541  size--;
542  h = ((h << 5) + h) ^ OVR_tolower(pdata[size]);
543  }
544 
545  // Alternative: "sdbm" hash function, suggested at same web page above.
546  // h = 0;
547  // for bytes { h = (h << 16) + (h << 6) - hash + *p; }
548  return h;
549 }
550 
551 
552 
553 // ***** String Buffer used for Building Strings
554 
555 
556 #define OVR_SBUFF_DEFAULT_GROW_SIZE 512
557 // Constructors / Destructor.
559  : pData(NULL), Size(0), BufferSize(0), GrowSize(OVR_SBUFF_DEFAULT_GROW_SIZE), LengthIsSize(false)
560 {
561 }
562 
564  : pData(NULL), Size(0), BufferSize(0), GrowSize(OVR_SBUFF_DEFAULT_GROW_SIZE), LengthIsSize(false)
565 {
566  SetGrowSize(growSize);
567 }
568 
569 StringBuffer::StringBuffer(const char* data)
570  : pData(NULL), Size(0), BufferSize(0), GrowSize(OVR_SBUFF_DEFAULT_GROW_SIZE), LengthIsSize(false)
571 {
572  AppendString(data);
573 }
574 
575 StringBuffer::StringBuffer(const char* data, UPInt dataSize)
576  : pData(NULL), Size(0), BufferSize(0), GrowSize(OVR_SBUFF_DEFAULT_GROW_SIZE), LengthIsSize(false)
577 {
578  AppendString(data, dataSize);
579 }
580 
582  : pData(NULL), Size(0), BufferSize(0), GrowSize(OVR_SBUFF_DEFAULT_GROW_SIZE), LengthIsSize(false)
583 {
584  AppendString(src.ToCStr(), src.GetSize());
585 }
586 
588  : pData(NULL), Size(0), BufferSize(0), GrowSize(OVR_SBUFF_DEFAULT_GROW_SIZE), LengthIsSize(false)
589 {
590  AppendString(src.ToCStr(), src.GetSize());
591 }
592 
593 StringBuffer::StringBuffer(const wchar_t* data)
594  : pData(NULL), Size(0), BufferSize(0), GrowSize(OVR_SBUFF_DEFAULT_GROW_SIZE), LengthIsSize(false)
595 {
596  *this = data;
597 }
598 
600 {
601  if (pData)
602  OVR_FREE(pData);
603 }
605 {
606  if (growSize <= 16)
607  GrowSize = 16;
608  else
609  {
610  UByte bits = Alg::UpperBit(UInt32(growSize-1));
611  UPInt size = 1<<bits;
612  GrowSize = size == growSize ? growSize : size;
613  }
614 }
615 
617 {
618  UPInt length, size = GetSize();
619  if (LengthIsSize)
620  return size;
621 
623 
624  if (length == GetSize())
625  LengthIsSize = true;
626  return length;
627 }
628 
630 {
631  if (_size >= BufferSize) // >= because of trailing zero! (!AB)
632  {
633  BufferSize = (_size + 1 + GrowSize - 1)& ~(GrowSize-1);
634  if (!pData)
635  pData = (char*)OVR_ALLOC(BufferSize);
636  else
637  pData = (char*)OVR_REALLOC(pData, BufferSize);
638  }
639 }
641 {
642  Reserve(_size);
643  LengthIsSize = false;
644  Size = _size;
645  if (pData)
646  pData[Size] = 0;
647 }
648 
650 {
651  Resize(0);
652  /*
653  if (pData != pEmptyNullData)
654  {
655  OVR_FREE(pHeap, pData);
656  pData = pEmptyNullData;
657  Size = BufferSize = 0;
658  LengthIsSize = false;
659  }
660  */
661 }
662 // Appends a character
664 {
665  char buff[8];
666  UPInt origSize = GetSize();
667 
668  // Converts ch into UTF8 string and fills it into buff. Also increments index according to the number of bytes
669  // in the UTF8 string.
670  SPInt srcSize = 0;
671  UTF8Util::EncodeChar(buff, &srcSize, ch);
672  OVR_ASSERT(srcSize >= 0);
673 
674  UPInt size = origSize + srcSize;
675  Resize(size);
676  memcpy(pData + origSize, buff, srcSize);
677 }
678 
679 // Append a string
680 void StringBuffer::AppendString(const wchar_t* pstr, SPInt len)
681 {
682  if (!pstr)
683  return;
684 
685  SPInt srcSize = UTF8Util::GetEncodeStringSize(pstr, len);
686  UPInt origSize = GetSize();
687  UPInt size = srcSize + origSize;
688 
689  Resize(size);
690  UTF8Util::EncodeString(pData + origSize, pstr, len);
691 }
692 
693 void StringBuffer::AppendString(const char* putf8str, SPInt utf8StrSz)
694 {
695  if (!putf8str || !utf8StrSz)
696  return;
697  if (utf8StrSz == -1)
698  utf8StrSz = (SPInt)OVR_strlen(putf8str);
699 
700  UPInt origSize = GetSize();
701  UPInt size = utf8StrSz + origSize;
702 
703  Resize(size);
704  memcpy(pData + origSize, putf8str, utf8StrSz);
705 }
706 
707 
708 void StringBuffer::operator = (const char* pstr)
709 {
710  pstr = pstr ? pstr : "";
711  UPInt size = OVR_strlen(pstr);
712  Resize(size);
713  memcpy(pData, pstr, size);
714 }
715 
716 void StringBuffer::operator = (const wchar_t* pstr)
717 {
718  pstr = pstr ? pstr : L"";
720  Resize(size);
722 }
723 
725 {
726  Resize(src.GetSize());
727  memcpy(pData, src.ToCStr(), src.GetSize());
728 }
729 
731 {
732  Clear();
733  AppendString(src.ToCStr(), src.GetSize());
734 }
735 
736 
737 // Inserts substr at posAt
738 void StringBuffer::Insert(const char* substr, UPInt posAt, SPInt len)
739 {
740  UPInt oldSize = Size;
741  UPInt insertSize = (len < 0) ? OVR_strlen(substr) : (UPInt)len;
742  UPInt byteIndex = LengthIsSize ? posAt :
744 
745  OVR_ASSERT(byteIndex <= oldSize);
746  Reserve(oldSize + insertSize);
747 
748  memmove(pData + byteIndex + insertSize, pData + byteIndex, oldSize - byteIndex + 1);
749  memcpy (pData + byteIndex, substr, insertSize);
750  LengthIsSize = false;
751  Size = oldSize + insertSize;
752  pData[Size] = 0;
753 }
754 
755 // Inserts character at posAt
757 {
758  char buf[8];
759  SPInt len = 0;
760  UTF8Util::EncodeChar(buf, &len, c);
761  OVR_ASSERT(len >= 0);
762  buf[(UPInt)len] = 0;
763 
764  Insert(buf, posAt, len);
765  return (UPInt)len;
766 }
767 
768 } // OVR
UPInt InsertCharAt(UInt32 c, UPInt posAt)
Definition: OVR_String.cpp:475
#define String_LengthIsSize
Definition: OVR_String.cpp:39
int OVR_CDECL OVR_tolower(int c)
Definition: OVR_Std.h:458
String ToUpper() const
Definition: OVR_String.cpp:394
void operator=(const char *str)
Definition: OVR_String.cpp:280
UInt32 OVR_STDCALL GetCharAt(SPInt index, const char *putf8str, SPInt length)
int OVR_CDECL OVR_towupper(wchar_t charCode)
Definition: OVR_Std.cpp:998
static DataDesc NullData
Definition: OVR_String.h:176
void SetGrowSize(UPInt growSize)
Definition: OVR_String.cpp:604
void SetData(DataDesc *pdesc)
Definition: OVR_String.h:129
#define NULL
__BEGIN_NAMESPACE_STD void * memcpy(void *__restrict __dest, const void *__restrict __src, size_t __n) __THROW __nonnull((1
String ToLower() const
Definition: OVR_String.cpp:418
SPInt OVR_STDCALL GetLength(const char *buf, SPInt buflen)
UInt32 GetNextChar(const char **offset) const
Definition: OVR_String.cpp:207
UInt32 OVR_STDCALL DecodeNextChar_Advance0(const char **putf8Buffer)
int OVR_CDECL OVR_towlower(wchar_t charCode)
Definition: OVR_Std.cpp:1016
void Remove(UPInt posAt, SPInt len=1)
Definition: OVR_String.cpp:343
uint32_t UInt32
Definition: OVR_Types.h:253
volatile SInt32 RefCount
Definition: OVR_String.h:72
void OVR_STDCALL EncodeChar(char *pbuffer, SPInt *pindex, UInt32 ucs_character)
UInt32 GetCharAt(UPInt index) const
Definition: OVR_String.cpp:163
size_t UPInt
Definition: OVR_Types.h:218
const char * ToCStr() const
Definition: OVR_String.h:437
#define OVR_SBUFF_DEFAULT_GROW_SIZE
Definition: OVR_String.cpp:556
uint8_t UByte
Definition: OVR_Types.h:249
__BEGIN_NAMESPACE_STD void void * memmove(void *__dest, const void *__src, size_t __n) __THROW __nonnull((1
UPInt InsertCharAt(UInt32 c, UPInt posAt)
Definition: OVR_String.cpp:756
void Clear()
Definition: OVR_String.cpp:386
const char * ToCStr() const
Definition: OVR_String.h:186
static UPInt OVR_STDCALL BernsteinHashFunctionCIS(const void *pdataIn, UPInt size, UPInt seed=5381)
Definition: OVR_String.cpp:535
UInt32 DecodeNextChar(const char **putf8Buffer)
Definition: OVR_UTF8Util.h:88
UByte UpperBit(UPInt val)
Definition: OVR_Alg.h:670
UInt32 GetFirstCharAt(UPInt index, const char **offset) const
Definition: OVR_String.cpp:181
UPInt GetLengthFlag() const
Definition: OVR_String.h:97
virtual void InitString(char *pbuffer, UPInt size) const =0
String Substring(UPInt start, UPInt end) const
Definition: OVR_String.cpp:368
#define OVR_ASSERT(p)
void AppendString(const wchar_t *pstr, SPInt len=-1)
Definition: OVR_String.cpp:231
void Resize(UPInt _size)
Definition: OVR_String.cpp:640
int OVR_CDECL OVR_stricmp(const char *a, const char *b)
Definition: OVR_Std.cpp:38
UPInt GetLength() const
Definition: OVR_String.cpp:142
void AppendChar(UInt32 ch)
Definition: OVR_String.cpp:663
void Insert(const char *substr, UPInt posAt, SPInt len=-1)
Definition: OVR_String.cpp:738
void operator+=(const String &src)
Definition: OVR_String.cpp:315
SPInt OVR_STDCALL GetByteIndex(SPInt index, const char *putf8str, SPInt length)
UPInt GetLength() const
Definition: OVR_String.cpp:616
void operator=(const char *str)
Definition: OVR_String.cpp:708
bool LengthIsSize() const
Definition: OVR_String.h:98
UPInt GetSize() const
Definition: OVR_String.h:189
ptrdiff_t SPInt
Definition: OVR_Types.h:219
DataDesc * GetData() const
Definition: OVR_String.h:121
void Reserve(UPInt _size)
Definition: OVR_String.cpp:629
void OVR_STDCALL EncodeString(char *pbuff, const wchar_t *pchar, SPInt length)
SPInt OVR_STDCALL GetEncodeStringSize(const wchar_t *pchar, SPInt length)
#define OVR_REALLOC(p, s)
int char * index(const char *__s, int __c) __THROW __attribute_pure__ __nonnull((1))
DataDesc * AllocData(UPInt size, UPInt lengthIsSize)
Definition: OVR_String.cpp:104
void AppendChar(UInt32 ch)
Definition: OVR_String.cpp:214
#define OVR_ALLOC(s)
static UPInt OVR_STDCALL BernsteinHashFunction(const void *pdataIn, UPInt size, UPInt seed=5381)
Definition: OVR_String.cpp:521
#define OVR_FREE(p)
static int OVR_STDCALL CompareNoCase(const char *a, const char *b)
Definition: OVR_String.cpp:488
UPInt GetSize() const
Definition: OVR_String.h:440
UPInt GetSize() const
Definition: OVR_String.h:96
UPInt OVR_CDECL OVR_strlen(const char *str)
Definition: OVR_Std.h:143
void AssignString(const InitStruct &src, UPInt size)
Definition: OVR_String.cpp:264
void AppendString(const wchar_t *pstr, SPInt len=-1)
Definition: OVR_String.cpp:680
DataDesc * AllocDataCopy2(UPInt size, UPInt lengthIsSize, const char *pdata1, UPInt copySize1, const char *pdata2, UPInt copySize2)
Definition: OVR_String.cpp:131
String & Insert(const char *substr, UPInt posAt, SPInt len=-1)
Definition: OVR_String.cpp:444
String operator+(const char *str) const
Definition: OVR_String.cpp:329
DataDesc * AllocDataCopy1(UPInt size, UPInt lengthIsSize, const char *pdata, UPInt copySize)
Definition: OVR_String.cpp:123