From bcdce9633dc351d3bc7f347a165348b8fab87cd9 Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 15 Feb 2022 12:33:52 +0100 Subject: refactor: reorganize files & improve classes --- src/utils/smart_string.cpp | 65 ---------------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 src/utils/smart_string.cpp (limited to 'src/utils/smart_string.cpp') diff --git a/src/utils/smart_string.cpp b/src/utils/smart_string.cpp deleted file mode 100644 index ac9a862..0000000 --- a/src/utils/smart_string.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "smart_string.hpp" - -#include "memory.hpp" - -#include - -SmartString::SmartString(char *c_string) : c_str(c_string) -{ -} - -SmartString::SmartString(unsigned int size) : c_str(malloc_s(size + 1)) -{ -} - -SmartString::SmartString(const SmartString &smart_str) - : c_str(malloc_s(strlen(smart_str.c_str) + 1)) -{ - memcpy(c_str, smart_str.c_str, strlen(smart_str.c_str) + 1); -} - -SmartString::SmartString(SmartString &&smart_str) noexcept : c_str(smart_str.c_str) -{ - smart_str.c_str = nullptr; -} - -SmartString &SmartString::operator=(const SmartString &smart_str) -{ - if (&smart_str != this) - { - free(c_str); - c_str = nullptr; - - auto str_size = strlen(smart_str.c_str) + 1; - - c_str = malloc_s(str_size); - memcpy(c_str, smart_str.c_str, str_size); - } - - return *this; -} - -SmartString &SmartString::operator=(SmartString &&smart_str) noexcept -{ - if (&smart_str != this) - { - free(c_str); - c_str = smart_str.c_str; - smart_str.c_str = nullptr; - } - - return *this; -} - -SmartString::~SmartString() -{ - if (c_str != nullptr) - { - free(c_str); - } -} - -SmartString::operator char *() const -{ - return c_str; -} -- cgit v1.2.3-18-g5258