Merge pull request #133 from timower/master

Fix const for String operators.
pull/135/head
Thomas Herzog 2018-05-15 23:00:02 +02:00 committed by GitHub
commit 1d4ca1575f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 14 deletions

View File

@ -49,15 +49,15 @@ public:
wchar_t operator[](const int idx) const; wchar_t operator[](const int idx) const;
void operator=(const String &s); void operator=(const String &s);
bool operator==(const String &s); bool operator==(const String &s) const;
bool operator!=(const String &s); bool operator!=(const String &s) const;
String operator+(const String &s); String operator+(const String &s) const;
void operator+=(const String &s); void operator+=(const String &s);
void operator+=(const wchar_t c); void operator+=(const wchar_t c);
bool operator<(const String &s); bool operator<(const String &s) const;
bool operator<=(const String &s); bool operator<=(const String &s) const;
bool operator>(const String &s); bool operator>(const String &s) const;
bool operator>=(const String &s); bool operator>=(const String &s) const;
operator NodePath() const; operator NodePath() const;

View File

@ -115,15 +115,15 @@ void String::operator=(const String &s) {
godot::api->godot_string_new_copy(&_godot_string, &s._godot_string); godot::api->godot_string_new_copy(&_godot_string, &s._godot_string);
} }
bool String::operator==(const String &s) { bool String::operator==(const String &s) const {
return godot::api->godot_string_operator_equal(&_godot_string, &s._godot_string); return godot::api->godot_string_operator_equal(&_godot_string, &s._godot_string);
} }
bool String::operator!=(const String &s) { bool String::operator!=(const String &s) const {
return !(*this == s); return !(*this == s);
} }
String String::operator+(const String &s) { String String::operator+(const String &s) const {
String new_string = *this; String new_string = *this;
new_string._godot_string = godot::api->godot_string_operator_plus(&new_string._godot_string, &s._godot_string); new_string._godot_string = godot::api->godot_string_operator_plus(&new_string._godot_string, &s._godot_string);
@ -138,20 +138,20 @@ void String::operator+=(const wchar_t c) {
// @Todo // @Todo
} }
bool String::operator<(const String &s) { bool String::operator<(const String &s) const {
return godot::api->godot_string_operator_less(&_godot_string, &s._godot_string); return godot::api->godot_string_operator_less(&_godot_string, &s._godot_string);
} }
bool String::operator<=(const String &s) { bool String::operator<=(const String &s) const {
return godot::api->godot_string_operator_less(&_godot_string, &s._godot_string) || return godot::api->godot_string_operator_less(&_godot_string, &s._godot_string) ||
(*this == s); (*this == s);
} }
bool String::operator>(const String &s) { bool String::operator>(const String &s) const {
return !(*this <= s); return !(*this <= s);
} }
bool String::operator>=(const String &s) { bool String::operator>=(const String &s) const {
return !(*this < s); return !(*this < s);
} }