summaryrefslogtreecommitdiff
path: root/modules/gdnative/godot/string.cpp
blob: 2235c12a2d6a895ce192ae443b7581e555c8ca85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
/*************************************************************************/
/*  string.cpp                                                           */
/*************************************************************************/
/*                       This file is part of:                           */
/*                           GODOT ENGINE                                */
/*                    http://www.godotengine.org                         */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur.                 */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md)    */
/*                                                                       */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the       */
/* "Software"), to deal in the Software without restriction, including   */
/* without limitation the rights to use, copy, modify, merge, publish,   */
/* distribute, sublicense, and/or sell copies of the Software, and to    */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions:                                             */
/*                                                                       */
/* The above copyright notice and this permission notice shall be        */
/* included in all copies or substantial portions of the Software.       */
/*                                                                       */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
/*************************************************************************/
#include <godot/string.h>

#include "core/variant.h"
#include "string_db.h"
#include "ustring.h"

#include <string.h>

#ifdef __cplusplus
extern "C" {
#endif

void _string_api_anchor() {
}

void GDAPI godot_string_new(godot_string *r_dest) {
	String *dest = (String *)r_dest;
	memnew_placement(dest, String);
}

void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src) {
	String *dest = (String *)r_dest;
	const String *src = (const String *)p_src;
	memnew_placement(dest, String(*src));
}

void GDAPI godot_string_new_data(godot_string *r_dest, const char *p_contents, const int p_size) {
	String *dest = (String *)r_dest;
	memnew_placement(dest, String(String::utf8(p_contents, p_size)));
}

void GDAPI godot_string_new_unicode_data(godot_string *r_dest, const wchar_t *p_contents, const int p_size) {
	String *dest = (String *)r_dest;
	memnew_placement(dest, String(p_contents, p_size));
}

void GDAPI godot_string_get_data(const godot_string *p_self, char *p_dest, int *p_size) {
	String *self = (String *)p_self;
	if (p_size != NULL) {
		*p_size = self->utf8().length();
	}
	if (p_dest != NULL) {
		memcpy(p_dest, self->utf8().get_data(), *p_size);
	}
}

wchar_t GDAPI *godot_string_operator_index(godot_string *p_self, const godot_int p_idx) {
	String *self = (String *)p_self;
	return &(self->operator[](p_idx));
}

const char GDAPI *godot_string_c_str(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	return self->utf8().get_data();
}

const wchar_t GDAPI *godot_string_unicode_str(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	return self->c_str();
}

godot_bool GDAPI godot_string_operator_equal(const godot_string *p_self, const godot_string *p_b) {
	const String *self = (const String *)p_self;
	const String *b = (const String *)p_b;
	return *self == *b;
}

godot_bool GDAPI godot_string_operator_less(const godot_string *p_self, const godot_string *p_b) {
	const String *self = (const String *)p_self;
	const String *b = (const String *)p_b;
	return *self < *b;
}

godot_string GDAPI godot_string_operator_plus(const godot_string *p_self, const godot_string *p_b) {
	godot_string ret;
	const String *self = (const String *)p_self;
	const String *b = (const String *)p_b;
	memnew_placement(&ret, String(*self + *b));
	return ret;
}

void GDAPI godot_string_destroy(godot_string *p_self) {
	String *self = (String *)p_self;
	self->~String();
}

/* Standard size stuff */

godot_int GDAPI godot_string_length(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->length();
}

/* Helpers */

godot_bool GDAPI godot_string_begins_with(const godot_string *p_self, const godot_string *p_string) {
	const String *self = (const String *)p_self;
	const String *string = (const String *)p_string;

	return self->begins_with(*string);
}

godot_bool GDAPI godot_string_begins_with_char_array(const godot_string *p_self, const char *p_char_array) {
	const String *self = (const String *)p_self;

	return self->begins_with(p_char_array);
}

godot_array GDAPI godot_string_bigrams(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	Vector<String> return_value = self->bigrams();

	godot_array result;
	memnew_placement(&result, Array);
	Array *proxy = (Array *)&result;
	proxy->resize(return_value.size());
	for (int i = 0; i < return_value.size(); i++) {
		(*proxy)[i] = return_value[i];
	}

	return result;
};

godot_string GDAPI godot_string_chr(wchar_t p_character) {
	godot_string result;
	memnew_placement(&result, String(String::chr(p_character)));

	return result;
}

godot_bool GDAPI godot_string_ends_with(const godot_string *p_self, const godot_string *p_string) {
	const String *self = (const String *)p_self;
	const String *string = (const String *)p_string;

	return self->ends_with(*string);
}

godot_int GDAPI godot_string_find(const godot_string *p_self, godot_string p_what) {
	const String *self = (const String *)p_self;
	String *what = (String *)&p_what;

	return self->find(*what);
}

godot_int GDAPI godot_string_find_from(const godot_string *p_self, godot_string p_what, godot_int p_from) {
	const String *self = (const String *)p_self;
	String *what = (String *)&p_what;

	return self->find(*what, p_from);
}

godot_int GDAPI godot_string_findmk(const godot_string *p_self, const godot_array *p_keys) {
	const String *self = (const String *)p_self;

	Vector<String> keys;
	Array *keys_proxy = (Array *)p_keys;
	keys.resize(keys_proxy->size());
	for (int i = 0; i < keys_proxy->size(); i++) {
		keys[i] = (*keys_proxy)[i];
	}

	return self->findmk(keys);
}

godot_int GDAPI godot_string_findmk_from(const godot_string *p_self, const godot_array *p_keys, godot_int p_from) {
	const String *self = (const String *)p_self;

	Vector<String> keys;
	Array *keys_proxy = (Array *)p_keys;
	keys.resize(keys_proxy->size());
	for (int i = 0; i < keys_proxy->size(); i++) {
		keys[i] = (*keys_proxy)[i];
	}

	return self->findmk(keys, p_from);
}

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) {
	const String *self = (const String *)p_self;

	Vector<String> keys;
	Array *keys_proxy = (Array *)p_keys;
	keys.resize(keys_proxy->size());
	for (int i = 0; i < keys_proxy->size(); i++) {
		keys[i] = (*keys_proxy)[i];
	}

	return self->findmk(keys, p_from, r_key);
}

godot_int GDAPI godot_string_findn(const godot_string *p_self, godot_string p_what) {
	const String *self = (const String *)p_self;
	String *what = (String *)&p_what;

	return self->findn(*what);
}

godot_int GDAPI godot_string_findn_from(const godot_string *p_self, godot_string p_what, godot_int p_from) {
	const String *self = (const String *)p_self;
	String *what = (String *)&p_what;

	return self->findn(*what, p_from);
}

godot_int GDAPI find_last(const godot_string *p_self, godot_string p_what) {
	const String *self = (const String *)p_self;
	String *what = (String *)&p_what;

	return self->find_last(*what);
}

godot_string GDAPI godot_string_format(const godot_string *p_self, const godot_variant *p_values) {
	const String *self = (const String *)p_self;
	const Variant *values = (const Variant *)p_values;
	godot_string result;
	memnew_placement(&result, String(self->format(*values)));

	return result;
}

godot_string GDAPI godot_string_format_with_custom_placeholder(const godot_string *p_self, const godot_variant *p_values, const char *p_placeholder) {
	const String *self = (const String *)p_self;
	const Variant *values = (const Variant *)p_values;
	String placeholder = String(p_placeholder);
	godot_string result;
	memnew_placement(&result, String(self->format(*values, placeholder)));

	return result;
}

godot_string GDAPI godot_string_hex_encode_buffer(const uint8_t *p_buffer, godot_int p_len) {
	godot_string result;
	memnew_placement(&result, String(String::hex_encode_buffer(p_buffer, p_len)));

	return result;
}

godot_int GDAPI godot_string_hex_to_int(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->hex_to_int();
}

godot_int GDAPI godot_string_hex_to_int_without_prefix(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->hex_to_int(true);
}

godot_string GDAPI godot_string_insert(const godot_string *p_self, godot_int p_at_pos, godot_string p_string) {
	const String *self = (const String *)p_self;
	String *content = (String *)&p_string;
	godot_string result;
	memnew_placement(&result, String(self->insert(p_at_pos, *content)));

	return result;
}

godot_bool GDAPI godot_string_is_numeric(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->is_numeric();
}

godot_bool GDAPI godot_string_is_subsequence_of(const godot_string *p_self, const godot_string *p_string) {
	const String *self = (const String *)p_self;
	const String *string = (const String *)p_string;

	return self->is_subsequence_of(*string);
}

godot_bool GDAPI godot_string_is_subsequence_ofi(const godot_string *p_self, const godot_string *p_string) {
	const String *self = (const String *)p_self;
	const String *string = (const String *)p_string;

	return self->is_subsequence_ofi(*string);
}

godot_string GDAPI godot_string_lpad(const godot_string *p_self, godot_int p_min_length) {
	const String *self = (const String *)p_self;
	godot_string result;
	memnew_placement(&result, String(self->lpad(p_min_length)));

	return result;
}

godot_string GDAPI godot_string_lpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character) {
	const String *self = (const String *)p_self;
	const String *character = (const String *)p_character;
	godot_string result;
	memnew_placement(&result, String(self->lpad(p_min_length, *character)));

	return result;
}

godot_bool GDAPI godot_string_match(const godot_string *p_self, const godot_string *p_wildcard) {
	const String *self = (const String *)p_self;
	const String *wildcard = (const String *)p_wildcard;

	return self->match(*wildcard);
}

godot_bool GDAPI godot_string_matchn(const godot_string *p_self, const godot_string *p_wildcard) {
	const String *self = (const String *)p_self;
	const String *wildcard = (const String *)p_wildcard;

	return self->matchn(*wildcard);
}

godot_string GDAPI godot_string_md5(const uint8_t *p_md5) {
	godot_string result;
	memnew_placement(&result, String(String::md5(p_md5)));

	return result;
}

godot_string GDAPI godot_string_num(double p_num) {
	godot_string result;
	memnew_placement(&result, String(String::num(p_num)));

	return result;
}

godot_string GDAPI godot_string_num_int64(int64_t p_num, godot_int p_base) {
	godot_string result;
	memnew_placement(&result, String(String::num_int64(p_num, p_base)));

	return result;
}

godot_string GDAPI godot_string_num_int64_capitalized(int64_t p_num, godot_int p_base, godot_bool p_capitalize_hex) {
	godot_string result;
	memnew_placement(&result, String(String::num_int64(p_num, p_base, true)));

	return result;
}

godot_string GDAPI godot_string_num_real(double p_num) {
	godot_string result;
	memnew_placement(&result, String(String::num_real(p_num)));

	return result;
}

godot_string GDAPI godot_string_num_scientific(double p_num) {
	godot_string result;
	memnew_placement(&result, String(String::num_scientific(p_num)));

	return result;
}

godot_string GDAPI godot_string_num_with_decimals(double p_num, godot_int p_decimals) {
	godot_string result;
	memnew_placement(&result, String(String::num(p_num, p_decimals)));

	return result;
}

godot_string GDAPI godot_string_pad_decimals(const godot_string *p_self, godot_int p_digits) {
	const String *self = (const String *)p_self;
	godot_string result;
	memnew_placement(&result, String(self->pad_decimals(p_digits)));

	return result;
}

godot_string GDAPI godot_string_pad_zeros(const godot_string *p_self, godot_int p_digits) {
	const String *self = (const String *)p_self;
	godot_string result;
	memnew_placement(&result, String(self->pad_zeros(p_digits)));

	return result;
}

godot_string GDAPI godot_string_replace(const godot_string *p_self, godot_string p_key, godot_string p_with) {
	const String *self = (const String *)p_self;
	String *key = (String *)&p_key;
	String *with = (String *)&p_with;
	godot_string result;
	memnew_placement(&result, String(self->replace(*key, *with)));

	return result;
}

godot_string GDAPI godot_string_replacen(const godot_string *p_self, godot_string p_key, godot_string p_with) {
	const String *self = (const String *)p_self;
	String *key = (String *)&p_key;
	String *with = (String *)&p_with;
	godot_string result;
	memnew_placement(&result, String(self->replacen(*key, *with)));

	return result;
}

godot_int GDAPI godot_string_rfind(const godot_string *p_self, godot_string p_what) {
	const String *self = (const String *)p_self;
	String *what = (String *)&p_what;

	return self->rfind(*what);
}

godot_int GDAPI godot_string_rfindn(const godot_string *p_self, godot_string p_what) {
	const String *self = (const String *)p_self;
	String *what = (String *)&p_what;

	return self->rfindn(*what);
}

godot_int GDAPI godot_string_rfind_from(const godot_string *p_self, godot_string p_what, godot_int p_from) {
	const String *self = (const String *)p_self;
	String *what = (String *)&p_what;

	return self->rfind(*what, p_from);
}

godot_int GDAPI godot_string_rfindn_from(const godot_string *p_self, godot_string p_what, godot_int p_from) {
	const String *self = (const String *)p_self;
	String *what = (String *)&p_what;

	return self->rfindn(*what, p_from);
}

godot_string GDAPI godot_string_replace_first(const godot_string *p_self, godot_string p_key, godot_string p_with) {
	const String *self = (const String *)p_self;
	String *key = (String *)&p_key;
	String *with = (String *)&p_with;
	godot_string result;
	memnew_placement(&result, String(self->replace_first(*key, *with)));

	return result;
}

godot_string GDAPI godot_string_rpad(const godot_string *p_self, godot_int p_min_length) {
	const String *self = (const String *)p_self;
	godot_string result;
	memnew_placement(&result, String(self->rpad(p_min_length)));

	return result;
}

godot_string GDAPI godot_string_rpad_with_custom_character(const godot_string *p_self, godot_int p_min_length, const godot_string *p_character) {
	const String *self = (const String *)p_self;
	const String *character = (const String *)p_character;
	godot_string result;
	memnew_placement(&result, String(self->rpad(p_min_length, *character)));

	return result;
}

godot_real GDAPI godot_string_similarity(const godot_string *p_self, const godot_string *p_string) {
	const String *self = (const String *)p_self;
	const String *string = (const String *)p_string;

	return self->similarity(*string);
}

godot_string GDAPI godot_string_sprintf(const godot_string *p_self, const godot_array *p_values, godot_bool *p_error) {
	const String *self = (const String *)p_self;
	const Array *values = (const Array *)p_values;

	godot_string result;
	String return_value = self->sprintf(*values, p_error);
	memnew_placement(&result, String(return_value));

	return result;
}

godot_string GDAPI godot_string_substr(const godot_string *p_self, godot_int p_from, godot_int p_chars) {
	const String *self = (const String *)p_self;
	godot_string result;
	memnew_placement(&result, String(self->substr(p_from, p_chars)));

	return result;
}

double GDAPI godot_string_to_double(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->to_double();
}

godot_real GDAPI godot_string_to_float(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->to_float();
}

godot_int GDAPI godot_string_to_int(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->to_int();
}

godot_string GDAPI godot_string_capitalize(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	memnew_placement(&result, String(self->capitalize()));

	return result;
};

godot_string GDAPI godot_string_camelcase_to_underscore(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	memnew_placement(&result, String(self->camelcase_to_underscore(false)));

	return result;
};

godot_string GDAPI godot_string_camelcase_to_underscore_lowercased(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	memnew_placement(&result, String(self->camelcase_to_underscore()));

	return result;
};

double GDAPI godot_string_char_to_double(const char *p_what) {
	return String::to_double(p_what);
};

godot_int GDAPI godot_string_char_to_int(const char *p_what) {
	return String::to_int(p_what);
};

int64_t GDAPI godot_string_wchar_to_int(const wchar_t *p_str) {
	return String::to_int(p_str);
};

godot_int GDAPI godot_string_char_to_int_with_len(const char *p_what, godot_int p_len) {
	return String::to_int(p_what, p_len);
};

int64_t GDAPI godot_string_char_to_int64_with_len(const wchar_t *p_str, int p_len) {
	return String::to_int(p_str, p_len);
};

int64_t GDAPI godot_string_hex_to_int64(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->hex_to_int64(false);
};

int64_t GDAPI godot_string_hex_to_int64_with_prefix(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->hex_to_int64();
};

int64_t GDAPI godot_string_to_int64(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->to_int64();
};

double GDAPI godot_string_unicode_char_to_double(const wchar_t *p_str, const wchar_t **r_end) {
	return String::to_double(p_str, r_end);
}

godot_string GDAPI godot_string_get_slice(const godot_string *p_self, godot_string p_splitter, godot_int p_slice) {
	const String *self = (const String *)p_self;
	String *splitter = (String *)&p_splitter;
	godot_string result;
	memnew_placement(&result, String(self->get_slice(*splitter, p_slice)));

	return result;
};

godot_string GDAPI godot_string_get_slicec(const godot_string *p_self, wchar_t p_splitter, godot_int p_slice) {
	const String *self = (const String *)p_self;
	godot_string result;
	memnew_placement(&result, String(self->get_slicec(p_splitter, p_slice)));

	return result;
};

godot_array GDAPI godot_string_split(const godot_string *p_self, const godot_string *p_splitter) {
	const String *self = (const String *)p_self;
	const String *splitter = (const String *)p_splitter;
	godot_array result;
	memnew_placement(&result, Array);
	Array *proxy = (Array *)&result;
	Vector<String> return_value = self->split(*splitter, false);

	proxy->resize(return_value.size());
	for (int i = 0; i < return_value.size(); i++) {
		(*proxy)[i] = return_value[i];
	}

	return result;
};

godot_array GDAPI godot_string_split_allow_empty(const godot_string *p_self, const godot_string *p_splitter) {
	const String *self = (const String *)p_self;
	const String *splitter = (const String *)p_splitter;
	godot_array result;
	memnew_placement(&result, Array);
	Array *proxy = (Array *)&result;
	Vector<String> return_value = self->split(*splitter);

	proxy->resize(return_value.size());
	for (int i = 0; i < return_value.size(); i++) {
		(*proxy)[i] = return_value[i];
	}

	return result;
};

godot_array GDAPI godot_string_split_floats(const godot_string *p_self, const godot_string *p_splitter) {
	const String *self = (const String *)p_self;
	const String *splitter = (const String *)p_splitter;
	godot_array result;
	memnew_placement(&result, Array);
	Array *proxy = (Array *)&result;
	Vector<float> return_value = self->split_floats(*splitter, false);

	proxy->resize(return_value.size());
	for (int i = 0; i < return_value.size(); i++) {
		(*proxy)[i] = return_value[i];
	}

	return result;
};

godot_array GDAPI godot_string_split_floats_allows_empty(const godot_string *p_self, const godot_string *p_splitter) {
	const String *self = (const String *)p_self;
	const String *splitter = (const String *)p_splitter;
	godot_array result;
	memnew_placement(&result, Array);
	Array *proxy = (Array *)&result;
	Vector<float> return_value = self->split_floats(*splitter);

	proxy->resize(return_value.size());
	for (int i = 0; i < return_value.size(); i++) {
		(*proxy)[i] = return_value[i];
	}

	return result;
};

godot_array GDAPI godot_string_split_floats_mk(const godot_string *p_self, const godot_array *p_splitters) {
	const String *self = (const String *)p_self;

	Vector<String> splitters;
	Array *splitter_proxy = (Array *)p_splitters;
	splitters.resize(splitter_proxy->size());
	for (int i = 0; i < splitter_proxy->size(); i++) {
		splitters[i] = (*splitter_proxy)[i];
	}

	godot_array result;
	memnew_placement(&result, Array);
	Array *proxy = (Array *)&result;
	Vector<float> return_value = self->split_floats_mk(splitters, false);

	proxy->resize(return_value.size());
	for (int i = 0; i < return_value.size(); i++) {
		(*proxy)[i] = return_value[i];
	}

	return result;
};

godot_array GDAPI godot_string_split_floats_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters) {
	const String *self = (const String *)p_self;

	Vector<String> splitters;
	Array *splitter_proxy = (Array *)p_splitters;
	splitters.resize(splitter_proxy->size());
	for (int i = 0; i < splitter_proxy->size(); i++) {
		splitters[i] = (*splitter_proxy)[i];
	}

	godot_array result;
	memnew_placement(&result, Array);
	Array *proxy = (Array *)&result;
	Vector<float> return_value = self->split_floats_mk(splitters);

	proxy->resize(return_value.size());
	for (int i = 0; i < return_value.size(); i++) {
		(*proxy)[i] = return_value[i];
	}

	return result;
};

godot_array GDAPI godot_string_split_ints(const godot_string *p_self, const godot_string *p_splitter) {
	const String *self = (const String *)p_self;
	const String *splitter = (const String *)p_splitter;
	godot_array result;
	memnew_placement(&result, Array);
	Array *proxy = (Array *)&result;
	Vector<int> return_value = self->split_ints(*splitter, false);

	proxy->resize(return_value.size());
	for (int i = 0; i < return_value.size(); i++) {
		(*proxy)[i] = return_value[i];
	}

	return result;
};

godot_array GDAPI godot_string_split_ints_allows_empty(const godot_string *p_self, const godot_string *p_splitter) {
	const String *self = (const String *)p_self;
	const String *splitter = (const String *)p_splitter;
	godot_array result;
	memnew_placement(&result, Array);
	Array *proxy = (Array *)&result;
	Vector<int> return_value = self->split_ints(*splitter);

	proxy->resize(return_value.size());
	for (int i = 0; i < return_value.size(); i++) {
		(*proxy)[i] = return_value[i];
	}

	return result;
};

godot_array GDAPI godot_string_split_ints_mk(const godot_string *p_self, const godot_array *p_splitters) {
	const String *self = (const String *)p_self;

	Vector<String> splitters;
	Array *splitter_proxy = (Array *)p_splitters;
	splitters.resize(splitter_proxy->size());
	for (int i = 0; i < splitter_proxy->size(); i++) {
		splitters[i] = (*splitter_proxy)[i];
	}

	godot_array result;
	memnew_placement(&result, Array);
	Array *proxy = (Array *)&result;
	Vector<int> return_value = self->split_ints_mk(splitters, false);

	proxy->resize(return_value.size());
	for (int i = 0; i < return_value.size(); i++) {
		(*proxy)[i] = return_value[i];
	}

	return result;
};

godot_array GDAPI godot_string_split_ints_mk_allows_empty(const godot_string *p_self, const godot_array *p_splitters) {
	const String *self = (const String *)p_self;

	Vector<String> splitters;
	Array *splitter_proxy = (Array *)p_splitters;
	splitters.resize(splitter_proxy->size());
	for (int i = 0; i < splitter_proxy->size(); i++) {
		splitters[i] = (*splitter_proxy)[i];
	}

	godot_array result;
	memnew_placement(&result, Array);
	Array *proxy = (Array *)&result;
	Vector<int> return_value = self->split_ints_mk(splitters);

	proxy->resize(return_value.size());
	for (int i = 0; i < return_value.size(); i++) {
		(*proxy)[i] = return_value[i];
	}

	return result;
};

godot_array GDAPI godot_string_split_spaces(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_array result;
	memnew_placement(&result, Array);
	Array *proxy = (Array *)&result;
	Vector<String> return_value = self->split_spaces();

	proxy->resize(return_value.size());
	for (int i = 0; i < return_value.size(); i++) {
		(*proxy)[i] = return_value[i];
	}

	return result;
};

godot_int GDAPI godot_string_get_slice_count(const godot_string *p_self, godot_string p_splitter) {
	const String *self = (const String *)p_self;
	String *splitter = (String *)&p_splitter;

	return self->get_slice_count(*splitter);
};

wchar_t GDAPI godot_string_char_lowercase(wchar_t p_char) {
	return String::char_lowercase(p_char);
};

wchar_t GDAPI godot_string_char_uppercase(wchar_t p_char) {
	return String::char_uppercase(p_char);
};

godot_string GDAPI godot_string_to_lower(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	memnew_placement(&result, String(self->to_lower()));

	return result;
};

godot_string GDAPI godot_string_to_upper(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	memnew_placement(&result, String(self->to_upper()));

	return result;
};

godot_string GDAPI godot_string_get_basename(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	memnew_placement(&result, String(self->get_basename()));

	return result;
};

godot_string GDAPI godot_string_get_extension(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	memnew_placement(&result, String(self->get_extension()));

	return result;
};

godot_string GDAPI godot_string_left(const godot_string *p_self, godot_int p_pos) {
	const String *self = (const String *)p_self;
	godot_string result;
	memnew_placement(&result, String(self->left(p_pos)));

	return result;
};

wchar_t GDAPI godot_string_ord_at(const godot_string *p_self, godot_int p_idx) {
	const String *self = (const String *)p_self;

	return self->ord_at(p_idx);
};

godot_string GDAPI godot_string_plus_file(const godot_string *p_self, const godot_string *p_file) {
	const String *self = (const String *)p_self;
	const String *file = (const String *)p_file;
	godot_string result;
	memnew_placement(&result, String(self->plus_file(*file)));

	return result;
};

godot_string GDAPI godot_string_right(const godot_string *p_self, godot_int p_pos) {
	const String *self = (const String *)p_self;
	godot_string result;
	memnew_placement(&result, String(self->right(p_pos)));

	return result;
};

godot_string GDAPI godot_string_strip_edges(const godot_string *p_self, godot_bool p_left, godot_bool p_right) {
	const String *self = (const String *)p_self;
	godot_string result;
	memnew_placement(&result, String(self->strip_edges(p_left, p_right)));

	return result;
};

godot_string GDAPI godot_string_strip_escapes(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	memnew_placement(&result, String(self->strip_escapes()));

	return result;
};

void GDAPI godot_string_erase(godot_string *p_self, godot_int p_pos, godot_int p_chars) {
	String *self = (String *)p_self;

	return self->erase(p_pos, p_chars);
};

void GDAPI godot_string_ascii(godot_string *p_self, char *result) {
	String *self = (String *)p_self;
	Vector<char> return_value = self->ascii();

	for (int i = 0; i < return_value.size(); i++) {
		result[i] = return_value[i];
	}
}

void GDAPI godot_string_ascii_extended(godot_string *p_self, char *result) {
	String *self = (String *)p_self;
	Vector<char> return_value = self->ascii(true);

	for (int i = 0; i < return_value.size(); i++) {
		result[i] = return_value[i];
	}
}

void GDAPI godot_string_utf8(godot_string *p_self, char *result) {
	String *self = (String *)p_self;
	Vector<char> return_value = self->utf8();

	for (int i = 0; i < return_value.size(); i++) {
		result[i] = return_value[i];
	}
}

godot_bool GDAPI godot_string_parse_utf8(godot_string *p_self, const char *p_utf8) {
	String *self = (String *)p_self;

	return self->parse_utf8(p_utf8);
};

godot_bool GDAPI godot_string_parse_utf8_with_len(godot_string *p_self, const char *p_utf8, godot_int p_len) {
	String *self = (String *)p_self;

	return self->parse_utf8(p_utf8, p_len);
};

godot_string GDAPI godot_string_chars_to_utf8(const char *p_utf8) {
	godot_string result;
	memnew_placement(&result, String(String::utf8(p_utf8)));

	return result;
};

godot_string GDAPI godot_string_chars_to_utf8_with_len(const char *p_utf8, godot_int p_len) {
	godot_string result;
	memnew_placement(&result, String(String::utf8(p_utf8, p_len)));

	return result;
};

uint32_t GDAPI godot_string_hash(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->hash();
};

uint64_t GDAPI godot_string_hash64(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->hash64();
};

uint32_t GDAPI godot_string_hash_chars(const char *p_cstr) {
	return String::hash(p_cstr);
};

uint32_t GDAPI godot_string_hash_chars_with_len(const char *p_cstr, godot_int p_len) {
	return String::hash(p_cstr, p_len);
};

uint32_t GDAPI godot_string_hash_utf8_chars(const wchar_t *p_str) {
	return String::hash(p_str);
};

uint32_t GDAPI godot_string_hash_utf8_chars_with_len(const wchar_t *p_str, godot_int p_len) {
	return String::hash(p_str, p_len);
};

godot_pool_byte_array GDAPI godot_string_md5_buffer(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	Vector<uint8_t> tmp_result = self->md5_buffer();

	godot_pool_byte_array result;
	memnew_placement(&result, PoolByteArray);
	PoolByteArray *proxy = (PoolByteArray *)&result;
	PoolByteArray::Write proxy_writer = proxy->write();
	proxy->resize(tmp_result.size());

	for (int i = 0; i < tmp_result.size(); i++) {
		proxy_writer[i] = tmp_result[i];
	}

	return result;
};

godot_string GDAPI godot_string_md5_text(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	memnew_placement(&result, String(self->md5_text()));

	return result;
};

godot_pool_byte_array GDAPI godot_string_sha256_buffer(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	Vector<uint8_t> tmp_result = self->sha256_buffer();

	godot_pool_byte_array result;
	memnew_placement(&result, PoolByteArray);
	PoolByteArray *proxy = (PoolByteArray *)&result;
	PoolByteArray::Write proxy_writer = proxy->write();
	proxy->resize(tmp_result.size());

	for (int i = 0; i < tmp_result.size(); i++) {
		proxy_writer[i] = tmp_result[i];
	}

	return result;
};

godot_string GDAPI godot_string_sha256_text(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	memnew_placement(&result, String(self->sha256_text()));

	return result;
};

godot_bool godot_string_empty(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->empty();
};

// path functions
godot_string GDAPI godot_string_get_base_dir(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	String return_value = self->get_base_dir();
	memnew_placement(&result, String(return_value));

	return result;
};

godot_string GDAPI godot_string_get_file(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	String return_value = self->get_file();
	memnew_placement(&result, String(return_value));

	return result;
};

godot_string GDAPI godot_string_humanize_size(size_t p_size) {
	godot_string result;
	String return_value = String::humanize_size(p_size);
	memnew_placement(&result, String(return_value));

	return result;
};

godot_bool GDAPI godot_string_is_abs_path(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->is_abs_path();
};

godot_bool GDAPI godot_string_is_rel_path(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->is_rel_path();
};

godot_bool GDAPI godot_string_is_resource_file(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->is_resource_file();
};

godot_string GDAPI godot_string_path_to(const godot_string *p_self, const godot_string *p_path) {
	const String *self = (const String *)p_self;
	String *path = (String *)p_path;
	godot_string result;
	String return_value = self->path_to(*path);
	memnew_placement(&result, String(return_value));

	return result;
};

godot_string GDAPI godot_string_path_to_file(const godot_string *p_self, const godot_string *p_path) {
	const String *self = (const String *)p_self;
	String *path = (String *)p_path;
	godot_string result;
	String return_value = self->path_to_file(*path);
	memnew_placement(&result, String(return_value));

	return result;
};

godot_string GDAPI godot_string_simplify_path(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	String return_value = self->simplify_path();
	memnew_placement(&result, String(return_value));

	return result;
};

godot_string GDAPI godot_string_c_escape(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	String return_value = self->c_escape();
	memnew_placement(&result, String(return_value));

	return result;
};

godot_string GDAPI godot_string_c_escape_multiline(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	String return_value = self->c_escape_multiline();
	memnew_placement(&result, String(return_value));

	return result;
};

godot_string GDAPI godot_string_c_unescape(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	String return_value = self->c_unescape();
	memnew_placement(&result, String(return_value));

	return result;
};

godot_string GDAPI godot_string_http_escape(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	String return_value = self->http_escape();
	memnew_placement(&result, String(return_value));

	return result;
};

godot_string GDAPI godot_string_http_unescape(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	String return_value = self->http_unescape();
	memnew_placement(&result, String(return_value));

	return result;
};

godot_string GDAPI godot_string_json_escape(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	String return_value = self->json_escape();
	memnew_placement(&result, String(return_value));

	return result;
};

godot_string GDAPI godot_string_word_wrap(const godot_string *p_self, godot_int p_chars_per_line) {
	const String *self = (const String *)p_self;
	godot_string result;
	String return_value = self->word_wrap(p_chars_per_line);
	memnew_placement(&result, String(return_value));

	return result;
};

godot_string GDAPI godot_string_xml_escape(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	String return_value = self->xml_escape();
	memnew_placement(&result, String(return_value));

	return result;
};

godot_string GDAPI godot_string_xml_escape_with_quotes(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	String return_value = self->xml_escape(true);
	memnew_placement(&result, String(return_value));

	return result;
};

godot_string GDAPI godot_string_xml_unescape(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	String return_value = self->xml_unescape();
	memnew_placement(&result, String(return_value));

	return result;
};

godot_string GDAPI godot_string_percent_decode(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	String return_value = self->percent_decode();
	memnew_placement(&result, String(return_value));

	return result;
};

godot_string GDAPI godot_string_percent_encode(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_string result;
	String return_value = self->percent_encode();
	memnew_placement(&result, String(return_value));

	return result;
};

godot_bool GDAPI godot_string_is_valid_float(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->is_valid_float();
};

godot_bool GDAPI godot_string_is_valid_hex_number(const godot_string *p_self, godot_bool p_with_prefix) {
	const String *self = (const String *)p_self;

	return self->is_valid_hex_number(p_with_prefix);
};

godot_bool GDAPI godot_string_is_valid_html_color(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->is_valid_html_color();
};

godot_bool GDAPI godot_string_is_valid_identifier(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->is_valid_identifier();
};

godot_bool GDAPI godot_string_is_valid_integer(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->is_valid_integer();
};

godot_bool GDAPI godot_string_is_valid_ip_address(const godot_string *p_self) {
	const String *self = (const String *)p_self;

	return self->is_valid_ip_address();
};

#ifdef __cplusplus
}
#endif