ustring.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. /*************************************************************************/
  2. /* ustring.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef USTRING_GODOT_H
  31. #define USTRING_GODOT_H
  32. // Note: Renamed to avoid conflict with ICU header with the same name.
  33. #include "core/templates/cowdata.h"
  34. #include "core/templates/vector.h"
  35. #include "core/typedefs.h"
  36. #include "core/variant/array.h"
  37. /*************************************************************************/
  38. /* CharProxy */
  39. /*************************************************************************/
  40. template <class T>
  41. class CharProxy {
  42. friend class Char16String;
  43. friend class CharString;
  44. friend class String;
  45. const int _index;
  46. CowData<T> &_cowdata;
  47. static const T _null = 0;
  48. _FORCE_INLINE_ CharProxy(const int &p_index, CowData<T> &p_cowdata) :
  49. _index(p_index),
  50. _cowdata(p_cowdata) {}
  51. public:
  52. _FORCE_INLINE_ CharProxy(const CharProxy<T> &p_other) :
  53. _index(p_other._index),
  54. _cowdata(p_other._cowdata) {}
  55. _FORCE_INLINE_ operator T() const {
  56. if (unlikely(_index == _cowdata.size())) {
  57. return _null;
  58. }
  59. return _cowdata.get(_index);
  60. }
  61. _FORCE_INLINE_ const T *operator&() const {
  62. return _cowdata.ptr() + _index;
  63. }
  64. _FORCE_INLINE_ void operator=(const T &p_other) const {
  65. _cowdata.set(_index, p_other);
  66. }
  67. _FORCE_INLINE_ void operator=(const CharProxy<T> &p_other) const {
  68. _cowdata.set(_index, p_other.operator T());
  69. }
  70. };
  71. /*************************************************************************/
  72. /* Char16String */
  73. /*************************************************************************/
  74. class Char16String {
  75. CowData<char16_t> _cowdata;
  76. static const char16_t _null;
  77. public:
  78. _FORCE_INLINE_ char16_t *ptrw() { return _cowdata.ptrw(); }
  79. _FORCE_INLINE_ const char16_t *ptr() const { return _cowdata.ptr(); }
  80. _FORCE_INLINE_ int size() const { return _cowdata.size(); }
  81. Error resize(int p_size) { return _cowdata.resize(p_size); }
  82. _FORCE_INLINE_ char16_t get(int p_index) const { return _cowdata.get(p_index); }
  83. _FORCE_INLINE_ void set(int p_index, const char16_t &p_elem) { _cowdata.set(p_index, p_elem); }
  84. _FORCE_INLINE_ const char16_t &operator[](int p_index) const {
  85. if (unlikely(p_index == _cowdata.size())) {
  86. return _null;
  87. }
  88. return _cowdata.get(p_index);
  89. }
  90. _FORCE_INLINE_ CharProxy<char16_t> operator[](int p_index) { return CharProxy<char16_t>(p_index, _cowdata); }
  91. _FORCE_INLINE_ Char16String() {}
  92. _FORCE_INLINE_ Char16String(const Char16String &p_str) { _cowdata._ref(p_str._cowdata); }
  93. _FORCE_INLINE_ Char16String &operator=(const Char16String &p_str) {
  94. _cowdata._ref(p_str._cowdata);
  95. return *this;
  96. }
  97. _FORCE_INLINE_ Char16String(const char16_t *p_cstr) { copy_from(p_cstr); }
  98. Char16String &operator=(const char16_t *p_cstr);
  99. bool operator<(const Char16String &p_right) const;
  100. Char16String &operator+=(char16_t p_char);
  101. int length() const { return size() ? size() - 1 : 0; }
  102. const char16_t *get_data() const;
  103. operator const char16_t *() const { return get_data(); };
  104. protected:
  105. void copy_from(const char16_t *p_cstr);
  106. };
  107. /*************************************************************************/
  108. /* CharString */
  109. /*************************************************************************/
  110. class CharString {
  111. CowData<char> _cowdata;
  112. static const char _null;
  113. public:
  114. _FORCE_INLINE_ char *ptrw() { return _cowdata.ptrw(); }
  115. _FORCE_INLINE_ const char *ptr() const { return _cowdata.ptr(); }
  116. _FORCE_INLINE_ int size() const { return _cowdata.size(); }
  117. Error resize(int p_size) { return _cowdata.resize(p_size); }
  118. _FORCE_INLINE_ char get(int p_index) const { return _cowdata.get(p_index); }
  119. _FORCE_INLINE_ void set(int p_index, const char &p_elem) { _cowdata.set(p_index, p_elem); }
  120. _FORCE_INLINE_ const char &operator[](int p_index) const {
  121. if (unlikely(p_index == _cowdata.size())) {
  122. return _null;
  123. }
  124. return _cowdata.get(p_index);
  125. }
  126. _FORCE_INLINE_ CharProxy<char> operator[](int p_index) { return CharProxy<char>(p_index, _cowdata); }
  127. _FORCE_INLINE_ CharString() {}
  128. _FORCE_INLINE_ CharString(const CharString &p_str) { _cowdata._ref(p_str._cowdata); }
  129. _FORCE_INLINE_ CharString &operator=(const CharString &p_str) {
  130. _cowdata._ref(p_str._cowdata);
  131. return *this;
  132. }
  133. _FORCE_INLINE_ CharString(const char *p_cstr) { copy_from(p_cstr); }
  134. CharString &operator=(const char *p_cstr);
  135. bool operator<(const CharString &p_right) const;
  136. CharString &operator+=(char p_char);
  137. int length() const { return size() ? size() - 1 : 0; }
  138. const char *get_data() const;
  139. operator const char *() const { return get_data(); };
  140. protected:
  141. void copy_from(const char *p_cstr);
  142. };
  143. /*************************************************************************/
  144. /* String */
  145. /*************************************************************************/
  146. struct StrRange {
  147. const char32_t *c_str;
  148. int len;
  149. StrRange(const char32_t *p_c_str = nullptr, int p_len = 0) {
  150. c_str = p_c_str;
  151. len = p_len;
  152. }
  153. };
  154. class String {
  155. CowData<char32_t> _cowdata;
  156. static const char32_t _null;
  157. void copy_from(const char *p_cstr);
  158. void copy_from(const char *p_cstr, const int p_clip_to);
  159. void copy_from(const wchar_t *p_cstr);
  160. void copy_from(const wchar_t *p_cstr, const int p_clip_to);
  161. void copy_from(const char32_t *p_cstr);
  162. void copy_from(const char32_t *p_cstr, const int p_clip_to);
  163. void copy_from(const char32_t &p_char);
  164. void copy_from_unchecked(const char32_t *p_char, const int p_length);
  165. bool _base_is_subsequence_of(const String &p_string, bool case_insensitive) const;
  166. int _count(const String &p_string, int p_from, int p_to, bool p_case_insensitive) const;
  167. public:
  168. enum {
  169. npos = -1 ///<for "some" compatibility with std::string (npos is a huge value in std::string)
  170. };
  171. _FORCE_INLINE_ char32_t *ptrw() { return _cowdata.ptrw(); }
  172. _FORCE_INLINE_ const char32_t *ptr() const { return _cowdata.ptr(); }
  173. void remove(int p_index) { _cowdata.remove(p_index); }
  174. _FORCE_INLINE_ void clear() { resize(0); }
  175. _FORCE_INLINE_ char32_t get(int p_index) const { return _cowdata.get(p_index); }
  176. _FORCE_INLINE_ void set(int p_index, const char32_t &p_elem) { _cowdata.set(p_index, p_elem); }
  177. _FORCE_INLINE_ int size() const { return _cowdata.size(); }
  178. Error resize(int p_size) { return _cowdata.resize(p_size); }
  179. _FORCE_INLINE_ const char32_t &operator[](int p_index) const {
  180. if (unlikely(p_index == _cowdata.size())) {
  181. return _null;
  182. }
  183. return _cowdata.get(p_index);
  184. }
  185. _FORCE_INLINE_ CharProxy<char32_t> operator[](int p_index) { return CharProxy<char32_t>(p_index, _cowdata); }
  186. bool operator==(const String &p_str) const;
  187. bool operator!=(const String &p_str) const;
  188. String operator+(const String &p_str) const;
  189. String &operator+=(const String &);
  190. String &operator+=(char32_t p_char);
  191. String &operator+=(const char *p_str);
  192. String &operator+=(const wchar_t *p_str);
  193. String &operator+=(const char32_t *p_str);
  194. /* Compatibility Operators */
  195. void operator=(const char *p_str);
  196. void operator=(const wchar_t *p_str);
  197. void operator=(const char32_t *p_str);
  198. bool operator==(const char *p_str) const;
  199. bool operator==(const wchar_t *p_str) const;
  200. bool operator==(const char32_t *p_str) const;
  201. bool operator==(const StrRange &p_str_range) const;
  202. bool operator!=(const char *p_str) const;
  203. bool operator!=(const wchar_t *p_str) const;
  204. bool operator!=(const char32_t *p_str) const;
  205. bool operator<(const char32_t *p_str) const;
  206. bool operator<(const char *p_str) const;
  207. bool operator<(const wchar_t *p_str) const;
  208. bool operator<(const String &p_str) const;
  209. bool operator<=(const String &p_str) const;
  210. bool operator>(const String &p_str) const;
  211. bool operator>=(const String &p_str) const;
  212. signed char casecmp_to(const String &p_str) const;
  213. signed char nocasecmp_to(const String &p_str) const;
  214. signed char naturalnocasecmp_to(const String &p_str) const;
  215. const char32_t *get_data() const;
  216. /* standard size stuff */
  217. _FORCE_INLINE_ int length() const {
  218. int s = size();
  219. return s ? (s - 1) : 0; // length does not include zero
  220. }
  221. bool is_valid_string() const;
  222. /* complex helpers */
  223. String substr(int p_from, int p_chars = -1) const;
  224. int find(const String &p_str, int p_from = 0) const; ///< return <0 if failed
  225. int find(const char *p_str, int p_from = 0) const; ///< return <0 if failed
  226. int find_char(const char32_t &p_char, int p_from = 0) const; ///< return <0 if failed
  227. int findn(const String &p_str, int p_from = 0) const; ///< return <0 if failed, case insensitive
  228. int rfind(const String &p_str, int p_from = -1) const; ///< return <0 if failed
  229. int rfindn(const String &p_str, int p_from = -1) const; ///< return <0 if failed, case insensitive
  230. int findmk(const Vector<String> &p_keys, int p_from = 0, int *r_key = nullptr) const; ///< return <0 if failed
  231. bool match(const String &p_wildcard) const;
  232. bool matchn(const String &p_wildcard) const;
  233. bool begins_with(const String &p_string) const;
  234. bool begins_with(const char *p_string) const;
  235. bool ends_with(const String &p_string) const;
  236. bool is_enclosed_in(const String &p_string) const;
  237. bool is_subsequence_of(const String &p_string) const;
  238. bool is_subsequence_ofi(const String &p_string) const;
  239. bool is_quoted() const;
  240. Vector<String> bigrams() const;
  241. float similarity(const String &p_string) const;
  242. String format(const Variant &values, String placeholder = "{_}") const;
  243. String replace_first(const String &p_key, const String &p_with) const;
  244. String replace(const String &p_key, const String &p_with) const;
  245. String replace(const char *p_key, const char *p_with) const;
  246. String replacen(const String &p_key, const String &p_with) const;
  247. String repeat(int p_count) const;
  248. String insert(int p_at_pos, const String &p_string) const;
  249. String pad_decimals(int p_digits) const;
  250. String pad_zeros(int p_digits) const;
  251. String trim_prefix(const String &p_prefix) const;
  252. String trim_suffix(const String &p_suffix) const;
  253. String lpad(int min_length, const String &character = " ") const;
  254. String rpad(int min_length, const String &character = " ") const;
  255. String sprintf(const Array &values, bool *error) const;
  256. String quote(String quotechar = "\"") const;
  257. String unquote() const;
  258. static String num(double p_num, int p_decimals = -1);
  259. static String num_scientific(double p_num);
  260. static String num_real(double p_num, bool p_trailing = true);
  261. static String num_int64(int64_t p_num, int base = 10, bool capitalize_hex = false);
  262. static String num_uint64(uint64_t p_num, int base = 10, bool capitalize_hex = false);
  263. static String chr(char32_t p_char);
  264. static String md5(const uint8_t *p_md5);
  265. static String hex_encode_buffer(const uint8_t *p_buffer, int p_len);
  266. bool is_numeric() const;
  267. double to_float() const;
  268. int64_t hex_to_int() const;
  269. int64_t bin_to_int() const;
  270. int64_t to_int() const;
  271. static int64_t to_int(const char *p_str, int p_len = -1);
  272. static int64_t to_int(const wchar_t *p_str, int p_len = -1);
  273. static int64_t to_int(const char32_t *p_str, int p_len = -1, bool p_clamp = false);
  274. static double to_float(const char *p_str);
  275. static double to_float(const wchar_t *p_str, const wchar_t **r_end = nullptr);
  276. static double to_float(const char32_t *p_str, const char32_t **r_end = nullptr);
  277. String capitalize() const;
  278. String camelcase_to_underscore(bool lowercase = true) const;
  279. String get_with_code_lines() const;
  280. int get_slice_count(String p_splitter) const;
  281. String get_slice(String p_splitter, int p_slice) const;
  282. String get_slicec(char32_t p_splitter, int p_slice) const;
  283. Vector<String> split(const String &p_splitter, bool p_allow_empty = true, int p_maxsplit = 0) const;
  284. Vector<String> rsplit(const String &p_splitter, bool p_allow_empty = true, int p_maxsplit = 0) const;
  285. Vector<String> split_spaces() const;
  286. Vector<float> split_floats(const String &p_splitter, bool p_allow_empty = true) const;
  287. Vector<float> split_floats_mk(const Vector<String> &p_splitters, bool p_allow_empty = true) const;
  288. Vector<int> split_ints(const String &p_splitter, bool p_allow_empty = true) const;
  289. Vector<int> split_ints_mk(const Vector<String> &p_splitters, bool p_allow_empty = true) const;
  290. String join(Vector<String> parts) const;
  291. static char32_t char_uppercase(char32_t p_char);
  292. static char32_t char_lowercase(char32_t p_char);
  293. String to_upper() const;
  294. String to_lower() const;
  295. int count(const String &p_string, int p_from = 0, int p_to = 0) const;
  296. int countn(const String &p_string, int p_from = 0, int p_to = 0) const;
  297. String left(int p_pos) const;
  298. String right(int p_pos) const;
  299. String dedent() const;
  300. String strip_edges(bool left = true, bool right = true) const;
  301. String strip_escapes() const;
  302. String lstrip(const String &p_chars) const;
  303. String rstrip(const String &p_chars) const;
  304. String get_extension() const;
  305. String get_basename() const;
  306. String plus_file(const String &p_file) const;
  307. char32_t unicode_at(int p_idx) const;
  308. void erase(int p_pos, int p_chars);
  309. CharString ascii(bool p_allow_extended = false) const;
  310. CharString utf8() const;
  311. bool parse_utf8(const char *p_utf8, int p_len = -1); //return true on error
  312. static String utf8(const char *p_utf8, int p_len = -1);
  313. Char16String utf16() const;
  314. bool parse_utf16(const char16_t *p_utf16, int p_len = -1); //return true on error
  315. static String utf16(const char16_t *p_utf16, int p_len = -1);
  316. static uint32_t hash(const char32_t *p_cstr, int p_len); /* hash the string */
  317. static uint32_t hash(const char32_t *p_cstr); /* hash the string */
  318. static uint32_t hash(const wchar_t *p_cstr, int p_len); /* hash the string */
  319. static uint32_t hash(const wchar_t *p_cstr); /* hash the string */
  320. static uint32_t hash(const char *p_cstr, int p_len); /* hash the string */
  321. static uint32_t hash(const char *p_cstr); /* hash the string */
  322. uint32_t hash() const; /* hash the string */
  323. uint64_t hash64() const; /* hash the string */
  324. String md5_text() const;
  325. String sha1_text() const;
  326. String sha256_text() const;
  327. Vector<uint8_t> md5_buffer() const;
  328. Vector<uint8_t> sha1_buffer() const;
  329. Vector<uint8_t> sha256_buffer() const;
  330. _FORCE_INLINE_ bool is_empty() const { return length() == 0; }
  331. // path functions
  332. bool is_absolute_path() const;
  333. bool is_relative_path() const;
  334. bool is_resource_file() const;
  335. String path_to(const String &p_path) const;
  336. String path_to_file(const String &p_path) const;
  337. String get_base_dir() const;
  338. String get_file() const;
  339. static String humanize_size(uint64_t p_size);
  340. String simplify_path() const;
  341. String xml_escape(bool p_escape_quotes = false) const;
  342. String xml_unescape() const;
  343. String uri_encode() const;
  344. String uri_decode() const;
  345. String c_escape() const;
  346. String c_escape_multiline() const;
  347. String c_unescape() const;
  348. String json_escape() const;
  349. String word_wrap(int p_chars_per_line) const;
  350. Error parse_url(String &r_scheme, String &r_host, int &r_port, String &r_path) const;
  351. String property_name_encode() const;
  352. // node functions
  353. static const String invalid_node_name_characters;
  354. String validate_node_name() const;
  355. bool is_valid_identifier() const;
  356. bool is_valid_int() const;
  357. bool is_valid_float() const;
  358. bool is_valid_hex_number(bool p_with_prefix) const;
  359. bool is_valid_html_color() const;
  360. bool is_valid_ip_address() const;
  361. bool is_valid_filename() const;
  362. /**
  363. * The constructors must not depend on other overloads
  364. */
  365. _FORCE_INLINE_ String() {}
  366. _FORCE_INLINE_ String(const String &p_str) { _cowdata._ref(p_str._cowdata); }
  367. String &operator=(const String &p_str) {
  368. _cowdata._ref(p_str._cowdata);
  369. return *this;
  370. }
  371. Vector<uint8_t> to_ascii_buffer() const;
  372. Vector<uint8_t> to_utf8_buffer() const;
  373. Vector<uint8_t> to_utf16_buffer() const;
  374. Vector<uint8_t> to_utf32_buffer() const;
  375. String(const char *p_str);
  376. String(const wchar_t *p_str);
  377. String(const char32_t *p_str);
  378. String(const char *p_str, int p_clip_to_len);
  379. String(const wchar_t *p_str, int p_clip_to_len);
  380. String(const char32_t *p_str, int p_clip_to_len);
  381. String(const StrRange &p_range);
  382. };
  383. bool operator==(const char *p_chr, const String &p_str);
  384. bool operator==(const wchar_t *p_chr, const String &p_str);
  385. bool operator!=(const char *p_chr, const String &p_str);
  386. bool operator!=(const wchar_t *p_chr, const String &p_str);
  387. String operator+(const char *p_chr, const String &p_str);
  388. String operator+(const wchar_t *p_chr, const String &p_str);
  389. String operator+(char32_t p_chr, const String &p_str);
  390. String itos(int64_t p_val);
  391. String uitos(uint64_t p_val);
  392. String rtos(double p_val);
  393. String rtoss(double p_val); //scientific version
  394. struct NoCaseComparator {
  395. bool operator()(const String &p_a, const String &p_b) const {
  396. return p_a.nocasecmp_to(p_b) < 0;
  397. }
  398. };
  399. struct NaturalNoCaseComparator {
  400. bool operator()(const String &p_a, const String &p_b) const {
  401. return p_a.naturalnocasecmp_to(p_b) < 0;
  402. }
  403. };
  404. template <typename L, typename R>
  405. _FORCE_INLINE_ bool is_str_less(const L *l_ptr, const R *r_ptr) {
  406. while (true) {
  407. const char32_t l = *l_ptr;
  408. const char32_t r = *r_ptr;
  409. if (l == 0 && r == 0) {
  410. return false;
  411. } else if (l == 0) {
  412. return true;
  413. } else if (r == 0) {
  414. return false;
  415. } else if (l < r) {
  416. return true;
  417. } else if (l > r) {
  418. return false;
  419. }
  420. l_ptr++;
  421. r_ptr++;
  422. }
  423. }
  424. /* end of namespace */
  425. // Tool translate (TTR and variants) for the editor UI,
  426. // and doc translate for the class reference (DTR).
  427. #ifdef TOOLS_ENABLED
  428. // Gets parsed.
  429. String TTR(const String &p_text, const String &p_context = "");
  430. String TTRN(const String &p_text, const String &p_text_plural, int p_n, const String &p_context = "");
  431. String DTR(const String &p_text, const String &p_context = "");
  432. String DTRN(const String &p_text, const String &p_text_plural, int p_n, const String &p_context = "");
  433. // Use for C strings.
  434. #define TTRC(m_value) (m_value)
  435. // Use to avoid parsing (for use later with C strings).
  436. #define TTRGET(m_value) TTR(m_value)
  437. #else
  438. #define TTR(m_value) String()
  439. #define TTRN(m_value) String()
  440. #define DTR(m_value) String()
  441. #define DTRN(m_value) String()
  442. #define TTRC(m_value) (m_value)
  443. #define TTRGET(m_value) (m_value)
  444. #endif
  445. // Runtime translate for the public node API.
  446. String RTR(const String &p_text, const String &p_context = "");
  447. String RTRN(const String &p_text, const String &p_text_plural, int p_n, const String &p_context = "");
  448. bool is_symbol(char32_t c);
  449. bool select_word(const String &p_s, int p_col, int &r_beg, int &r_end);
  450. _FORCE_INLINE_ void sarray_add_str(Vector<String> &arr) {
  451. }
  452. _FORCE_INLINE_ void sarray_add_str(Vector<String> &arr, const String &p_str) {
  453. arr.push_back(p_str);
  454. }
  455. template <class... P>
  456. _FORCE_INLINE_ void sarray_add_str(Vector<String> &arr, const String &p_str, P... p_args) {
  457. arr.push_back(p_str);
  458. sarray_add_str(arr, p_args...);
  459. }
  460. template <class... P>
  461. _FORCE_INLINE_ Vector<String> sarray(P... p_args) {
  462. Vector<String> arr;
  463. sarray_add_str(arr, p_args...);
  464. return arr;
  465. }
  466. #endif // USTRING_GODOT_H