From 1803ca43fa912183554857a5da45e695fe8e9645 Mon Sep 17 00:00:00 2001 From: Timothy Werquin Date: Tue, 15 May 2018 22:23:03 +0200 Subject: [PATCH 1/2] Fix String const operators. Added const to various operators. --- include/core/String.hpp | 16 ++++++++-------- src/core/String.cpp | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/core/String.hpp b/include/core/String.hpp index 7826fcb6..9bb0e3e3 100644 --- a/include/core/String.hpp +++ b/include/core/String.hpp @@ -49,15 +49,15 @@ public: wchar_t operator[](const int idx) const; void operator=(const String &s); - bool operator==(const String &s); - bool operator!=(const String &s); - String operator+(const String &s); + bool operator==(const String &s) const; + bool operator!=(const String &s) const; + String operator+(const String &s) const; void operator+=(const String &s); - void operator+=(const wchar_t c); - bool operator<(const String &s); - bool operator<=(const String &s); - bool operator>(const String &s); - bool operator>=(const String &s); + void operator+=(const wchar_t c) const; + bool operator<(const String &s) const; + bool operator<=(const String &s) const; + bool operator>(const String &s) const; + bool operator>=(const String &s) const; operator NodePath() const; diff --git a/src/core/String.cpp b/src/core/String.cpp index 737c0408..7cbc0908 100644 --- a/src/core/String.cpp +++ b/src/core/String.cpp @@ -115,15 +115,15 @@ void String::operator=(const String &s) { 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); } -bool String::operator!=(const String &s) { +bool String::operator!=(const String &s) const { return !(*this == s); } -String String::operator+(const String &s) { +String String::operator+(const String &s) const { String new_string = *this; new_string._godot_string = godot::api->godot_string_operator_plus(&new_string._godot_string, &s._godot_string); @@ -134,24 +134,24 @@ void String::operator+=(const String &s) { _godot_string = godot::api->godot_string_operator_plus(&_godot_string, &s._godot_string); } -void String::operator+=(const wchar_t c) { +void String::operator+=(const wchar_t c) const { // @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); } -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) || (*this == s); } -bool String::operator>(const String &s) { +bool String::operator>(const String &s) const { return !(*this <= s); } -bool String::operator>=(const String &s) { +bool String::operator>=(const String &s) const { return !(*this < s); } From 1a32997a0f877b1411bdf39c53f52b491285026c Mon Sep 17 00:00:00 2001 From: Timothy Werquin Date: Tue, 15 May 2018 22:24:53 +0200 Subject: [PATCH 2/2] Fix const for += operator in string --- include/core/String.hpp | 2 +- src/core/String.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/core/String.hpp b/include/core/String.hpp index 9bb0e3e3..ff3a307a 100644 --- a/include/core/String.hpp +++ b/include/core/String.hpp @@ -53,7 +53,7 @@ public: bool operator!=(const String &s) const; String operator+(const String &s) const; void operator+=(const String &s); - void operator+=(const wchar_t c) const; + void operator+=(const wchar_t c); bool operator<(const String &s) const; bool operator<=(const String &s) const; bool operator>(const String &s) const; diff --git a/src/core/String.cpp b/src/core/String.cpp index 7cbc0908..f85fa04a 100644 --- a/src/core/String.cpp +++ b/src/core/String.cpp @@ -134,7 +134,7 @@ void String::operator+=(const String &s) { _godot_string = godot::api->godot_string_operator_plus(&_godot_string, &s._godot_string); } -void String::operator+=(const wchar_t c) const { +void String::operator+=(const wchar_t c) { // @Todo }