From 627fb387e6a6262870e12a4bfe4a1f1020b1d15b Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Wed, 16 Feb 2022 01:57:03 -0600 Subject: [PATCH] [ox/std] Add operator+(...) to BString --- deps/ox/src/ox/std/bstring.hpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/deps/ox/src/ox/std/bstring.hpp b/deps/ox/src/ox/std/bstring.hpp index 1ad7c4acd..f670f69ce 100644 --- a/deps/ox/src/ox/std/bstring.hpp +++ b/deps/ox/src/ox/std/bstring.hpp @@ -37,6 +37,12 @@ class BString { constexpr BString &operator+=(int64_t i) noexcept; + constexpr BString operator+(const char *str) const noexcept; + + constexpr BString operator+(char *str) const noexcept; + + constexpr BString operator+(int64_t i) const noexcept; + constexpr bool operator==(const BString &other) const noexcept; constexpr bool operator!=(const BString &other) noexcept; @@ -123,6 +129,26 @@ constexpr BString &BString::operator+=(int64_t i) noexcept { return this->operator+=(str); } +template +constexpr BString BString::operator+(const char *str) const noexcept { + auto out = *this; + std::size_t strLen = ox_strlen(str) + 1; + oxIgnoreError(out.append(str, strLen)); + return out; +} + +template +constexpr BString BString::operator+(char *str) const noexcept { + return *this + static_cast(str); +} + +template +constexpr BString BString::operator+(int64_t i) const noexcept { + char str[65] = {}; + ox_itoa(i, str); + return this->operator+(str); +} + template constexpr bool BString::operator==(const BString &other) const noexcept { bool retval = true;