[ox/std] Add support for appending single chars

This commit is contained in:
Gary Talent 2021-04-16 20:00:04 -05:00
parent 86202562fe
commit db49361f8a
2 changed files with 39 additions and 0 deletions

View File

@ -60,6 +60,15 @@ String &String::operator=(char *str) noexcept {
return *this = static_cast<const char*>(str); return *this = static_cast<const char*>(str);
} }
String &String::operator=(char c) noexcept {
char str[] = {c, 0};
return this->operator=(str);
}
String &String::operator=(int i) noexcept {
return this->operator=(static_cast<int64_t>(i));
}
String &String::operator=(int64_t i) noexcept { String &String::operator=(int64_t i) noexcept {
char str[65] = {}; char str[65] = {};
ox_itoa(i, str); ox_itoa(i, str);
@ -89,6 +98,15 @@ String &String::operator+=(char *str) noexcept {
return *this += static_cast<const char*>(str); return *this += static_cast<const char*>(str);
} }
String &String::operator+=(char c) noexcept {
char str[] = {c, 0};
return this->operator+=(str);
}
String &String::operator+=(int i) noexcept {
return this->operator+=(static_cast<int64_t>(i));
}
String &String::operator+=(int64_t i) noexcept { String &String::operator+=(int64_t i) noexcept {
char str[65] = {}; char str[65] = {};
ox_itoa(i, str); ox_itoa(i, str);
@ -115,6 +133,15 @@ String String::operator+(char *str) const noexcept {
return *this + static_cast<const char*>(str); return *this + static_cast<const char*>(str);
} }
String String::operator+(char c) const noexcept {
char str[] = {c, 0};
return *this + str;
}
String String::operator+(int i) const noexcept {
return this->operator+(static_cast<int64_t>(i));
}
String String::operator+(int64_t i) const noexcept { String String::operator+(int64_t i) const noexcept {
char str[65] = {}; char str[65] = {};
ox_itoa(i, str); ox_itoa(i, str);

View File

@ -40,6 +40,10 @@ class String {
String &operator=(char *str) noexcept; String &operator=(char *str) noexcept;
String &operator=(char c) noexcept;
String &operator=(int i) noexcept;
String &operator=(int64_t i) noexcept; String &operator=(int64_t i) noexcept;
String &operator=(const String &src) noexcept; String &operator=(const String &src) noexcept;
@ -50,6 +54,10 @@ class String {
String &operator+=(char *str) noexcept; String &operator+=(char *str) noexcept;
String &operator+=(char c) noexcept;
String &operator+=(int i) noexcept;
String &operator+=(int64_t i) noexcept; String &operator+=(int64_t i) noexcept;
String &operator+=(const String &src) noexcept; String &operator+=(const String &src) noexcept;
@ -58,6 +66,10 @@ class String {
String operator+(char *str) const noexcept; String operator+(char *str) const noexcept;
String operator+(char c) const noexcept;
String operator+(int i) const noexcept;
String operator+(int64_t i) const noexcept; String operator+(int64_t i) const noexcept;
String operator+(const String &src) const noexcept; String operator+(const String &src) const noexcept;