diff options
author | reduz <reduzio@gmail.com> | 2020-11-04 23:01:55 -0300 |
---|---|---|
committer | reduz <reduzio@gmail.com> | 2020-11-06 12:45:50 -0300 |
commit | f2397809a84c2bf0d41e6cb2092fa8f3c5a17850 (patch) | |
tree | 1eb1930e9124c5ecf77840e80ebed64cbb85608c /core/ustring.cpp | |
parent | 391d29f558d122798416b5957660d9eeceecd0f5 (diff) | |
download | redot-engine-f2397809a84c2bf0d41e6cb2092fa8f3c5a17850.tar.gz |
Refactored Variant Operators.
-Using classes to call and a table
-For typed code (GDS or GDNative), can obtain functions to call prevalidated or ptr.
Diffstat (limited to 'core/ustring.cpp')
-rw-r--r-- | core/ustring.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp index 27dab8db6e..79db595714 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -637,6 +637,20 @@ bool operator==(const wchar_t *p_chr, const String &p_str) { #endif } +bool operator!=(const char *p_chr, const String &p_str) { + return !(p_str == p_chr); +} + +bool operator!=(const wchar_t *p_chr, const String &p_str) { +#ifdef WINDOWS_ENABLED + // wchar_t is 16-bit + return !(p_str == String::utf16((const char16_t *)p_chr)); +#else + // wchar_t is 32-bi + return !(p_str == String((const char32_t *)p_chr)); +#endif +} + bool String::operator!=(const char *p_str) const { return (!(*this == p_str)); } @@ -654,7 +668,14 @@ bool String::operator!=(const String &p_str) const { } bool String::operator<=(const String &p_str) const { - return (*this < p_str) || (*this == p_str); + return !(p_str < *this); +} + +bool String::operator>(const String &p_str) const { + return p_str < *this; +} +bool String::operator>=(const String &p_str) const { + return !(*this < p_str); } bool String::operator<(const char *p_str) const { @@ -4455,7 +4476,9 @@ String String::sprintf(const Array &values, bool *error) const { bool left_justified = false; bool show_sign = false; - *error = true; + if (error) { + *error = true; + } for (; *self; self++) { const char32_t c = *self; @@ -4716,7 +4739,9 @@ String String::sprintf(const Array &values, bool *error) const { return "not all arguments converted during string formatting"; } - *error = false; + if (error) { + *error = false; + } return formatted; } |