Bike-X  0.8
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
OVR_String.h
Go to the documentation of this file.
1 /************************************************************************************
2 
3 PublicHeader: OVR.h
4 Filename : OVR_String.h
5 Content : String UTF8 string implementation with copy-on-write semantics
6  (thread-safe for assignment but not modification).
7 Created : September 19, 2012
8 Notes :
9 
10 Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
11 
12 Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
13 you may not use the Oculus VR Rift SDK except in compliance with the License,
14 which is provided at the time of installation or download, or which
15 otherwise accompanies this software in either electronic or hard copy form.
16 
17 You may obtain a copy of the License at
18 
19 http://www.oculusvr.com/licenses/LICENSE-3.1
20 
21 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
22 distributed under the License is distributed on an "AS IS" BASIS,
23 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 See the License for the specific language governing permissions and
25 limitations under the License.
26 
27 ************************************************************************************/
28 
29 #ifndef OVR_String_h
30 #define OVR_String_h
31 
32 #include "OVR_Types.h"
33 #include "OVR_Allocator.h"
34 #include "OVR_UTF8Util.h"
35 #include "OVR_Atomic.h"
36 #include "OVR_Std.h"
37 #include "OVR_Alg.h"
38 
39 namespace OVR {
40 
41 // ***** Classes
42 
43 class String;
44 class StringBuffer;
45 
46 
47 //-----------------------------------------------------------------------------------
48 // ***** String Class
49 
50 // String is UTF8 based string class with copy-on-write implementation
51 // for assignment.
52 
53 class String
54 {
55 protected:
56 
58  {
59  //Flag_GetLength = 0x7FFFFFFF,
60  // This flag is set if GetLength() == GetSize() for a string.
61  // Avoid extra scanning is Substring and indexing logic.
62  Flag_LengthIsSizeShift = (sizeof(UPInt)*8 - 1)
63  };
64 
65 
66  // Internal structure to hold string data
67  struct DataDesc
68  {
69  // Number of bytes. Will be the same as the number of chars if the characters
70  // are ascii, may not be equal to number of chars in case string data is UTF8.
72  volatile SInt32 RefCount;
73  char Data[1];
74 
75  void AddRef()
76  {
78  }
79  // Decrement ref count. This needs to be thread-safe, since
80  // a different thread could have also decremented the ref count.
81  // For example, if u start off with a ref count = 2. Now if u
82  // decrement the ref count and check against 0 in different
83  // statements, a different thread can also decrement the ref count
84  // in between our decrement and checking against 0 and will find
85  // the ref count = 0 and delete the object. This will lead to a crash
86  // when context switches to our thread and we'll be trying to delete
87  // an already deleted object. Hence decrementing the ref count and
88  // checking against 0 needs to made an atomic operation.
89  void Release()
90  {
92  OVR_FREE(this);
93  }
94 
96  UPInt GetSize() const { return Size & ~GetLengthFlagBit() ; }
97  UPInt GetLengthFlag() const { return Size & GetLengthFlagBit(); }
98  bool LengthIsSize() const { return GetLengthFlag() != 0; }
99  };
100 
101  // Heap type of the string is encoded in the lower bits.
102  enum HeapType
103  {
104  HT_Global = 0, // Heap is global.
105  HT_Local = 1, // SF::String_loc: Heap is determined based on string's address.
106  HT_Dynamic = 2, // SF::String_temp: Heap is stored as a part of the class.
108  };
109 
110  union {
111  DataDesc* pData;
112  UPInt HeapTypeBits;
113  };
114  typedef union {
117  } DataDescUnion;
118 
119  inline HeapType GetHeapType() const { return (HeapType) (HeapTypeBits & HT_Mask); }
120 
121  inline DataDesc* GetData() const
122  {
123  DataDescUnion u;
124  u.pData = pData;
126  return u.pData;
127  }
128 
129  inline void SetData(DataDesc* pdesc)
130  {
131  HeapType ht = GetHeapType();
132  pData = pdesc;
133  OVR_ASSERT((HeapTypeBits & HT_Mask) == 0);
134  HeapTypeBits |= ht;
135  }
136 
137 
138  DataDesc* AllocData(UPInt size, UPInt lengthIsSize);
139  DataDesc* AllocDataCopy1(UPInt size, UPInt lengthIsSize,
140  const char* pdata, UPInt copySize);
141  DataDesc* AllocDataCopy2(UPInt size, UPInt lengthIsSize,
142  const char* pdata1, UPInt copySize1,
143  const char* pdata2, UPInt copySize2);
144 
145  // Special constructor to avoid data initalization when used in derived class.
146  struct NoConstructor { };
147  String(const NoConstructor&) { }
148 
149 public:
150 
151  // For initializing string with dynamic buffer
152  struct InitStruct
153  {
154  virtual ~InitStruct() { }
155  virtual void InitString(char* pbuffer, UPInt size) const = 0;
156  };
157 
158 
159  // Constructors / Destructors.
160  String();
161  String(const char* data);
162  String(const char* data1, const char* pdata2, const char* pdata3 = 0);
163  String(const char* data, UPInt buflen);
164  String(const String& src);
165  String(const StringBuffer& src);
166  String(const InitStruct& src, UPInt size);
167  explicit String(const wchar_t* data);
168 
169  // Destructor (Captain Obvious guarantees!)
171  {
172  GetData()->Release();
173  }
174 
175  // Declaration of NullString
177 
178 
179  // *** General Functions
180 
181  void Clear();
182 
183  // For casting to a pointer to char.
184  operator const char*() const { return GetData()->Data; }
185  // Pointer to raw buffer.
186  const char* ToCStr() const { return GetData()->Data; }
187 
188  // Returns number of bytes
189  UPInt GetSize() const { return GetData()->GetSize() ; }
190  // Tells whether or not the string is empty
191  bool IsEmpty() const { return GetSize() == 0; }
192 
193  // Returns number of characters
194  UPInt GetLength() const;
195 
196  // Returns character at the specified index
197  UInt32 GetCharAt(UPInt index) const;
198  UInt32 GetFirstCharAt(UPInt index, const char** offset) const;
199  UInt32 GetNextChar(const char** offset) const;
200 
201  // Appends a character
202  void AppendChar(UInt32 ch);
203 
204  // Append a string
205  void AppendString(const wchar_t* pstr, SPInt len = -1);
206  void AppendString(const char* putf8str, SPInt utf8StrSz = -1);
207 
208  // Assigned a string with dynamic data (copied through initializer).
209  void AssignString(const InitStruct& src, UPInt size);
210  // Assigns string with known size.
211  void AssignString(const char* putf8str, UPInt size);
212 
213  // Resize the string to the new size
214 // void Resize(UPInt _size);
215 
216  // Removes the character at posAt
217  void Remove(UPInt posAt, SPInt len = 1);
218 
219  // Returns a String that's a substring of this.
220  // -start is the index of the first UTF8 character you want to include.
221  // -end is the index one past the last UTF8 character you want to include.
222  String Substring(UPInt start, UPInt end) const;
223 
224  // Case-conversion
225  String ToUpper() const;
226  String ToLower() const;
227 
228  // Inserts substr at posAt
229  String& Insert (const char* substr, UPInt posAt, SPInt len = -1);
230 
231  // Inserts character at posAt
232  UPInt InsertCharAt(UInt32 c, UPInt posAt);
233 
234  // Inserts substr at posAt, which is an index of a character (not byte).
235  // Of size is specified, it is in bytes.
236 // String& Insert(const UInt32* substr, UPInt posAt, SPInt size = -1);
237 
238  // Get Byte index of the character at position = index
239  UPInt GetByteIndex(UPInt index) const { return (UPInt)UTF8Util::GetByteIndex(index, GetData()->Data); }
240 
241  // Utility: case-insensitive string compare. stricmp() & strnicmp() are not
242  // ANSI or POSIX, do not seem to appear in Linux.
243  static int OVR_STDCALL CompareNoCase(const char* a, const char* b);
244  static int OVR_STDCALL CompareNoCase(const char* a, const char* b, SPInt len);
245 
246  // Hash function, case-insensitive
247  static UPInt OVR_STDCALL BernsteinHashFunctionCIS(const void* pdataIn, UPInt size, UPInt seed = 5381);
248 
249  // Hash function, case-sensitive
250  static UPInt OVR_STDCALL BernsteinHashFunction(const void* pdataIn, UPInt size, UPInt seed = 5381);
251 
252 
253  // ***** File path parsing helper functions.
254  // Implemented in OVR_String_FilePath.cpp.
255 
256  // Absolute paths can star with:
257  // - protocols: 'file://', 'http://'
258  // - windows drive: 'c:\'
259  // - UNC share name: '\\share'
260  // - unix root '/'
261  static bool HasAbsolutePath(const char* path);
262  static bool HasExtension(const char* path);
263  static bool HasProtocol(const char* path);
264 
265  bool HasAbsolutePath() const { return HasAbsolutePath(ToCStr()); }
266  bool HasExtension() const { return HasExtension(ToCStr()); }
267  bool HasProtocol() const { return HasProtocol(ToCStr()); }
268 
269  String GetProtocol() const; // Returns protocol, if any, with trailing '://'.
270  String GetPath() const; // Returns path with trailing '/'.
271  String GetFilename() const; // Returns filename, including extension.
272  String GetExtension() const; // Returns extension with a dot.
273 
274  void StripProtocol(); // Strips front protocol, if any, from the string.
275  void StripExtension(); // Strips off trailing extension.
276 
277 
278  // Operators
279  // Assignment
280  void operator = (const char* str);
281  void operator = (const wchar_t* str);
282  void operator = (const String& src);
283  void operator = (const StringBuffer& src);
284 
285  // Addition
286  void operator += (const String& src);
287  void operator += (const char* psrc) { AppendString(psrc); }
288  void operator += (const wchar_t* psrc) { AppendString(psrc); }
289  void operator += (char ch) { AppendChar(ch); }
290  String operator + (const char* str) const;
291  String operator + (const String& src) const;
292 
293  // Comparison
294  bool operator == (const String& str) const
295  {
296  return (OVR_strcmp(GetData()->Data, str.GetData()->Data)== 0);
297  }
298 
299  bool operator != (const String& str) const
300  {
301  return !operator == (str);
302  }
303 
304  bool operator == (const char* str) const
305  {
306  return OVR_strcmp(GetData()->Data, str) == 0;
307  }
308 
309  bool operator != (const char* str) const
310  {
311  return !operator == (str);
312  }
313 
314  bool operator < (const char* pstr) const
315  {
316  return OVR_strcmp(GetData()->Data, pstr) < 0;
317  }
318 
319  bool operator < (const String& str) const
320  {
321  return *this < str.GetData()->Data;
322  }
323 
324  bool operator > (const char* pstr) const
325  {
326  return OVR_strcmp(GetData()->Data, pstr) > 0;
327  }
328 
329  bool operator > (const String& str) const
330  {
331  return *this > str.GetData()->Data;
332  }
333 
334  int CompareNoCase(const char* pstr) const
335  {
336  return CompareNoCase(GetData()->Data, pstr);
337  }
338  int CompareNoCase(const String& str) const
339  {
340  return CompareNoCase(GetData()->Data, str.ToCStr());
341  }
342 
343  // Accesses raw bytes
344  const char& operator [] (int index) const
345  {
346  OVR_ASSERT(index >= 0 && (UPInt)index < GetSize());
347  return GetData()->Data[index];
348  }
349  const char& operator [] (UPInt index) const
350  {
351  OVR_ASSERT(index < GetSize());
352  return GetData()->Data[index];
353  }
354 
355 
356  // Case insensitive keys are used to look up insensitive string in hash tables
357  // for SWF files with version before SWF 7.
358  struct NoCaseKey
359  {
360  const String* pStr;
361  NoCaseKey(const String &str) : pStr(&str){};
362  };
363 
364  bool operator == (const NoCaseKey& strKey) const
365  {
366  return (CompareNoCase(ToCStr(), strKey.pStr->ToCStr()) == 0);
367  }
368  bool operator != (const NoCaseKey& strKey) const
369  {
370  return !(CompareNoCase(ToCStr(), strKey.pStr->ToCStr()) == 0);
371  }
372 
373  // Hash functor used for strings.
374  struct HashFunctor
375  {
376  UPInt operator()(const String& data) const
377  {
378  UPInt size = data.GetSize();
379  return String::BernsteinHashFunction((const char*)data, size);
380  }
381  };
382  // Case-insensitive hash functor used for strings. Supports additional
383  // lookup based on NoCaseKey.
385  {
386  UPInt operator()(const String& data) const
387  {
388  UPInt size = data.GetSize();
389  return String::BernsteinHashFunctionCIS((const char*)data, size);
390  }
391  UPInt operator()(const NoCaseKey& data) const
392  {
393  UPInt size = data.pStr->GetSize();
394  return String::BernsteinHashFunctionCIS((const char*)data.pStr->ToCStr(), size);
395  }
396  };
397 
398 };
399 
400 
401 //-----------------------------------------------------------------------------------
402 // ***** String Buffer used for Building Strings
403 
405 {
406  char* pData;
410  mutable bool LengthIsSize;
411 
412 public:
413 
414  // Constructors / Destructor.
415  StringBuffer();
416  explicit StringBuffer(UPInt growSize);
417  StringBuffer(const char* data);
418  StringBuffer(const char* data, UPInt buflen);
419  StringBuffer(const String& src);
420  StringBuffer(const StringBuffer& src);
421  explicit StringBuffer(const wchar_t* data);
422  ~StringBuffer();
423 
424 
425  // Modify grow size used for growing/shrinking the buffer.
426  UPInt GetGrowSize() const { return GrowSize; }
427  void SetGrowSize(UPInt growSize);
428 
429 
430  // *** General Functions
431  // Does not release memory, just sets Size to 0
432  void Clear();
433 
434  // For casting to a pointer to char.
435  operator const char*() const { return (pData) ? pData : ""; }
436  // Pointer to raw buffer.
437  const char* ToCStr() const { return (pData) ? pData : ""; }
438 
439  // Returns number of bytes.
440  UPInt GetSize() const { return Size ; }
441  // Tells whether or not the string is empty.
442  bool IsEmpty() const { return GetSize() == 0; }
443 
444  // Returns number of characters
445  UPInt GetLength() const;
446 
447  // Returns character at the specified index
448  UInt32 GetCharAt(UPInt index) const;
449  UInt32 GetFirstCharAt(UPInt index, const char** offset) const;
450  UInt32 GetNextChar(const char** offset) const;
451 
452 
453  // Resize the string to the new size
454  void Resize(UPInt _size);
455  void Reserve(UPInt _size);
456 
457  // Appends a character
458  void AppendChar(UInt32 ch);
459 
460  // Append a string
461  void AppendString(const wchar_t* pstr, SPInt len = -1);
462  void AppendString(const char* putf8str, SPInt utf8StrSz = -1);
463  void AppendFormat(const char* format, ...);
464 
465  // Assigned a string with dynamic data (copied through initializer).
466  //void AssignString(const InitStruct& src, UPInt size);
467 
468  // Inserts substr at posAt
469  void Insert (const char* substr, UPInt posAt, SPInt len = -1);
470  // Inserts character at posAt
471  UPInt InsertCharAt(UInt32 c, UPInt posAt);
472 
473  // Assignment
474  void operator = (const char* str);
475  void operator = (const wchar_t* str);
476  void operator = (const String& src);
477  void operator = (const StringBuffer& src);
478 
479  // Addition
480  void operator += (const String& src) { AppendString(src.ToCStr(),src.GetSize()); }
481  void operator += (const char* psrc) { AppendString(psrc); }
482  void operator += (const wchar_t* psrc) { AppendString(psrc); }
483  void operator += (char ch) { AppendChar(ch); }
484  //String operator + (const char* str) const ;
485  //String operator + (const String& src) const ;
486 
487  // Accesses raw bytes
488  char& operator [] (int index)
489  {
490  OVR_ASSERT(((UPInt)index) < GetSize());
491  return pData[index];
492  }
494  {
495  OVR_ASSERT(index < GetSize());
496  return pData[index];
497  }
498 
499  const char& operator [] (int index) const
500  {
501  OVR_ASSERT(((UPInt)index) < GetSize());
502  return pData[index];
503  }
504  const char& operator [] (UPInt index) const
505  {
506  OVR_ASSERT(index < GetSize());
507  return pData[index];
508  }
509 };
510 
511 
512 //
513 // Wrapper for string data. The data must have a guaranteed
514 // lifespan throughout the usage of the wrapper. Not intended for
515 // cached usage. Not thread safe.
516 //
518 {
519 public:
522  : pStr(p.pStr), Size(p.Size) {}
523  StringDataPtr(const char* pstr, UPInt sz)
524  : pStr(pstr), Size(sz) {}
525  StringDataPtr(const char* pstr)
526  : pStr(pstr), Size((pstr != NULL) ? OVR_strlen(pstr) : 0) {}
527  explicit StringDataPtr(const String& str)
528  : pStr(str.ToCStr()), Size(str.GetSize()) {}
529  template <typename T, int N>
530  StringDataPtr(const T (&v)[N])
531  : pStr(v), Size(N) {}
532 
533 public:
534  const char* ToCStr() const { return pStr; }
535  UPInt GetSize() const { return Size; }
536  bool IsEmpty() const { return GetSize() == 0; }
537 
538  // value is a prefix of this string
539  // Character's values are not compared.
540  bool IsPrefix(const StringDataPtr& value) const
541  {
542  return ToCStr() == value.ToCStr() && GetSize() >= value.GetSize();
543  }
544  // value is a suffix of this string
545  // Character's values are not compared.
546  bool IsSuffix(const StringDataPtr& value) const
547  {
548  return ToCStr() <= value.ToCStr() && (End()) == (value.End());
549  }
550 
551  // Find first character.
552  // init_ind - initial index.
553  SPInt FindChar(char c, UPInt init_ind = 0) const
554  {
555  for (UPInt i = init_ind; i < GetSize(); ++i)
556  if (pStr[i] == c)
557  return static_cast<SPInt>(i);
558 
559  return -1;
560  }
561 
562  // Find last character.
563  // init_ind - initial index.
564  SPInt FindLastChar(char c, UPInt init_ind = ~0) const
565  {
566  if (init_ind == (UPInt)~0 || init_ind > GetSize())
567  init_ind = GetSize();
568  else
569  ++init_ind;
570 
571  for (UPInt i = init_ind; i > 0; --i)
572  if (pStr[i - 1] == c)
573  return static_cast<SPInt>(i - 1);
574 
575  return -1;
576  }
577 
578  // Create new object and trim size bytes from the left.
580  {
581  // Limit trim size to the size of the string.
582  size = Alg::PMin(GetSize(), size);
583 
584  return StringDataPtr(ToCStr() + size, GetSize() - size);
585  }
586  // Create new object and trim size bytes from the right.
588  {
589  // Limit trim to the size of the string.
590  size = Alg::PMin(GetSize(), size);
591 
592  return StringDataPtr(ToCStr(), GetSize() - size);
593  }
594 
595  // Create new object, which contains next token.
596  // Useful for parsing.
597  StringDataPtr GetNextToken(char separator = ':') const
598  {
599  UPInt cur_pos = 0;
600  const char* cur_str = ToCStr();
601 
602  for (; cur_pos < GetSize() && cur_str[cur_pos]; ++cur_pos)
603  {
604  if (cur_str[cur_pos] == separator)
605  {
606  break;
607  }
608  }
609 
610  return StringDataPtr(ToCStr(), cur_pos);
611  }
612 
613  // Trim size bytes from the left.
615  {
616  // Limit trim size to the size of the string.
617  size = Alg::PMin(GetSize(), size);
618  pStr += size;
619  Size -= size;
620 
621  return *this;
622  }
623  // Trim size bytes from the right.
625  {
626  // Limit trim to the size of the string.
627  size = Alg::PMin(GetSize(), size);
628  Size -= size;
629 
630  return *this;
631  }
632 
633  const char* Begin() const { return ToCStr(); }
634  const char* End() const { return ToCStr() + GetSize(); }
635 
636  // Hash functor used string data pointers
637  struct HashFunctor
638  {
639  UPInt operator()(const StringDataPtr& data) const
640  {
641  return String::BernsteinHashFunction(data.ToCStr(), data.GetSize());
642  }
643  };
644 
645  bool operator== (const StringDataPtr& data) const
646  {
647  return (OVR_strncmp(pStr, data.pStr, data.Size) == 0);
648  }
649 
650 protected:
651  const char* pStr;
653 };
654 
655 } // OVR
656 
657 #endif
UPInt InsertCharAt(UInt32 c, UPInt posAt)
Definition: OVR_String.cpp:475
UPInt GetByteIndex(UPInt index) const
Definition: OVR_String.h:239
bool operator==(const String &str) const
Definition: OVR_String.h:294
bool operator!=(const String &str) const
Definition: OVR_String.h:299
String ToUpper() const
Definition: OVR_String.cpp:394
void operator=(const char *str)
Definition: OVR_String.cpp:280
String GetFilename() const
String GetProtocol() const
static DataDesc NullData
Definition: OVR_String.h:176
void SetGrowSize(UPInt growSize)
Definition: OVR_String.cpp:604
bool HasProtocol() const
Definition: OVR_String.h:267
void SetData(DataDesc *pdesc)
Definition: OVR_String.h:129
#define NULL
String ToLower() const
Definition: OVR_String.cpp:418
bool HasAbsolutePath() const
Definition: OVR_String.h:265
NoCaseKey(const String &str)
Definition: OVR_String.h:361
UInt32 GetNextChar(const char **offset) const
Definition: OVR_String.cpp:207
bool operator>(const char *pstr) const
Definition: OVR_String.h:324
void Remove(UPInt posAt, SPInt len=1)
Definition: OVR_String.cpp:343
UInt32 GetCharAt(UPInt index) const
uint32_t UInt32
Definition: OVR_Types.h:253
volatile SInt32 RefCount
Definition: OVR_String.h:72
const char * Begin() const
Definition: OVR_String.h:633
SPInt FindLastChar(char c, UPInt init_ind=~0) const
Definition: OVR_String.h:564
StringDataPtr(const char *pstr)
Definition: OVR_String.h:525
StringDataPtr GetTrimRight(UPInt size) const
Definition: OVR_String.h:587
UInt32 GetCharAt(UPInt index) const
Definition: OVR_String.cpp:163
HeapType GetHeapType() const
Definition: OVR_String.h:119
static UPInt GetLengthFlagBit()
Definition: OVR_String.h:95
size_t UPInt
Definition: OVR_Types.h:218
const char * ToCStr() const
Definition: OVR_String.h:437
#define OVR_STDCALL
UPInt InsertCharAt(UInt32 c, UPInt posAt)
Definition: OVR_String.cpp:756
char & operator[](int index)
Definition: OVR_String.h:488
bool IsPrefix(const StringDataPtr &value) const
Definition: OVR_String.h:540
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
const char * pStr
Definition: OVR_String.h:651
bool IsSuffix(const StringDataPtr &value) const
Definition: OVR_String.h:546
UInt32 GetFirstCharAt(UPInt index, const char **offset) const
Definition: OVR_String.cpp:181
UPInt GetLengthFlag() const
Definition: OVR_String.h:97
int CompareNoCase(const String &str) const
Definition: OVR_String.h:338
const char * ToCStr() const
Definition: OVR_String.h:534
virtual void InitString(char *pbuffer, UPInt size) const =0
String Substring(UPInt start, UPInt end) const
Definition: OVR_String.cpp:368
int CompareNoCase(const char *pstr) const
Definition: OVR_String.h:334
StringDataPtr GetTrimLeft(UPInt size) const
Definition: OVR_String.h:579
UPInt operator()(const String &data) const
Definition: OVR_String.h:376
OVR_FORCE_INLINE const T PMin(const T a, const T b)
Definition: OVR_Alg.h:67
#define OVR_ASSERT(p)
StringDataPtr & TrimRight(UPInt size)
Definition: OVR_String.h:624
static C ExchangeAdd_NoSync(volatile C *p, C val)
Definition: OVR_Atomic.h:583
void AppendString(const wchar_t *pstr, SPInt len=-1)
Definition: OVR_String.cpp:231
StringDataPtr GetNextToken(char separator= ':') const
Definition: OVR_String.h:597
bool operator<(const char *pstr) const
Definition: OVR_String.h:314
StringDataPtr(const String &str)
Definition: OVR_String.h:527
int OVR_CDECL OVR_strncmp(const char *ws1, const char *ws2, UPInt size)
Definition: OVR_Std.h:237
void Resize(UPInt _size)
Definition: OVR_String.cpp:640
bool IsEmpty() const
Definition: OVR_String.h:191
int OVR_CDECL OVR_strcmp(const char *dest, const char *src)
Definition: OVR_Std.h:181
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 AppendFormat(const char *format,...)
void operator+=(const String &src)
Definition: OVR_String.cpp:315
SPInt OVR_STDCALL GetByteIndex(SPInt index, const char *putf8str, SPInt length)
int32_t SInt32
Definition: OVR_Types.h:252
UPInt operator()(const StringDataPtr &data) const
Definition: OVR_String.h:639
UPInt GetLength() const
Definition: OVR_String.cpp:616
void operator=(const char *str)
Definition: OVR_String.cpp:708
String GetPath() const
const char & operator[](int index) const
Definition: OVR_String.h:344
UPInt GetSize() const
Definition: OVR_String.h:535
const char * End() const
Definition: OVR_String.h:634
bool LengthIsSize() const
Definition: OVR_String.h:98
UPInt GetSize() const
Definition: OVR_String.h:189
StringDataPtr(const T(&v)[N])
Definition: OVR_String.h:530
ptrdiff_t SPInt
Definition: OVR_Types.h:219
StringDataPtr & TrimLeft(UPInt size)
Definition: OVR_String.h:614
String GetExtension() const
DataDesc * GetData() const
Definition: OVR_String.h:121
void Reserve(UPInt _size)
Definition: OVR_String.cpp:629
bool IsEmpty() const
Definition: OVR_String.h:442
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
SPInt FindChar(char c, UPInt init_ind=0) const
Definition: OVR_String.h:553
bool HasExtension() const
Definition: OVR_String.h:266
StringDataPtr(const char *pstr, UPInt sz)
Definition: OVR_String.h:523
bool IsEmpty() const
Definition: OVR_String.h:536
StringDataPtr(const StringDataPtr &p)
Definition: OVR_String.h:521
static UPInt OVR_STDCALL BernsteinHashFunction(const void *pdataIn, UPInt size, UPInt seed=5381)
Definition: OVR_String.cpp:521
String(const NoConstructor &)
Definition: OVR_String.h:147
void operator+=(const String &src)
Definition: OVR_String.h:480
UPInt operator()(const String &data) const
Definition: OVR_String.h:386
UInt32 GetFirstCharAt(UPInt index, const char **offset) const
UPInt operator()(const NoCaseKey &data) const
Definition: OVR_String.h:391
#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 GetGrowSize() const
Definition: OVR_String.h:426
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
bool operator==(const StringDataPtr &data) const
Definition: OVR_String.h:645
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
const String * pStr
Definition: OVR_String.h:360
DataDesc * AllocDataCopy1(UPInt size, UPInt lengthIsSize, const char *pdata, UPInt copySize)
Definition: OVR_String.cpp:123
UInt32 GetNextChar(const char **offset) const