From 11ca0e93d7d92b4461b52f4e3a7ade01fc829279 Mon Sep 17 00:00:00 2001 From: Metehan Tuncbilek Date: Mon, 21 Oct 2024 12:35:45 +0300 Subject: [PATCH] another adjustments for string --- openVulkanoCpp/Data/Containers/String.hpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/openVulkanoCpp/Data/Containers/String.hpp b/openVulkanoCpp/Data/Containers/String.hpp index 933512e..b74ddd3 100644 --- a/openVulkanoCpp/Data/Containers/String.hpp +++ b/openVulkanoCpp/Data/Containers/String.hpp @@ -27,6 +27,7 @@ namespace OpenVulkano String(const std::string_view& str) : m_string(str) {} String(const String& other) : m_string(other.m_string) {} String(String&& other) noexcept : m_string(std::move(other.m_string)) {} + String(std::string&& other) noexcept : m_string(std::move(other)) {} ~String() = default; template String& operator=(const T& other) @@ -41,24 +42,32 @@ namespace OpenVulkano return *this; } - template String& operator=(const String& other) + String& operator=(const String& other) { m_string = other.m_string; return *this; } + String& operator=(String&& other) + { + m_string = std::move(other.m_string); + return *this; + } + template String& operator+=(const T& other) { m_string += other; return *this; } - template String& operator+=(const String& other) + String& operator+=(const String& other) { m_string += other.m_string; return *this; } + + template String operator+(const T& other) const { return m_string + other; } String operator+(const String& other) const { return m_string + other.m_string; } @@ -96,7 +105,7 @@ namespace OpenVulkano String& Trim() noexcept { return TrimBack().TrimFront(); } - [[nodiscard]] String Trim() const { return Trim(); } + [[nodiscard]] String Trim() const { return Trim(); } String& TrimFront() noexcept { @@ -203,7 +212,7 @@ namespace OpenVulkano m_string.size() - end - delimiter.size()) }; } - static inline int64_t OctToInt(const std::string_view& string) + static inline int64_t OctToInt(const std::string_view& string) { int64_t result = 0; for (int i = 0; i < static_cast(string.length()); i++) @@ -263,7 +272,7 @@ namespace OpenVulkano int64_t HexToInt() { return HexToInt(m_string); } - static bool IsUrl(const std::string_view& str) + static constexpr bool IsUrl(const std::string_view& str) { return str.find("http://") == 0 || str.find("https://") == 0 || str.find("ftp://") == 0; }