improved string
This commit is contained in:
parent
226b562ee0
commit
06def051e4
2 changed files with 36 additions and 8 deletions
|
@ -14,6 +14,7 @@ public:
|
|||
|
||||
LSString(const std::string& sString);
|
||||
|
||||
// - Operator
|
||||
LSString& operator=(const LSString& sRhs);
|
||||
|
||||
// - Destructor
|
||||
|
@ -67,7 +68,9 @@ public:
|
|||
#pragma endregion
|
||||
|
||||
#pragma region Logic
|
||||
|
||||
void Assign(const char* pData);
|
||||
void Insert(const char* pData, size_t uiPos);
|
||||
bool RemoveAt(size_t uiPos, size_t uiSize);
|
||||
#pragma endregion
|
||||
|
||||
// - Utility
|
||||
|
@ -113,9 +116,7 @@ public:
|
|||
|
||||
#pragma region Logic
|
||||
size_t StringLength(const char* pData) const;
|
||||
void Assign(const char* pData);
|
||||
void Insert(const char* pData, size_t uiPos);
|
||||
bool RemoveAt(size_t uiPos, size_t uiSize);
|
||||
|
||||
int Find(const char* pData, size_t uiOffset, size_t uiLength) const;
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -152,4 +153,24 @@ private:
|
|||
size_t m_uiLength = 0;
|
||||
size_t m_uiCapacity = 0;
|
||||
const float c_uiCapacityIncreaseFactor = 1.5;
|
||||
};
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------
|
||||
inline LSString operator+(const LSString& sLhs, const LSString& sRhs)
|
||||
{
|
||||
LSString sNew(sLhs);
|
||||
sNew.Append(sRhs);
|
||||
return sNew;
|
||||
}
|
||||
inline LSString operator+(const LSString& sLhs, const char* sRhs)
|
||||
{
|
||||
LSString sNew(sLhs);
|
||||
sNew.Append(sRhs);
|
||||
return sNew;
|
||||
}
|
||||
inline LSString operator+(const char* sLhs, const LSString& sRhs)
|
||||
{
|
||||
LSString sNew(sLhs);
|
||||
sNew.Append(sRhs);
|
||||
return sNew;
|
||||
}
|
|
@ -9,12 +9,19 @@
|
|||
int main()
|
||||
{
|
||||
printf("---LSString---\n");
|
||||
LSString s = "187";
|
||||
printf("Found: %d", s.Find("7"));
|
||||
LSString s3;
|
||||
const LSString s1 = "187";
|
||||
const LSString s2 = "361";
|
||||
|
||||
{
|
||||
s3 = s1 + s2;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
// - STRING
|
||||
{
|
||||
printf("---LSString---\n");
|
||||
|
@ -25,7 +32,7 @@ int main()
|
|||
printf("Run: %2d: ", static_cast<int>(zRun));
|
||||
|
||||
Timer tSingle("Duration in ");
|
||||
LSString s(nullptr);
|
||||
LSString s = "12345";
|
||||
|
||||
for (size_t z = 0; z < 187; z++)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue