1 /*************************************************************************/
2 /* string.cpp */
3 /*************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
9 /* Copyright (c) 2014-2020 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
31 #include "gdnative/string.h"
32
33 #include "core/string_name.h"
34 #include "core/ustring.h"
35 #include "core/variant.h"
36
37 #include <string.h>
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 static_assert(sizeof(godot_char_string) == sizeof(CharString), "CharString size mismatch");
44 static_assert(sizeof(godot_string) == sizeof(String), "String size mismatch");
45 static_assert(sizeof(godot_char_type) == sizeof(CharType), "CharType size mismatch");
46
godot_char_string_length(const godot_char_string * p_cs)47 godot_int GDAPI godot_char_string_length(const godot_char_string *p_cs) {
48 const CharString *cs = (const CharString *)p_cs;
49
50 return cs->length();
51 }
52
godot_char_string_get_data(const godot_char_string * p_cs)53 const char GDAPI *godot_char_string_get_data(const godot_char_string *p_cs) {
54 const CharString *cs = (const CharString *)p_cs;
55
56 return cs->get_data();
57 }
58
godot_char_string_destroy(godot_char_string * p_cs)59 void GDAPI godot_char_string_destroy(godot_char_string *p_cs) {
60 CharString *cs = (CharString *)p_cs;
61
62 cs->~CharString();
63 }
64
godot_string_new(godot_string * r_dest)65 void GDAPI godot_string_new(godot_string *r_dest) {
66 String *dest = (String *)r_dest;
67 memnew_placement(dest, String);
68 }
69
godot_string_new_copy(godot_string * r_dest,const godot_string * p_src)70 void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src) {
71 String *dest = (String *)r_dest;
72 const String *src = (const String *)p_src;
73 memnew_placement(dest, String(*src));
74 }
75
godot_string_new_with_wide_string(godot_string * r_dest,const wchar_t * p_contents,const int p_size)76 void GDAPI godot_string_new_with_wide_string(godot_string *r_dest, const wchar_t *p_contents, const int p_size) {
77 String *dest = (String *)r_dest;
78 memnew_placement(dest, String(p_contents, p_size));
79 }
80
godot_string_operator_index(godot_string * p_self,const godot_int p_idx)81 const wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx) {
82 String *self = (String *)p_self;
83 return &(self->operator[](p_idx));
84 }
85
godot_string_operator_index_const(const godot_string * p_self,const godot_int p_idx)86 wchar_t GDAPI godot_string_operator_index_const(const godot_string *p_self, const godot_int p_idx) {
87 const String *self = (const String *)p_self;
88 return self->operator[](p_idx);
89 }
90
godot_string_wide_str(const godot_string * p_self)91 const wchar_t GDAPI *godot_string_wide_str(const godot_string *p_self) {
92 const String *self = (const String *)p_self;
93 return self->c_str();
94 }
95
godot_string_operator_equal(const godot_string * p_self,const godot_string * p_b)96 godot_bool GDAPI godot_string_operator_equal(const godot_string *p_self, const godot_string *p_b) {
97 const String *self = (const String *)p_self;
98 const String *b = (const String *)p_b;
99 return *self == *b;
100 }
101
godot_string_operator_less(const godot_string * p_self,const godot_string * p_b)102 godot_bool GDAPI godot_string_operator_less(const godot_string *p_self, const godot_string *p_b) {
103 const String *self = (const String *)p_self;
104 const String *b = (const String *)p_b;
105 return *self < *b;
106 }
107
godot_string_operator_plus(const godot_string * p_self,const godot_string * p_b)108 godot_string GDAPI godot_string_operator_plus(const godot_string *p_self, const godot_string *p_b) {
109 godot_string ret;
110 const String *self = (const String *)p_self;
111 const String *b = (const String *)p_b;
112 memnew_placement(&ret, String(*self + *b));
113 return ret;
114 }
115
godot_string_destroy(godot_string * p_self)116 void GDAPI godot_string_destroy(godot_string *p_self) {
117 String *self = (String *)p_self;
118 self->~String();
119 }
120
121 /* Standard size stuff */
122
godot_string_length(const godot_string * p_self)123 godot_int GDAPI godot_string_length(const godot_string *p_self) {
124 const String *self = (const String *)p_self;
125
126 return self->length();
127 }
128
129 /* Helpers */
130
godot_string_casecmp_to(const godot_string * p_self,const godot_string * p_str)131 signed char GDAPI godot_string_casecmp_to(const godot_string *p_self, const godot_string *p_str) {
132 const String *self = (const String *)p_self;
133 const String *str = (const String *)p_str;
134
135 return self->casecmp_to(*str);
136 }
137
godot_string_nocasecmp_to(const godot_string * p_self,const godot_string * p_str)138 signed char GDAPI godot_string_nocasecmp_to(const godot_string *p_self, const godot_string *p_str) {
139 const String *self = (const String *)p_self;
140 const String *str = (const String *)p_str;
141
142 return self->nocasecmp_to(*str);
143 }
godot_string_naturalnocasecmp_to(const godot_string * p_self,const godot_string * p_str)144 signed char GDAPI godot_string_naturalnocasecmp_to(const godot_string *p_self, const godot_string *p_str) {
145 const String *self = (const String *)p_self;
146 const String *str = (const String *)p_str;
147
148 return self->naturalnocasecmp_to(*str);
149 }
150
godot_string_begins_with(const godot_string * p_self,const godot_string * p_string)151 godot_bool GDAPI godot_string_begins_with(const godot_string *p_self, const godot_string *p_string) {
152 const String *self = (const String *)p_self;
153 const String *string = (const String *)p_string;
154
155 return self->begins_with(*string);
156 }
157
godot_string_begins_with_char_array(const godot_string * p_self,const char * p_char_array)158 godot_bool GDAPI godot_string_begins_with_char_array(const godot_string *p_self, const char *p_char_array) {
159 const String *self = (const String *)p_self;
160
161 return self->begins_with(p_char_array);
162 }
163
godot_string_bigrams(const godot_string * p_self)164 godot_array GDAPI godot_string_bigrams(const godot_string *p_self) {
165 const String *self = (const String *)p_self;
166 Vector<String> return_value = self->bigrams();
167
168 godot_array result;
169 memnew_placement(&result, Array);
170 Array *proxy = (Array *)&result;
171 proxy->resize(return_value.size());
172 for (int i = 0; i < return_value.size(); i++) {
173 (*proxy)[i] = return_value[i];
174 }
175
176 return result;
177 };
178
godot_string_chr(wchar_t p_character)179 godot_string GDAPI godot_string_chr(wchar_t p_character) {
180 godot_string result;
181 memnew_placement(&result, String(String::chr(p_character)));
182
183 return result;
184 }
185
godot_string_ends_with(const godot_string * p_self,const godot_string * p_string)186 godot_bool GDAPI godot_string_ends_with(const godot_string *p_self, const godot_string *p_string) {
187 const String *self = (const String *)p_self;
188 const String *string = (const String *)p_string;
189
190 return self->ends_with(*string);
191 }
192
godot_string_count(const godot_string * p_self,godot_string p_what,godot_int p_from,godot_int p_to)193 godot_int GDAPI godot_string_count(const godot_string *p_self, godot_string p_what, godot_int p_from, godot_int p_to) {
194 const String *self = (const String *)p_self;
195 String *what = (String *)&p_what;
196
197 return self->count(*what, p_from, p_to);
198 }
199
godot_string_countn(const godot_string * p_self,godot_string p_what,godot_int p_from,godot_int p_to)200 godot_int GDAPI godot_string_countn(const godot_string *p_self, godot_string p_what, godot_int p_from, godot_int p_to) {
201 const String *self = (const String *)p_self;
202 String *what = (String *)&p_what;
203
204 return self->countn(*what, p_from, p_to);
205 }
206
godot_string_find(const godot_string * p_self,godot_string p_what)207 godot_int GDAPI godot_string_find(const godot_string *p_self, godot_string p_what) {
208 const String *self = (const String *)p_self;
209 String *what = (String *)&p_what;
210
211 return self->find(*what);
212 }
213
godot_string_find_from(const godot_string * p_self,godot_string p_what,godot_int p_from)214 godot_int GDAPI godot_string_find_from(const godot_string *p_self, godot_string p_what, godot_int p_from) {
215 const String *self = (const String *)p_self;
216 String *what = (String *)&p_what;
217
218 return self->find(*what, p_from);
219 }
220
godot_string_findmk(const godot_string * p_self,const godot_array * p_keys)221 godot_int GDAPI godot_string_findmk(const godot_string *p_self, const godot_array *p_keys) {
222 const String *self = (const String *)p_self;
223
224 Vector<String> keys;
225 Array *keys_proxy = (Array *)p_keys;
226 keys.resize(keys_proxy->size());
227 for (int i = 0; i < keys_proxy->size(); i++) {
228 keys.write[i] = (*keys_proxy)[i];
229 }
230
231 return self->findmk(keys);
232 }
233
godot_string_findmk_from(const godot_string * p_self,const godot_array * p_keys,godot_int p_from)234 godot_int GDAPI godot_string_findmk_from(const godot_string *p_self, const godot_array *p_keys, godot_int p_from) {
235 const String *self = (const String *)p_self;
236
237 Vector<String> keys;
238 Array *keys_proxy = (Array *)p_keys;
239 keys.resize(keys_proxy->size());
240 for (int i = 0; i < keys_proxy->size(); i++) {
241 keys.write[i] = (*keys_proxy)[i];
242 }
243
244 return self->findmk(keys, p_from);
245 }
246
godot_string_findmk_from_in_place(const godot_string * p_self,const godot_array * p_keys,godot_int p_from,godot_int * r_key)247 godot_int GDAPI godot_string_findmk_from_in_place(const godot_string *p_self, const godot_array *p_keys, godot_int p_from, godot_int *r_key) {
248 const String *self = (const String *)p_self;
249
250 Vector<String> keys;
251 Array *keys_proxy = (Array *)p_keys;
252 keys.resize(keys_proxy->size());
253 for (int i = 0; i < keys_proxy->size(); i++) {
254 keys.write[i] = (*keys_proxy)[i];
255 }
256
257 return self->findmk(keys, p_from, r_key);
258 }
259
godot_string_findn(const godot_string * p_self,godot_string p_what)260 godot_int GDAPI godot_string_findn(const godot_string *p_self, godot_string p_what) {
261 const String *self = (const String *)p_self;
262 String *what = (String *)&p_what;
263
264 return self->findn(*what);
265 }
266
godot_string_findn_from(const godot_string * p_self,godot_string p_what,godot_int p_from)267 godot_int GDAPI godot_string_findn_from(const godot_string *p_self, godot_string p_what, godot_int p_from) {
268 const String *self = (const String *)p_self;
269 String *what = (String *)&p_what;
270
271 return self->findn(*what, p_from);
272 }
273
godot_string_find_last(const godot_string * p_self,godot_string p_what)274 godot_int GDAPI godot_string_find_last(const godot_string *p_self, godot_string p_what) {
275 const String *self = (const String *)p_self;
276 String *what = (String *)&p_what;
277
278 return self->find_last(*what);
279 }
280
godot_string_format(const godot_string * p_self,const godot_variant * p_values)281 godot_string GDAPI godot_string_format(const godot_string *p_self, const godot_variant *p_values) {
282 const String *self = (const String *)p_self;
283 const Variant *values = (const Variant *)p_values;
284 godot_string result;
285 memnew_placement(&result, String(self->format(*values)));
286
287 return result;
288 }
289
godot_string_format_with_custom_placeholder(const godot_string * p_self,const godot_variant * p_values,const char * p_placeholder)290 godot_string GDAPI godot_string_format_with_custom_placeholder(const godot_string *p_self, const godot_variant *p_values, const char *p_placeholder) {
291 const String *self = (const String *)p_self;
292 const Variant *values = (const Variant *)p_values;
293 String placeholder = String(p_placeholder);
294 godot_string result;
295 memnew_placement(&result, String(self->format(*values, placeholder)));
296
297 return result;
298 }
299
godot_string_hex_encode_buffer(const uint8_t * p_buffer,godot_int p_len)300 godot_string GDAPI godot_string_hex_encode_buffer(const uint8_t *p_buffer, godot_int p_len) {
301 godot_string result;
302 memnew_placement(&result, String(String::hex_encode_buffer(p_buffer, p_len)));
303
304 return result;
305 }
306
godot_string_hex_to_int(const godot_string * p_self)307 godot_int GDAPI godot_string_hex_to_int(const godot_string *p_self) {
308 const String *self = (const String *)p_self;
309
310 return self->hex_to_int();
311 }
312
godot_string_hex_to_int_without_prefix(const godot_string * p_self)313 godot_int GDAPI godot_string_hex_to_int_without_prefix(const godot_string *p_self) {
314 const String *self = (const String *)p_self;
315
316 return self->hex_to_int(true);
317 }
318
godot_string_insert(const godot_string * p_self,godot_int p_at_pos,godot_string p_string)319 godot_string GDAPI godot_string_insert(const godot_string *p_self, godot_int p_at_pos, godot_string p_string) {
320 const String *self = (const String *)p_self;
321 String *content = (String *)&p_string;
322 godot_string result;
323 memnew_placement(&result, String(self->insert(p_at_pos, *content)));
324
325 return result;
326 }
327
godot_string_is_numeric(const godot_string * p_self)328 godot_bool GDAPI godot_string_is_numeric(const godot_string *p_self) {
329 const String *self = (const String *)p_self;
330
331 return self->is_numeric();
332 }
333
godot_string_is_subsequence_of(const godot_string * p_self,const godot_string * p_string)334 godot_bool GDAPI godot_string_is_subsequence_of(const godot_string *p_self, const godot_string *p_string) {
335 const String *self = (const String *)p_self;
336 const String *string = (const String *)p_string;
337
338 return self->is_subsequence_of(*string);
339 }
340
godot_string_is_subsequence_ofi(const godot_string * p_self,const godot_string * p_string)341 godot_bool GDAPI godot_string_is_subsequence_ofi(const godot_string *p_self, const godot_string *p_string) {
342 const String *self = (const String *)p_self;
343 const String *string = (const String *)p_string;
344
345 return self->is_subsequence_ofi(*string);
346 }
347
godot_string_lpad(const godot_string * p_self,godot_int p_min_length)348 godot_string GDAPI godot_string_lpad(const godot_string *p_self, godot_int p_min_length) {
349 const String *self = (const String *)p_self;
350 godot_string result;
351 memnew_placement(&result, String(self->lpad(p_min_length)));
352
353 return result;
354 }
355
godot_string_lpad_with_custom_character(const godot_string * p_self,godot_int p_min_length,const godot_string * p_character)356 godot_string GDAPI godot_string_lpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character) {
357 const String *self = (const String *)p_self;
358 const String *character = (const String *)p_character;
359 godot_string result;
360 memnew_placement(&result, String(self->lpad(p_min_length, *character)));
361
362 return result;
363 }
364
godot_string_match(const godot_string * p_self,const godot_string * p_wildcard)365 godot_bool GDAPI godot_string_match(const godot_string *p_self, const godot_string *p_wildcard) {
366 const String *self = (const String *)p_self;
367 const String *wildcard = (const String *)p_wildcard;
368
369 return self->match(*wildcard);
370 }
371
godot_string_matchn(const godot_string * p_self,const godot_string * p_wildcard)372 godot_bool GDAPI godot_string_matchn(const godot_string *p_self, const godot_string *p_wildcard) {
373 const String *self = (const String *)p_self;
374 const String *wildcard = (const String *)p_wildcard;
375
376 return self->matchn(*wildcard);
377 }
378
godot_string_md5(const uint8_t * p_md5)379 godot_string GDAPI godot_string_md5(const uint8_t *p_md5) {
380 godot_string result;
381 memnew_placement(&result, String(String::md5(p_md5)));
382
383 return result;
384 }
385
godot_string_num(double p_num)386 godot_string GDAPI godot_string_num(double p_num) {
387 godot_string result;
388 memnew_placement(&result, String(String::num(p_num)));
389
390 return result;
391 }
392
godot_string_num_int64(int64_t p_num,godot_int p_base)393 godot_string GDAPI godot_string_num_int64(int64_t p_num, godot_int p_base) {
394 godot_string result;
395 memnew_placement(&result, String(String::num_int64(p_num, p_base)));
396
397 return result;
398 }
399
godot_string_num_int64_capitalized(int64_t p_num,godot_int p_base,godot_bool p_capitalize_hex)400 godot_string GDAPI godot_string_num_int64_capitalized(int64_t p_num, godot_int p_base, godot_bool p_capitalize_hex) {
401 godot_string result;
402 memnew_placement(&result, String(String::num_int64(p_num, p_base, true)));
403
404 return result;
405 }
406
godot_string_num_real(double p_num)407 godot_string GDAPI godot_string_num_real(double p_num) {
408 godot_string result;
409 memnew_placement(&result, String(String::num_real(p_num)));
410
411 return result;
412 }
413
godot_string_num_scientific(double p_num)414 godot_string GDAPI godot_string_num_scientific(double p_num) {
415 godot_string result;
416 memnew_placement(&result, String(String::num_scientific(p_num)));
417
418 return result;
419 }
420
godot_string_num_with_decimals(double p_num,godot_int p_decimals)421 godot_string GDAPI godot_string_num_with_decimals(double p_num, godot_int p_decimals) {
422 godot_string result;
423 memnew_placement(&result, String(String::num(p_num, p_decimals)));
424
425 return result;
426 }
427
godot_string_pad_decimals(const godot_string * p_self,godot_int p_digits)428 godot_string GDAPI godot_string_pad_decimals(const godot_string *p_self, godot_int p_digits) {
429 const String *self = (const String *)p_self;
430 godot_string result;
431 memnew_placement(&result, String(self->pad_decimals(p_digits)));
432
433 return result;
434 }
435
godot_string_pad_zeros(const godot_string * p_self,godot_int p_digits)436 godot_string GDAPI godot_string_pad_zeros(const godot_string *p_self, godot_int p_digits) {
437 const String *self = (const String *)p_self;
438 godot_string result;
439 memnew_placement(&result, String(self->pad_zeros(p_digits)));
440
441 return result;
442 }
443
godot_string_replace(const godot_string * p_self,godot_string p_key,godot_string p_with)444 godot_string GDAPI godot_string_replace(const godot_string *p_self, godot_string p_key, godot_string p_with) {
445 const String *self = (const String *)p_self;
446 String *key = (String *)&p_key;
447 String *with = (String *)&p_with;
448 godot_string result;
449 memnew_placement(&result, String(self->replace(*key, *with)));
450
451 return result;
452 }
453
godot_string_replacen(const godot_string * p_self,godot_string p_key,godot_string p_with)454 godot_string GDAPI godot_string_replacen(const godot_string *p_self, godot_string p_key, godot_string p_with) {
455 const String *self = (const String *)p_self;
456 String *key = (String *)&p_key;
457 String *with = (String *)&p_with;
458 godot_string result;
459 memnew_placement(&result, String(self->replacen(*key, *with)));
460
461 return result;
462 }
463
godot_string_rfind(const godot_string * p_self,godot_string p_what)464 godot_int GDAPI godot_string_rfind(const godot_string *p_self, godot_string p_what) {
465 const String *self = (const String *)p_self;
466 String *what = (String *)&p_what;
467
468 return self->rfind(*what);
469 }
470
godot_string_rfindn(const godot_string * p_self,godot_string p_what)471 godot_int GDAPI godot_string_rfindn(const godot_string *p_self, godot_string p_what) {
472 const String *self = (const String *)p_self;
473 String *what = (String *)&p_what;
474
475 return self->rfindn(*what);
476 }
477
godot_string_rfind_from(const godot_string * p_self,godot_string p_what,godot_int p_from)478 godot_int GDAPI godot_string_rfind_from(const godot_string *p_self, godot_string p_what, godot_int p_from) {
479 const String *self = (const String *)p_self;
480 String *what = (String *)&p_what;
481
482 return self->rfind(*what, p_from);
483 }
484
godot_string_rfindn_from(const godot_string * p_self,godot_string p_what,godot_int p_from)485 godot_int GDAPI godot_string_rfindn_from(const godot_string *p_self, godot_string p_what, godot_int p_from) {
486 const String *self = (const String *)p_self;
487 String *what = (String *)&p_what;
488
489 return self->rfindn(*what, p_from);
490 }
491
godot_string_replace_first(const godot_string * p_self,godot_string p_key,godot_string p_with)492 godot_string GDAPI godot_string_replace_first(const godot_string *p_self, godot_string p_key, godot_string p_with) {
493 const String *self = (const String *)p_self;
494 String *key = (String *)&p_key;
495 String *with = (String *)&p_with;
496 godot_string result;
497 memnew_placement(&result, String(self->replace_first(*key, *with)));
498
499 return result;
500 }
501
godot_string_rpad(const godot_string * p_self,godot_int p_min_length)502 godot_string GDAPI godot_string_rpad(const godot_string *p_self, godot_int p_min_length) {
503 const String *self = (const String *)p_self;
504 godot_string result;
505 memnew_placement(&result, String(self->rpad(p_min_length)));
506
507 return result;
508 }
509
godot_string_rpad_with_custom_character(const godot_string * p_self,godot_int p_min_length,const godot_string * p_character)510 godot_string GDAPI godot_string_rpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character) {
511 const String *self = (const String *)p_self;
512 const String *character = (const String *)p_character;
513 godot_string result;
514 memnew_placement(&result, String(self->rpad(p_min_length, *character)));
515
516 return result;
517 }
518
godot_string_similarity(const godot_string * p_self,const godot_string * p_string)519 godot_real GDAPI godot_string_similarity(const godot_string *p_self, const godot_string *p_string) {
520 const String *self = (const String *)p_self;
521 const String *string = (const String *)p_string;
522
523 return self->similarity(*string);
524 }
525
godot_string_sprintf(const godot_string * p_self,const godot_array * p_values,godot_bool * p_error)526 godot_string GDAPI godot_string_sprintf(const godot_string *p_self, const godot_array *p_values, godot_bool *p_error) {
527 const String *self = (const String *)p_self;
528 const Array *values = (const Array *)p_values;
529
530 godot_string result;
531 String return_value = self->sprintf(*values, p_error);
532 memnew_placement(&result, String(return_value));
533
534 return result;
535 }
536
godot_string_substr(const godot_string * p_self,godot_int p_from,godot_int p_chars)537 godot_string GDAPI godot_string_substr(const godot_string *p_self, godot_int p_from, godot_int p_chars) {
538 const String *self = (const String *)p_self;
539 godot_string result;
540 memnew_placement(&result, String(self->substr(p_from, p_chars)));
541
542 return result;
543 }
544
godot_string_to_double(const godot_string * p_self)545 double GDAPI godot_string_to_double(const godot_string *p_self) {
546 const String *self = (const String *)p_self;
547
548 return self->to_double();
549 }
550
godot_string_to_float(const godot_string * p_self)551 godot_real GDAPI godot_string_to_float(const godot_string *p_self) {
552 const String *self = (const String *)p_self;
553
554 return self->to_float();
555 }
556
godot_string_to_int(const godot_string * p_self)557 godot_int GDAPI godot_string_to_int(const godot_string *p_self) {
558 const String *self = (const String *)p_self;
559
560 return self->to_int();
561 }
562
godot_string_capitalize(const godot_string * p_self)563 godot_string GDAPI godot_string_capitalize(const godot_string *p_self) {
564 const String *self = (const String *)p_self;
565 godot_string result;
566 memnew_placement(&result, String(self->capitalize()));
567
568 return result;
569 }
570
godot_string_camelcase_to_underscore(const godot_string * p_self)571 godot_string GDAPI godot_string_camelcase_to_underscore(const godot_string *p_self) {
572 const String *self = (const String *)p_self;
573 godot_string result;
574 memnew_placement(&result, String(self->camelcase_to_underscore(false)));
575
576 return result;
577 }
578
godot_string_camelcase_to_underscore_lowercased(const godot_string * p_self)579 godot_string GDAPI godot_string_camelcase_to_underscore_lowercased(const godot_string *p_self) {
580 const String *self = (const String *)p_self;
581 godot_string result;
582 memnew_placement(&result, String(self->camelcase_to_underscore()));
583
584 return result;
585 }
586
godot_string_char_to_double(const char * p_what)587 double GDAPI godot_string_char_to_double(const char *p_what) {
588 return String::to_double(p_what);
589 }
590
godot_string_char_to_int(const char * p_what)591 godot_int GDAPI godot_string_char_to_int(const char *p_what) {
592 return String::to_int(p_what);
593 }
594
godot_string_wchar_to_int(const wchar_t * p_str)595 int64_t GDAPI godot_string_wchar_to_int(const wchar_t *p_str) {
596 return String::to_int(p_str);
597 }
598
godot_string_char_to_int_with_len(const char * p_what,godot_int p_len)599 godot_int GDAPI godot_string_char_to_int_with_len(const char *p_what, godot_int p_len) {
600 return String::to_int(p_what, p_len);
601 }
602
godot_string_char_to_int64_with_len(const wchar_t * p_str,int p_len)603 int64_t GDAPI godot_string_char_to_int64_with_len(const wchar_t *p_str, int p_len) {
604 return String::to_int(p_str, p_len);
605 }
606
godot_string_hex_to_int64(const godot_string * p_self)607 int64_t GDAPI godot_string_hex_to_int64(const godot_string *p_self) {
608 const String *self = (const String *)p_self;
609
610 return self->hex_to_int64(false);
611 }
612
godot_string_hex_to_int64_with_prefix(const godot_string * p_self)613 int64_t GDAPI godot_string_hex_to_int64_with_prefix(const godot_string *p_self) {
614 const String *self = (const String *)p_self;
615
616 return self->hex_to_int64();
617 }
618
godot_string_to_int64(const godot_string * p_self)619 int64_t GDAPI godot_string_to_int64(const godot_string *p_self) {
620 const String *self = (const String *)p_self;
621
622 return self->to_int64();
623 }
624
godot_string_unicode_char_to_double(const wchar_t * p_str,const wchar_t ** r_end)625 double GDAPI godot_string_unicode_char_to_double(const wchar_t *p_str, const wchar_t **r_end) {
626 return String::to_double(p_str, r_end);
627 }
628
godot_string_get_slice(const godot_string * p_self,godot_string p_splitter,godot_int p_slice)629 godot_string GDAPI godot_string_get_slice(const godot_string *p_self, godot_string p_splitter, godot_int p_slice) {
630 const String *self = (const String *)p_self;
631 String *splitter = (String *)&p_splitter;
632 godot_string result;
633 memnew_placement(&result, String(self->get_slice(*splitter, p_slice)));
634
635 return result;
636 }
637
godot_string_get_slicec(const godot_string * p_self,wchar_t p_splitter,godot_int p_slice)638 godot_string GDAPI godot_string_get_slicec(const godot_string *p_self, wchar_t p_splitter, godot_int p_slice) {
639 const String *self = (const String *)p_self;
640 godot_string result;
641 memnew_placement(&result, String(self->get_slicec(p_splitter, p_slice)));
642
643 return result;
644 }
645
godot_string_split(const godot_string * p_self,const godot_string * p_splitter)646 godot_array GDAPI godot_string_split(const godot_string *p_self, const godot_string *p_splitter) {
647 const String *self = (const String *)p_self;
648 const String *splitter = (const String *)p_splitter;
649 godot_array result;
650 memnew_placement(&result, Array);
651 Array *proxy = (Array *)&result;
652 Vector<String> return_value = self->split(*splitter, false);
653
654 proxy->resize(return_value.size());
655 for (int i = 0; i < return_value.size(); i++) {
656 (*proxy)[i] = return_value[i];
657 }
658
659 return result;
660 }
661
godot_string_split_allow_empty(const godot_string * p_self,const godot_string * p_splitter)662 godot_array GDAPI godot_string_split_allow_empty(const godot_string *p_self, const godot_string *p_splitter) {
663 const String *self = (const String *)p_self;
664 const String *splitter = (const String *)p_splitter;
665 godot_array result;
666 memnew_placement(&result, Array);
667 Array *proxy = (Array *)&result;
668 Vector<String> return_value = self->split(*splitter);
669
670 proxy->resize(return_value.size());
671 for (int i = 0; i < return_value.size(); i++) {
672 (*proxy)[i] = return_value[i];
673 }
674
675 return result;
676 }
677
godot_string_split_floats(const godot_string * p_self,const godot_string * p_splitter)678 godot_array GDAPI godot_string_split_floats(const godot_string *p_self, const godot_string *p_splitter) {
679 const String *self = (const String *)p_self;
680 const String *splitter = (const String *)p_splitter;
681 godot_array result;
682 memnew_placement(&result, Array);
683 Array *proxy = (Array *)&result;
684 Vector<float> return_value = self->split_floats(*splitter, false);
685
686 proxy->resize(return_value.size());
687 for (int i = 0; i < return_value.size(); i++) {
688 (*proxy)[i] = return_value[i];
689 }
690
691 return result;
692 }
693
godot_string_split_floats_allows_empty(const godot_string * p_self,const godot_string * p_splitter)694 godot_array GDAPI godot_string_split_floats_allows_empty(const godot_string *p_self, const godot_string *p_splitter) {
695 const String *self = (const String *)p_self;
696 const String *splitter = (const String *)p_splitter;
697 godot_array result;
698 memnew_placement(&result, Array);
699 Array *proxy = (Array *)&result;
700 Vector<float> return_value = self->split_floats(*splitter);
701
702 proxy->resize(return_value.size());
703 for (int i = 0; i < return_value.size(); i++) {
704 (*proxy)[i] = return_value[i];
705 }
706
707 return result;
708 }
709
godot_string_split_floats_mk(const godot_string * p_self,const godot_array * p_splitters)710 godot_array GDAPI godot_string_split_floats_mk(const godot_string *p_self, const godot_array *p_splitters) {
711 const String *self = (const String *)p_self;
712
713 Vector<String> splitters;
714 Array *splitter_proxy = (Array *)p_splitters;
715 splitters.resize(splitter_proxy->size());
716 for (int i = 0; i < splitter_proxy->size(); i++) {
717 splitters.write[i] = (*splitter_proxy)[i];
718 }
719
720 godot_array result;
721 memnew_placement(&result, Array);
722 Array *proxy = (Array *)&result;
723 Vector<float> return_value = self->split_floats_mk(splitters, false);
724
725 proxy->resize(return_value.size());
726 for (int i = 0; i < return_value.size(); i++) {
727 (*proxy)[i] = return_value[i];
728 }
729
730 return result;
731 }
732
godot_string_split_floats_mk_allows_empty(const godot_string * p_self,const godot_array * p_splitters)733 godot_array GDAPI godot_string_split_floats_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters) {
734 const String *self = (const String *)p_self;
735
736 Vector<String> splitters;
737 Array *splitter_proxy = (Array *)p_splitters;
738 splitters.resize(splitter_proxy->size());
739 for (int i = 0; i < splitter_proxy->size(); i++) {
740 splitters.write[i] = (*splitter_proxy)[i];
741 }
742
743 godot_array result;
744 memnew_placement(&result, Array);
745 Array *proxy = (Array *)&result;
746 Vector<float> return_value = self->split_floats_mk(splitters);
747
748 proxy->resize(return_value.size());
749 for (int i = 0; i < return_value.size(); i++) {
750 (*proxy)[i] = return_value[i];
751 }
752
753 return result;
754 }
755
godot_string_split_ints(const godot_string * p_self,const godot_string * p_splitter)756 godot_array GDAPI godot_string_split_ints(const godot_string *p_self, const godot_string *p_splitter) {
757 const String *self = (const String *)p_self;
758 const String *splitter = (const String *)p_splitter;
759 godot_array result;
760 memnew_placement(&result, Array);
761 Array *proxy = (Array *)&result;
762 Vector<int> return_value = self->split_ints(*splitter, false);
763
764 proxy->resize(return_value.size());
765 for (int i = 0; i < return_value.size(); i++) {
766 (*proxy)[i] = return_value[i];
767 }
768
769 return result;
770 }
771
godot_string_split_ints_allows_empty(const godot_string * p_self,const godot_string * p_splitter)772 godot_array GDAPI godot_string_split_ints_allows_empty(const godot_string *p_self, const godot_string *p_splitter) {
773 const String *self = (const String *)p_self;
774 const String *splitter = (const String *)p_splitter;
775 godot_array result;
776 memnew_placement(&result, Array);
777 Array *proxy = (Array *)&result;
778 Vector<int> return_value = self->split_ints(*splitter);
779
780 proxy->resize(return_value.size());
781 for (int i = 0; i < return_value.size(); i++) {
782 (*proxy)[i] = return_value[i];
783 }
784
785 return result;
786 }
787
godot_string_split_ints_mk(const godot_string * p_self,const godot_array * p_splitters)788 godot_array GDAPI godot_string_split_ints_mk(const godot_string *p_self, const godot_array *p_splitters) {
789 const String *self = (const String *)p_self;
790
791 Vector<String> splitters;
792 Array *splitter_proxy = (Array *)p_splitters;
793 splitters.resize(splitter_proxy->size());
794 for (int i = 0; i < splitter_proxy->size(); i++) {
795 splitters.write[i] = (*splitter_proxy)[i];
796 }
797
798 godot_array result;
799 memnew_placement(&result, Array);
800 Array *proxy = (Array *)&result;
801 Vector<int> return_value = self->split_ints_mk(splitters, false);
802
803 proxy->resize(return_value.size());
804 for (int i = 0; i < return_value.size(); i++) {
805 (*proxy)[i] = return_value[i];
806 }
807
808 return result;
809 }
810
godot_string_split_ints_mk_allows_empty(const godot_string * p_self,const godot_array * p_splitters)811 godot_array GDAPI godot_string_split_ints_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters) {
812 const String *self = (const String *)p_self;
813
814 Vector<String> splitters;
815 Array *splitter_proxy = (Array *)p_splitters;
816 splitters.resize(splitter_proxy->size());
817 for (int i = 0; i < splitter_proxy->size(); i++) {
818 splitters.write[i] = (*splitter_proxy)[i];
819 }
820
821 godot_array result;
822 memnew_placement(&result, Array);
823 Array *proxy = (Array *)&result;
824 Vector<int> return_value = self->split_ints_mk(splitters);
825
826 proxy->resize(return_value.size());
827 for (int i = 0; i < return_value.size(); i++) {
828 (*proxy)[i] = return_value[i];
829 }
830
831 return result;
832 }
833
godot_string_split_spaces(const godot_string * p_self)834 godot_array GDAPI godot_string_split_spaces(const godot_string *p_self) {
835 const String *self = (const String *)p_self;
836 godot_array result;
837 memnew_placement(&result, Array);
838 Array *proxy = (Array *)&result;
839 Vector<String> return_value = self->split_spaces();
840
841 proxy->resize(return_value.size());
842 for (int i = 0; i < return_value.size(); i++) {
843 (*proxy)[i] = return_value[i];
844 }
845
846 return result;
847 }
848
godot_string_get_slice_count(const godot_string * p_self,godot_string p_splitter)849 godot_int GDAPI godot_string_get_slice_count(const godot_string *p_self, godot_string p_splitter) {
850 const String *self = (const String *)p_self;
851 String *splitter = (String *)&p_splitter;
852
853 return self->get_slice_count(*splitter);
854 }
855
godot_string_char_lowercase(wchar_t p_char)856 wchar_t GDAPI godot_string_char_lowercase(wchar_t p_char) {
857 return String::char_lowercase(p_char);
858 }
859
godot_string_char_uppercase(wchar_t p_char)860 wchar_t GDAPI godot_string_char_uppercase(wchar_t p_char) {
861 return String::char_uppercase(p_char);
862 }
863
godot_string_to_lower(const godot_string * p_self)864 godot_string GDAPI godot_string_to_lower(const godot_string *p_self) {
865 const String *self = (const String *)p_self;
866 godot_string result;
867 memnew_placement(&result, String(self->to_lower()));
868
869 return result;
870 }
871
godot_string_to_upper(const godot_string * p_self)872 godot_string GDAPI godot_string_to_upper(const godot_string *p_self) {
873 const String *self = (const String *)p_self;
874 godot_string result;
875 memnew_placement(&result, String(self->to_upper()));
876
877 return result;
878 }
879
godot_string_get_basename(const godot_string * p_self)880 godot_string GDAPI godot_string_get_basename(const godot_string *p_self) {
881 const String *self = (const String *)p_self;
882 godot_string result;
883 memnew_placement(&result, String(self->get_basename()));
884
885 return result;
886 }
887
godot_string_get_extension(const godot_string * p_self)888 godot_string GDAPI godot_string_get_extension(const godot_string *p_self) {
889 const String *self = (const String *)p_self;
890 godot_string result;
891 memnew_placement(&result, String(self->get_extension()));
892
893 return result;
894 }
895
godot_string_left(const godot_string * p_self,godot_int p_pos)896 godot_string GDAPI godot_string_left(const godot_string *p_self, godot_int p_pos) {
897 const String *self = (const String *)p_self;
898 godot_string result;
899 memnew_placement(&result, String(self->left(p_pos)));
900
901 return result;
902 }
903
godot_string_ord_at(const godot_string * p_self,godot_int p_idx)904 wchar_t GDAPI godot_string_ord_at(const godot_string *p_self, godot_int p_idx) {
905 const String *self = (const String *)p_self;
906
907 return self->ord_at(p_idx);
908 }
909
godot_string_plus_file(const godot_string * p_self,const godot_string * p_file)910 godot_string GDAPI godot_string_plus_file(const godot_string *p_self, const godot_string *p_file) {
911 const String *self = (const String *)p_self;
912 const String *file = (const String *)p_file;
913 godot_string result;
914 memnew_placement(&result, String(self->plus_file(*file)));
915
916 return result;
917 }
918
godot_string_right(const godot_string * p_self,godot_int p_pos)919 godot_string GDAPI godot_string_right(const godot_string *p_self, godot_int p_pos) {
920 const String *self = (const String *)p_self;
921 godot_string result;
922 memnew_placement(&result, String(self->right(p_pos)));
923
924 return result;
925 }
926
godot_string_strip_edges(const godot_string * p_self,godot_bool p_left,godot_bool p_right)927 godot_string GDAPI godot_string_strip_edges(const godot_string *p_self, godot_bool p_left, godot_bool p_right) {
928 const String *self = (const String *)p_self;
929 godot_string result;
930 memnew_placement(&result, String(self->strip_edges(p_left, p_right)));
931
932 return result;
933 }
934
godot_string_strip_escapes(const godot_string * p_self)935 godot_string GDAPI godot_string_strip_escapes(const godot_string *p_self) {
936 const String *self = (const String *)p_self;
937 godot_string result;
938 memnew_placement(&result, String(self->strip_escapes()));
939
940 return result;
941 }
942
godot_string_erase(godot_string * p_self,godot_int p_pos,godot_int p_chars)943 void GDAPI godot_string_erase(godot_string *p_self, godot_int p_pos, godot_int p_chars) {
944 String *self = (String *)p_self;
945
946 return self->erase(p_pos, p_chars);
947 }
948
godot_string_ascii(const godot_string * p_self)949 godot_char_string GDAPI godot_string_ascii(const godot_string *p_self) {
950 const String *self = (const String *)p_self;
951 godot_char_string result;
952
953 memnew_placement(&result, CharString(self->ascii()));
954
955 return result;
956 }
957
godot_string_ascii_extended(const godot_string * p_self)958 godot_char_string GDAPI godot_string_ascii_extended(const godot_string *p_self) {
959 const String *self = (const String *)p_self;
960
961 godot_char_string result;
962
963 memnew_placement(&result, CharString(self->ascii(true)));
964
965 return result;
966 }
967
godot_string_utf8(const godot_string * p_self)968 godot_char_string GDAPI godot_string_utf8(const godot_string *p_self) {
969 const String *self = (const String *)p_self;
970
971 godot_char_string result;
972
973 memnew_placement(&result, CharString(self->utf8()));
974
975 return result;
976 }
977
godot_string_parse_utf8(godot_string * p_self,const char * p_utf8)978 godot_bool GDAPI godot_string_parse_utf8(godot_string *p_self, const char *p_utf8) {
979 String *self = (String *)p_self;
980
981 return self->parse_utf8(p_utf8);
982 }
983
godot_string_parse_utf8_with_len(godot_string * p_self,const char * p_utf8,godot_int p_len)984 godot_bool GDAPI godot_string_parse_utf8_with_len(godot_string *p_self, const char *p_utf8, godot_int p_len) {
985 String *self = (String *)p_self;
986
987 return self->parse_utf8(p_utf8, p_len);
988 }
989
godot_string_chars_to_utf8(const char * p_utf8)990 godot_string GDAPI godot_string_chars_to_utf8(const char *p_utf8) {
991 godot_string result;
992 memnew_placement(&result, String(String::utf8(p_utf8)));
993
994 return result;
995 }
996
godot_string_chars_to_utf8_with_len(const char * p_utf8,godot_int p_len)997 godot_string GDAPI godot_string_chars_to_utf8_with_len(const char *p_utf8, godot_int p_len) {
998 godot_string result;
999 memnew_placement(&result, String(String::utf8(p_utf8, p_len)));
1000
1001 return result;
1002 }
1003
godot_string_hash(const godot_string * p_self)1004 uint32_t GDAPI godot_string_hash(const godot_string *p_self) {
1005 const String *self = (const String *)p_self;
1006
1007 return self->hash();
1008 }
1009
godot_string_hash64(const godot_string * p_self)1010 uint64_t GDAPI godot_string_hash64(const godot_string *p_self) {
1011 const String *self = (const String *)p_self;
1012
1013 return self->hash64();
1014 }
1015
godot_string_hash_chars(const char * p_cstr)1016 uint32_t GDAPI godot_string_hash_chars(const char *p_cstr) {
1017 return String::hash(p_cstr);
1018 }
1019
godot_string_hash_chars_with_len(const char * p_cstr,godot_int p_len)1020 uint32_t GDAPI godot_string_hash_chars_with_len(const char *p_cstr, godot_int p_len) {
1021 return String::hash(p_cstr, p_len);
1022 }
1023
godot_string_hash_utf8_chars(const wchar_t * p_str)1024 uint32_t GDAPI godot_string_hash_utf8_chars(const wchar_t *p_str) {
1025 return String::hash(p_str);
1026 }
1027
godot_string_hash_utf8_chars_with_len(const wchar_t * p_str,godot_int p_len)1028 uint32_t GDAPI godot_string_hash_utf8_chars_with_len(const wchar_t *p_str, godot_int p_len) {
1029 return String::hash(p_str, p_len);
1030 }
1031
godot_string_md5_buffer(const godot_string * p_self)1032 godot_pool_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self) {
1033 const String *self = (const String *)p_self;
1034 Vector<uint8_t> tmp_result = self->md5_buffer();
1035
1036 godot_pool_byte_array result;
1037 memnew_placement(&result, PoolByteArray);
1038 PoolByteArray *proxy = (PoolByteArray *)&result;
1039 PoolByteArray::Write proxy_writer = proxy->write();
1040 proxy->resize(tmp_result.size());
1041
1042 for (int i = 0; i < tmp_result.size(); i++) {
1043 proxy_writer[i] = tmp_result[i];
1044 }
1045
1046 return result;
1047 }
1048
godot_string_md5_text(const godot_string * p_self)1049 godot_string GDAPI godot_string_md5_text(const godot_string *p_self) {
1050 const String *self = (const String *)p_self;
1051 godot_string result;
1052 memnew_placement(&result, String(self->md5_text()));
1053
1054 return result;
1055 }
1056
godot_string_sha256_buffer(const godot_string * p_self)1057 godot_pool_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_self) {
1058 const String *self = (const String *)p_self;
1059 Vector<uint8_t> tmp_result = self->sha256_buffer();
1060
1061 godot_pool_byte_array result;
1062 memnew_placement(&result, PoolByteArray);
1063 PoolByteArray *proxy = (PoolByteArray *)&result;
1064 PoolByteArray::Write proxy_writer = proxy->write();
1065 proxy->resize(tmp_result.size());
1066
1067 for (int i = 0; i < tmp_result.size(); i++) {
1068 proxy_writer[i] = tmp_result[i];
1069 }
1070
1071 return result;
1072 }
1073
godot_string_sha256_text(const godot_string * p_self)1074 godot_string GDAPI godot_string_sha256_text(const godot_string *p_self) {
1075 const String *self = (const String *)p_self;
1076 godot_string result;
1077 memnew_placement(&result, String(self->sha256_text()));
1078
1079 return result;
1080 }
1081
godot_string_empty(const godot_string * p_self)1082 godot_bool godot_string_empty(const godot_string *p_self) {
1083 const String *self = (const String *)p_self;
1084
1085 return self->empty();
1086 }
1087
1088 // path functions
godot_string_get_base_dir(const godot_string * p_self)1089 godot_string GDAPI godot_string_get_base_dir(const godot_string *p_self) {
1090 const String *self = (const String *)p_self;
1091 godot_string result;
1092 String return_value = self->get_base_dir();
1093 memnew_placement(&result, String(return_value));
1094
1095 return result;
1096 }
1097
godot_string_get_file(const godot_string * p_self)1098 godot_string GDAPI godot_string_get_file(const godot_string *p_self) {
1099 const String *self = (const String *)p_self;
1100 godot_string result;
1101 String return_value = self->get_file();
1102 memnew_placement(&result, String(return_value));
1103
1104 return result;
1105 }
1106
godot_string_humanize_size(size_t p_size)1107 godot_string GDAPI godot_string_humanize_size(size_t p_size) {
1108 godot_string result;
1109 String return_value = String::humanize_size(p_size);
1110 memnew_placement(&result, String(return_value));
1111
1112 return result;
1113 }
1114
godot_string_is_abs_path(const godot_string * p_self)1115 godot_bool GDAPI godot_string_is_abs_path(const godot_string *p_self) {
1116 const String *self = (const String *)p_self;
1117
1118 return self->is_abs_path();
1119 }
1120
godot_string_is_rel_path(const godot_string * p_self)1121 godot_bool GDAPI godot_string_is_rel_path(const godot_string *p_self) {
1122 const String *self = (const String *)p_self;
1123
1124 return self->is_rel_path();
1125 }
1126
godot_string_is_resource_file(const godot_string * p_self)1127 godot_bool GDAPI godot_string_is_resource_file(const godot_string *p_self) {
1128 const String *self = (const String *)p_self;
1129
1130 return self->is_resource_file();
1131 }
1132
godot_string_path_to(const godot_string * p_self,const godot_string * p_path)1133 godot_string GDAPI godot_string_path_to(const godot_string *p_self, const godot_string *p_path) {
1134 const String *self = (const String *)p_self;
1135 String *path = (String *)p_path;
1136 godot_string result;
1137 String return_value = self->path_to(*path);
1138 memnew_placement(&result, String(return_value));
1139
1140 return result;
1141 }
1142
godot_string_path_to_file(const godot_string * p_self,const godot_string * p_path)1143 godot_string GDAPI godot_string_path_to_file(const godot_string *p_self, const godot_string *p_path) {
1144 const String *self = (const String *)p_self;
1145 String *path = (String *)p_path;
1146 godot_string result;
1147 String return_value = self->path_to_file(*path);
1148 memnew_placement(&result, String(return_value));
1149
1150 return result;
1151 }
1152
godot_string_simplify_path(const godot_string * p_self)1153 godot_string GDAPI godot_string_simplify_path(const godot_string *p_self) {
1154 const String *self = (const String *)p_self;
1155 godot_string result;
1156 String return_value = self->simplify_path();
1157 memnew_placement(&result, String(return_value));
1158
1159 return result;
1160 }
1161
godot_string_c_escape(const godot_string * p_self)1162 godot_string GDAPI godot_string_c_escape(const godot_string *p_self) {
1163 const String *self = (const String *)p_self;
1164 godot_string result;
1165 String return_value = self->c_escape();
1166 memnew_placement(&result, String(return_value));
1167
1168 return result;
1169 }
1170
godot_string_c_escape_multiline(const godot_string * p_self)1171 godot_string GDAPI godot_string_c_escape_multiline(const godot_string *p_self) {
1172 const String *self = (const String *)p_self;
1173 godot_string result;
1174 String return_value = self->c_escape_multiline();
1175 memnew_placement(&result, String(return_value));
1176
1177 return result;
1178 }
1179
godot_string_c_unescape(const godot_string * p_self)1180 godot_string GDAPI godot_string_c_unescape(const godot_string *p_self) {
1181 const String *self = (const String *)p_self;
1182 godot_string result;
1183 String return_value = self->c_unescape();
1184 memnew_placement(&result, String(return_value));
1185
1186 return result;
1187 }
1188
godot_string_http_escape(const godot_string * p_self)1189 godot_string GDAPI godot_string_http_escape(const godot_string *p_self) {
1190 const String *self = (const String *)p_self;
1191 godot_string result;
1192 String return_value = self->http_escape();
1193 memnew_placement(&result, String(return_value));
1194
1195 return result;
1196 }
1197
godot_string_http_unescape(const godot_string * p_self)1198 godot_string GDAPI godot_string_http_unescape(const godot_string *p_self) {
1199 const String *self = (const String *)p_self;
1200 godot_string result;
1201 String return_value = self->http_unescape();
1202 memnew_placement(&result, String(return_value));
1203
1204 return result;
1205 }
1206
godot_string_json_escape(const godot_string * p_self)1207 godot_string GDAPI godot_string_json_escape(const godot_string *p_self) {
1208 const String *self = (const String *)p_self;
1209 godot_string result;
1210 String return_value = self->json_escape();
1211 memnew_placement(&result, String(return_value));
1212
1213 return result;
1214 }
1215
godot_string_word_wrap(const godot_string * p_self,godot_int p_chars_per_line)1216 godot_string GDAPI godot_string_word_wrap(const godot_string *p_self, godot_int p_chars_per_line) {
1217 const String *self = (const String *)p_self;
1218 godot_string result;
1219 String return_value = self->word_wrap(p_chars_per_line);
1220 memnew_placement(&result, String(return_value));
1221
1222 return result;
1223 }
1224
godot_string_xml_escape(const godot_string * p_self)1225 godot_string GDAPI godot_string_xml_escape(const godot_string *p_self) {
1226 const String *self = (const String *)p_self;
1227 godot_string result;
1228 String return_value = self->xml_escape();
1229 memnew_placement(&result, String(return_value));
1230
1231 return result;
1232 }
1233
godot_string_xml_escape_with_quotes(const godot_string * p_self)1234 godot_string GDAPI godot_string_xml_escape_with_quotes(const godot_string *p_self) {
1235 const String *self = (const String *)p_self;
1236 godot_string result;
1237 String return_value = self->xml_escape(true);
1238 memnew_placement(&result, String(return_value));
1239
1240 return result;
1241 }
1242
godot_string_xml_unescape(const godot_string * p_self)1243 godot_string GDAPI godot_string_xml_unescape(const godot_string *p_self) {
1244 const String *self = (const String *)p_self;
1245 godot_string result;
1246 String return_value = self->xml_unescape();
1247 memnew_placement(&result, String(return_value));
1248
1249 return result;
1250 }
1251
godot_string_percent_decode(const godot_string * p_self)1252 godot_string GDAPI godot_string_percent_decode(const godot_string *p_self) {
1253 const String *self = (const String *)p_self;
1254 godot_string result;
1255 String return_value = self->percent_decode();
1256 memnew_placement(&result, String(return_value));
1257
1258 return result;
1259 }
1260
godot_string_percent_encode(const godot_string * p_self)1261 godot_string GDAPI godot_string_percent_encode(const godot_string *p_self) {
1262 const String *self = (const String *)p_self;
1263 godot_string result;
1264 String return_value = self->percent_encode();
1265 memnew_placement(&result, String(return_value));
1266
1267 return result;
1268 }
1269
godot_string_is_valid_float(const godot_string * p_self)1270 godot_bool GDAPI godot_string_is_valid_float(const godot_string *p_self) {
1271 const String *self = (const String *)p_self;
1272
1273 return self->is_valid_float();
1274 }
1275
godot_string_is_valid_hex_number(const godot_string * p_self,godot_bool p_with_prefix)1276 godot_bool GDAPI godot_string_is_valid_hex_number(const godot_string *p_self, godot_bool p_with_prefix) {
1277 const String *self = (const String *)p_self;
1278
1279 return self->is_valid_hex_number(p_with_prefix);
1280 }
1281
godot_string_is_valid_html_color(const godot_string * p_self)1282 godot_bool GDAPI godot_string_is_valid_html_color(const godot_string *p_self) {
1283 const String *self = (const String *)p_self;
1284
1285 return self->is_valid_html_color();
1286 }
1287
godot_string_is_valid_identifier(const godot_string * p_self)1288 godot_bool GDAPI godot_string_is_valid_identifier(const godot_string *p_self) {
1289 const String *self = (const String *)p_self;
1290
1291 return self->is_valid_identifier();
1292 }
1293
godot_string_is_valid_integer(const godot_string * p_self)1294 godot_bool GDAPI godot_string_is_valid_integer(const godot_string *p_self) {
1295 const String *self = (const String *)p_self;
1296
1297 return self->is_valid_integer();
1298 }
1299
godot_string_is_valid_ip_address(const godot_string * p_self)1300 godot_bool GDAPI godot_string_is_valid_ip_address(const godot_string *p_self) {
1301 const String *self = (const String *)p_self;
1302
1303 return self->is_valid_ip_address();
1304 }
1305
godot_string_dedent(const godot_string * p_self)1306 godot_string GDAPI godot_string_dedent(const godot_string *p_self) {
1307 const String *self = (const String *)p_self;
1308 godot_string result;
1309 String return_value = self->dedent();
1310 memnew_placement(&result, String(return_value));
1311
1312 return result;
1313 }
1314
godot_string_trim_prefix(const godot_string * p_self,const godot_string * p_prefix)1315 godot_string GDAPI godot_string_trim_prefix(const godot_string *p_self, const godot_string *p_prefix) {
1316 const String *self = (const String *)p_self;
1317 String *prefix = (String *)p_prefix;
1318 godot_string result;
1319 String return_value = self->trim_prefix(*prefix);
1320 memnew_placement(&result, String(return_value));
1321
1322 return result;
1323 }
1324
godot_string_trim_suffix(const godot_string * p_self,const godot_string * p_suffix)1325 godot_string GDAPI godot_string_trim_suffix(const godot_string *p_self, const godot_string *p_suffix) {
1326 const String *self = (const String *)p_self;
1327 String *suffix = (String *)p_suffix;
1328 godot_string result;
1329 String return_value = self->trim_suffix(*suffix);
1330 memnew_placement(&result, String(return_value));
1331
1332 return result;
1333 }
1334
godot_string_rstrip(const godot_string * p_self,const godot_string * p_chars)1335 godot_string GDAPI godot_string_rstrip(const godot_string *p_self, const godot_string *p_chars) {
1336 const String *self = (const String *)p_self;
1337 String *chars = (String *)p_chars;
1338 godot_string result;
1339 String return_value = self->rstrip(*chars);
1340 memnew_placement(&result, String(return_value));
1341
1342 return result;
1343 }
1344
godot_string_rsplit(const godot_string * p_self,const godot_string * p_divisor,const godot_bool p_allow_empty,const godot_int p_maxsplit)1345 godot_pool_string_array GDAPI godot_string_rsplit(const godot_string *p_self, const godot_string *p_divisor,
1346 const godot_bool p_allow_empty, const godot_int p_maxsplit) {
1347 const String *self = (const String *)p_self;
1348 String *divisor = (String *)p_divisor;
1349
1350 godot_pool_string_array result;
1351 memnew_placement(&result, PoolStringArray);
1352 PoolStringArray *proxy = (PoolStringArray *)&result;
1353 PoolStringArray::Write proxy_writer = proxy->write();
1354 Vector<String> tmp_result = self->rsplit(*divisor, p_allow_empty, p_maxsplit);
1355 proxy->resize(tmp_result.size());
1356
1357 for (int i = 0; i < tmp_result.size(); i++) {
1358 proxy_writer[i] = tmp_result[i];
1359 }
1360
1361 return result;
1362 }
1363
1364 #ifdef __cplusplus
1365 }
1366 #endif
1367