From 6dd93155cc3c12d76fcdf4b76f67e17105adaade Mon Sep 17 00:00:00 2001 From: DirtyDuckEUW Date: Fri, 15 Oct 2021 23:07:58 +0200 Subject: [PATCH] Test --- String.sln | 31 ------ String/String.cpp | 180 ---------------------------------- String/String.h | 68 ------------- String/String.vcxproj | 163 ------------------------------ String/String.vcxproj.filters | 30 ------ String/String.vcxproj.user | 4 - String/main.cpp | 7 -- 7 files changed, 483 deletions(-) delete mode 100644 String.sln delete mode 100644 String/String.cpp delete mode 100644 String/String.h delete mode 100644 String/String.vcxproj delete mode 100644 String/String.vcxproj.filters delete mode 100644 String/String.vcxproj.user delete mode 100644 String/main.cpp diff --git a/String.sln b/String.sln deleted file mode 100644 index 08a598d..0000000 --- a/String.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.1705 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "String", "String\String.vcxproj", "{5FE98B77-3558-4384-BDAF-82AC8B69B752}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5FE98B77-3558-4384-BDAF-82AC8B69B752}.Debug|x64.ActiveCfg = Debug|x64 - {5FE98B77-3558-4384-BDAF-82AC8B69B752}.Debug|x64.Build.0 = Debug|x64 - {5FE98B77-3558-4384-BDAF-82AC8B69B752}.Debug|x86.ActiveCfg = Debug|Win32 - {5FE98B77-3558-4384-BDAF-82AC8B69B752}.Debug|x86.Build.0 = Debug|Win32 - {5FE98B77-3558-4384-BDAF-82AC8B69B752}.Release|x64.ActiveCfg = Release|x64 - {5FE98B77-3558-4384-BDAF-82AC8B69B752}.Release|x64.Build.0 = Release|x64 - {5FE98B77-3558-4384-BDAF-82AC8B69B752}.Release|x86.ActiveCfg = Release|Win32 - {5FE98B77-3558-4384-BDAF-82AC8B69B752}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {CDE2A97D-BF32-4748-9A47-B8D0E10D3A9D} - EndGlobalSection -EndGlobal diff --git a/String/String.cpp b/String/String.cpp deleted file mode 100644 index 9be8d95..0000000 --- a/String/String.cpp +++ /dev/null @@ -1,180 +0,0 @@ -#include "String.h" -#include - -//----------------------------------------------------------------------------------------------------------------------------- -String::String(const char* pData) -{ - if (!pData) return; - - m_uiLength = StringLength(pData); - m_pData = new char[m_uiLength + 1]; - memset(m_pData, 0, m_uiLength + 1); - memcpy(m_pData, pData, m_uiLength); - m_uiCapacity = m_uiLength; -} - -//----------------------------------------------------------------------------------------------------------------------------- -String::String(const std::string &sString) - : m_pData(new char[sString.length()]) - , m_uiLength(sString.length()) - , m_uiCapacity(sString.length()) -{ -} - -//----------------------------------------------------------------------------------------------------------------------------- -String::String(const String& sRhs) - : m_uiLength(sRhs.m_uiLength) - , m_pData(new char[sRhs.m_uiLength + 1]) - , m_uiCapacity(sRhs.m_uiCapacity) -{ - memset(m_pData + m_uiLength, 0, 1); - memcpy(m_pData, sRhs.m_pData, m_uiLength); -} - -//----------------------------------------------------------------------------------------------------------------------------- -String::~String() -{ - DELETE_ARRAY(m_pData); -} - -//----------------------------------------------------------------------------------------------------------------------------- -int String::StringLength(const char* pChar) -{ - int iRet = 0; - while (*pChar != 0x0) - { - pChar++; - iRet++; - } - return iRet; -} - -//----------------------------------------------------------------------------------------------------------------------------- -void String::Insert(const char *pData, unsigned int uiPos) -{ - if (!pData) return; - - unsigned int uilength = StringLength(pData); - unsigned int uiNewLength = m_uiLength + uilength; - - while (uiNewLength > m_uiCapacity) - { - IncreaseCapacity(); - } - - char* pLeft = m_pData + uiPos; - char* pRight = m_pData + uiPos + uilength; - - memcpy(pRight, m_pData + uiPos, m_uiLength - uiPos); - memcpy(pLeft, pData, uilength); - - m_uiLength = uiNewLength; -} - -//----------------------------------------------------------------------------------------------------------------------------- -void String::Append(const char *pData) -{ - Insert(pData, m_uiLength); -} - -//----------------------------------------------------------------------------------------------------------------------------- -bool String::Contains(const String& sRhs) -{ - return Contains(sRhs.m_pData); -} - -//----------------------------------------------------------------------------------------------------------------------------- -bool String::Contains(const char *pData) -{ - int iRet = 1; - unsigned int uiLength = StringLength(pData); - unsigned int uiOffset = 0; - - while (iRet != 0) - { - if (uiLength > m_uiLength || uiOffset > m_uiLength) break; - iRet = memcmp(m_pData + uiOffset, pData, uiLength); - uiOffset++; - } - - return iRet == 0; -} - -//----------------------------------------------------------------------------------------------------------------------------- -unsigned int String::Find(const String& sRhs, unsigned int uiOffset) -{ - return Find(sRhs.m_pData, uiOffset); -} - -//----------------------------------------------------------------------------------------------------------------------------- -unsigned int String::Find(const char *pData, unsigned int uiOffset) -{ - unsigned int uiLength = StringLength(pData); - unsigned int uiCurrentOffset = uiOffset; - - for (int iRet = 1; iRet != 0; uiCurrentOffset++) - { - if (uiLength > m_uiLength || uiCurrentOffset > m_uiLength) - { - uiCurrentOffset = -1; - break; - } - iRet = memcmp(m_pData + uiCurrentOffset, pData, uiLength); - } - - return uiCurrentOffset; -} - -//----------------------------------------------------------------------------------------------------------------------------- -char String::At(unsigned int uiPos) -{ - return *(m_pData + uiPos); -} - -//----------------------------------------------------------------------------------------------------------------------------- -bool String::Remove(const String& sRhs) -{ - return RemoveAt(Find(sRhs), sRhs.m_uiLength); -} - -//----------------------------------------------------------------------------------------------------------------------------- -bool String::Remove(const char *pData) -{ - return RemoveAt(Find(pData), StringLength(pData)); -} - -//----------------------------------------------------------------------------------------------------------------------------- -bool String::RemoveAt(unsigned int uiPos, unsigned int uiSize) -{ - if (uiPos > m_uiLength) return false; - - m_uiLength = m_uiLength - uiSize; - char* pLast = m_pData + uiPos + uiSize; - memcpy(m_pData + uiPos, pLast, uiSize); - memset(pLast, 0, uiSize); - - return true; -} - -//----------------------------------------------------------------------------------------------------------------------------- -unsigned int String::Length() const -{ - return m_uiLength; -} - -//----------------------------------------------------------------------------------------------------------------------------- -std::string String::ToStdString() -{ - return std::string(m_pData); -} - -//----------------------------------------------------------------------------------------------------------------------------- -void String::IncreaseCapacity() -{ - m_uiCapacity = m_uiCapacity * c_uiCapacityIncreaseFactor; - char *pNew = new char[m_uiCapacity + 1]; - memset(pNew, 0, m_uiCapacity + 1); - memcpy(pNew, m_pData, m_uiLength); - DELETE_ARRAY(m_pData); - m_pData = pNew; -} \ No newline at end of file diff --git a/String/String.h b/String/String.h deleted file mode 100644 index 57407da..0000000 --- a/String/String.h +++ /dev/null @@ -1,68 +0,0 @@ -#pragma once -#include - -class String -{ -private: -#define DELETE_POINTER(Pointer) \ -if (Pointer != nullptr)\ -{\ - delete Pointer;\ - Pointer = nullptr;\ -} - -#define DELETE_ARRAY(Array) \ -if (Array != nullptr)\ -{\ - delete[] Array;\ - Array = nullptr;\ -} - -public: - String() = default; - - String(const char* pData); - - String(const std::string& sString); - - String(const String& sRhs); - - String& operator=(const String& sRhs) = delete; - - ~String(); - - int StringLength(const char* pData); - - void Insert(const char *pData, unsigned int uiPos); - - void Append(const char *pData); - - bool Contains(const String& sRhs); - - bool Contains(const char *pData); - - unsigned int Find(const String& sRhs, unsigned int uiOffset = 0); - - unsigned int Find(const char *pData, unsigned int uiOffset = 0); - - char At(unsigned int uiPos); - - bool Remove(const String& sRhs); - - bool Remove(const char *pData); - - bool RemoveAt(unsigned int uiPos, unsigned int uiSize); - - unsigned int Length() const; - - std::string ToStdString(); - -private: - - void IncreaseCapacity(); - - char* m_pData = nullptr; - unsigned int m_uiLength = 0; - unsigned int m_uiCapacity = 0; - const float c_uiCapacityIncreaseFactor = 1.5; -}; \ No newline at end of file diff --git a/String/String.vcxproj b/String/String.vcxproj deleted file mode 100644 index 88002fc..0000000 --- a/String/String.vcxproj +++ /dev/null @@ -1,163 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {5FE98B77-3558-4384-BDAF-82AC8B69B752} - Win32Proj - String - 10.0.19041.0 - - - - Application - true - v141 - Unicode - - - Application - false - v141 - true - Unicode - - - Application - true - v141 - Unicode - - - Application - false - v141 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - true - - - false - - - false - - - - - - Level3 - Disabled - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - - - Level3 - Disabled - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - - - Level3 - MaxSpeed - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - Level3 - MaxSpeed - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - - - - - \ No newline at end of file diff --git a/String/String.vcxproj.filters b/String/String.vcxproj.filters deleted file mode 100644 index 154e4d9..0000000 --- a/String/String.vcxproj.filters +++ /dev/null @@ -1,30 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Quelldateien - - - Quelldateien - - - - - Headerdateien - - - \ No newline at end of file diff --git a/String/String.vcxproj.user b/String/String.vcxproj.user deleted file mode 100644 index be25078..0000000 --- a/String/String.vcxproj.user +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/String/main.cpp b/String/main.cpp deleted file mode 100644 index 1b7b648..0000000 --- a/String/main.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "String.h" - -int main() -{ - return 0; -}