Merge pull request #198 from bruvzg/fix_str_find_and_cmp

Add missing String::find from argument, and missing String::casecmp_to functions
pull/201/head
Bastiaan Olij 2018-11-19 21:29:39 +11:00 committed by GitHub
commit 5f3d6bc233
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 12 deletions

View File

@ -68,8 +68,6 @@ public:
CharString utf8() const;
CharString ascii(bool p_extended = false) const;
int64_t find(String p_what) const;
int64_t find_from(String p_what, int64_t p_from) const;
bool begins_with(String &s) const;
bool begins_with_char_array(const char *p_char_array) const;
PoolStringArray bigrams() const;
@ -131,6 +129,9 @@ public:
String to_upper() const;
String xml_escape() const;
String xml_unescape() const;
signed char casecmp_to(String p_str) const;
signed char nocasecmp_to(String p_str) const;
signed char naturalnocasecmp_to(String p_str) const;
};

View File

@ -256,15 +256,15 @@ void String::erase(int position, int chars) {
}
int String::find(String p_what, int p_from) const {
return godot::api->godot_string_find(&_godot_string, p_what._godot_string);
return godot::api->godot_string_find_from(&_godot_string, p_what._godot_string, p_from);
}
int String::find_last(String what) const {
return godot::api->godot_string_find_last(&_godot_string, what._godot_string);
int String::find_last(String p_what) const {
return godot::api->godot_string_find_last(&_godot_string, p_what._godot_string);
}
int String::findn(String what, int from) const {
return godot::api->godot_string_findn(&_godot_string, what._godot_string);
int String::findn(String p_what, int p_from) const {
return godot::api->godot_string_findn_from(&_godot_string, p_what._godot_string, p_from);
}
String String::format(Variant values) const {
@ -443,13 +443,12 @@ String String::replacen(String what, String forwhat) const {
return new_string;
}
int String::rfind(String what, int from) const {
return godot::api->godot_string_rfind(&_godot_string, what._godot_string);
int String::rfind(String p_what, int p_from) const {
return godot::api->godot_string_rfind_from(&_godot_string, p_what._godot_string, p_from);
}
int String::rfindn(String what, int from) const {
// From -1
return godot::api->godot_string_rfindn(&_godot_string, what._godot_string);
int String::rfindn(String p_what, int p_from) const {
return godot::api->godot_string_rfindn_from(&_godot_string, p_what._godot_string, p_from);
}
String String::right(int position) const {
@ -543,4 +542,18 @@ String String::xml_unescape() const {
return new_string;
}
signed char String::casecmp_to(String p_str) const {
return godot::api->godot_string_casecmp_to(&_godot_string, &p_str._godot_string);
}
signed char String::nocasecmp_to(String p_str) const {
return godot::api->godot_string_nocasecmp_to(&_godot_string, &p_str._godot_string);
}
signed char String::naturalnocasecmp_to(String p_str) const {
return godot::api->godot_string_naturalnocasecmp_to(&_godot_string, &p_str._godot_string);
}
}