68 lines
No EOL
1.2 KiB
C++
68 lines
No EOL
1.2 KiB
C++
#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;
|
|
}; |