init
This commit is contained in:
commit
c0a6e45559
7 changed files with 483 additions and 0 deletions
68
String/String.h
Normal file
68
String/String.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
|
||||
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;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue