Str.pkg 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. $#include "Str.h"
  2. class String
  3. {
  4. String();
  5. String(const String& str);
  6. String(const char* str);
  7. String(const char* str, unsigned length);
  8. ~String();
  9. String operator + (const String& rhs) const;
  10. String operator + (const char* rhs) const;
  11. bool operator == (const String& rhs) const;
  12. bool operator == (const char* rhs) const;
  13. tolua_outside bool StringEquals @ Equals(const String& rhs) const;
  14. tolua_outside bool StringEquals @ Equals(const char*& rhs) const;
  15. void Replace(const String& replaceThis, const String& replaceWith);
  16. void Replace(const char* replaceThis, const char* replaceWith);
  17. void Replace(unsigned pos, unsigned length, const String& replaceWith);
  18. void Replace(unsigned pos, unsigned length, const char* replaceWith);
  19. String Replaced(const String& replaceThis, const String& replaceWith) const;
  20. String Replaced(const char* replaceThis, const char* replaceWith) const;
  21. String& Append(const String& str);
  22. String& Append(const char* str);
  23. String& Append(const char* str, unsigned length);
  24. void Insert(unsigned pos, const String& str);
  25. void Insert(unsigned pos, char c);
  26. void Erase(unsigned pos, unsigned length = 1);
  27. void Resize(unsigned newLength);
  28. void Reserve(unsigned newCapacity);
  29. void Compact();
  30. void Clear();
  31. String Substring(unsigned pos) const;
  32. String Substring(unsigned pos, unsigned length) const;
  33. String Trimmed() const;
  34. String ToUpper() const;
  35. String ToLower() const;
  36. unsigned Find(const String& str, unsigned startPos = 0) const;
  37. unsigned Find(const char* str, unsigned startPos = 0) const;
  38. unsigned FindLast(const String& str, unsigned startPos = String::NPOS) const;
  39. unsigned FindLast(const char* str, unsigned startPos = String::NPOS) const;
  40. bool StartsWith(const String& str) const;
  41. bool StartsWith(const char* str) const;
  42. bool EndsWith(const String& str) const;
  43. bool EndsWith(const char* str) const;
  44. const char* CString() const;
  45. unsigned Length() const;
  46. unsigned Capacity() const;
  47. bool Empty() const;
  48. int Compare(const String& str, bool caseSensitive = true) const;
  49. int Compare(const char* str, bool caseSensitive = true) const;
  50. bool Contains(const String& str) const;
  51. unsigned ToHash() const;
  52. static int Compare(const char* str1, const char* str2, bool caseSensitive);
  53. static const unsigned NPOS;
  54. static const String EMPTY;
  55. tolua_readonly tolua_property__no_prefix unsigned length;
  56. tolua_readonly tolua_property__no_prefix unsigned capacity;
  57. tolua_readonly tolua_property__no_prefix bool empty;
  58. };
  59. ${
  60. static bool StringEquals(const String* lhs, const char* rhs)
  61. {
  62. return (*lhs) == rhs;
  63. }
  64. static bool StringEquals(const String* lhs, const String& rhs)
  65. {
  66. return (*lhs) == rhs;
  67. }
  68. $}