another adjustments for string

This commit is contained in:
Metehan Tuncbilek
2024-10-21 12:35:45 +03:00
parent b047a7c6c3
commit 11ca0e93d7

View File

@@ -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<typename T> String& operator=(const T& other)
@@ -41,24 +42,32 @@ namespace OpenVulkano
return *this;
}
template<typename T> 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<typename T> String& operator+=(const T& other)
{
m_string += other;
return *this;
}
template<typename T> String& operator+=(const String& other)
String& operator+=(const String& other)
{
m_string += other.m_string;
return *this;
}
template<typename T> 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<int>(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;
}