mirror of
https://github.com/godotengine/godot-cpp.git
synced 2026-01-07 10:10:08 +03:00
Implement String::resize()
This commit is contained in:
@@ -139,6 +139,7 @@ void Example::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("test_string_ops"), &Example::test_string_ops);
|
||||
ClassDB::bind_method(D_METHOD("test_str_utility"), &Example::test_str_utility);
|
||||
ClassDB::bind_method(D_METHOD("test_string_is_fourty_two"), &Example::test_string_is_fourty_two);
|
||||
ClassDB::bind_method(D_METHOD("test_string_resize"), &Example::test_string_resize);
|
||||
ClassDB::bind_method(D_METHOD("test_vector_ops"), &Example::test_vector_ops);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("test_bitfield", "flags"), &Example::test_bitfield);
|
||||
@@ -304,6 +305,16 @@ bool Example::test_string_is_fourty_two(const String &p_string) const {
|
||||
return strcmp(p_string.utf8().ptr(), "fourty two") == 0;
|
||||
}
|
||||
|
||||
String Example::test_string_resize(String p_string) const {
|
||||
int orig_len = p_string.length();
|
||||
p_string.resize(orig_len + 3);
|
||||
char32_t *data = p_string.ptrw();
|
||||
data[orig_len + 0] = '!';
|
||||
data[orig_len + 1] = '?';
|
||||
data[orig_len + 2] = '\0';
|
||||
return p_string;
|
||||
}
|
||||
|
||||
int Example::test_vector_ops() const {
|
||||
PackedInt32Array arr;
|
||||
arr.push_back(10);
|
||||
|
||||
@@ -118,6 +118,7 @@ public:
|
||||
String test_string_ops() const;
|
||||
String test_str_utility() const;
|
||||
bool test_string_is_fourty_two(const String &p_str) const;
|
||||
String test_string_resize(String p_original) const;
|
||||
int test_vector_ops() const;
|
||||
|
||||
BitField<Flags> test_bitfield(BitField<Flags> flags);
|
||||
|
||||
Reference in New Issue
Block a user