소스 검색

Fix String const operators.

Added const to various operators.
Timothy Werquin 7 년 전
부모
커밋
1803ca43fa
2개의 변경된 파일16개의 추가작업 그리고 16개의 파일을 삭제
  1. 8 8
      include/core/String.hpp
  2. 8 8
      src/core/String.cpp

+ 8 - 8
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;
 

+ 8 - 8
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);
 }