String.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef STRING_H
  2. #define STRING_H
  3. #include <gdnative/string.h>
  4. namespace godot {
  5. class NodePath;
  6. class Variant;
  7. class PoolByteArray;
  8. class PoolRealArray;
  9. class PoolStringArray;
  10. class String {
  11. godot_string _godot_string;
  12. public:
  13. String();
  14. String(const char *contents);
  15. String(const wchar_t *contents);
  16. String(const wchar_t c);
  17. String(const String &other);
  18. ~String();
  19. wchar_t &operator[](const int idx);
  20. wchar_t operator[](const int idx) const;
  21. void operator=(const String &s);
  22. bool operator==(const String &s);
  23. bool operator!=(const String &s);
  24. String operator+(const String &s);
  25. void operator+=(const String &s);
  26. void operator+=(const wchar_t c);
  27. bool operator<(const String &s);
  28. bool operator<=(const String &s);
  29. bool operator>(const String &s);
  30. bool operator>=(const String &s);
  31. operator NodePath() const;
  32. int length() const;
  33. const char *c_string() const;
  34. int64_t find(String p_what) const;
  35. int64_t find_from(String p_what, int64_t p_from) const;
  36. bool begins_with(String &s) const;
  37. bool begins_with_char_array(const char *p_char_array) const;
  38. PoolStringArray bigrams() const;
  39. String c_escape() const;
  40. String c_unescape() const;
  41. String capitalize() const;
  42. bool empty() const;
  43. bool ends_with(String &text) const;
  44. void erase(int position, int chars);
  45. int find(String what, int from = 0) const;
  46. int find_last(String what) const;
  47. int findn(String what, int from = 0) const;
  48. String format(Variant values, String placeholder) const;
  49. String get_base_dir() const;
  50. String get_basename() const;
  51. String get_extension() const;
  52. String get_file() const;
  53. int hash() const;
  54. int hex_to_int() const;
  55. String insert(int position, String what) const;
  56. bool is_abs_path() const;
  57. bool is_rel_path() const;
  58. bool is_subsequence_of(String text) const;
  59. bool is_subsequence_ofi(String text) const;
  60. bool is_valid_float() const;
  61. bool is_valid_html_color() const;
  62. bool is_valid_identifier() const;
  63. bool is_valid_integer() const;
  64. bool is_valid_ip_address() const;
  65. String json_escape() const;
  66. String left(int position) const;
  67. bool match(String expr) const;
  68. bool matchn(String expr) const;
  69. PoolByteArray md5_buffer() const;
  70. String md5_text() const;
  71. int ord_at(int at) const;
  72. String pad_decimals(int digits) const;
  73. String pad_zeros(int digits) const;
  74. String percent_decode() const;
  75. String percent_encode() const;
  76. String plus_file(String file) const;
  77. String replace(String what, String forwhat) const;
  78. String replacen(String what, String forwhat) const;
  79. int rfind(String what, int from = -1) const;
  80. int rfindn(String what, int from = -1) const;
  81. String right(int position) const;
  82. PoolByteArray sha256_buffer() const;
  83. String sha256_text() const;
  84. float similarity(String text) const;
  85. PoolStringArray split(String divisor, bool allow_empty = true) const;
  86. PoolRealArray split_floats(String divisor, bool allow_empty = true) const;
  87. String strip_edges(bool left = true, bool right = true) const;
  88. String substr(int from, int len) const;
  89. float to_float() const;
  90. int64_t to_int() const;
  91. String to_lower() const;
  92. String to_upper() const;
  93. String xml_escape() const;
  94. String xml_unescape() const;
  95. };
  96. String operator+(const char *a, const String &b);
  97. }
  98. #endif // STRING_H