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);
|
LSString(const std::string& sString);
|
||||||
|
|
||||||
|
// - Operator
|
||||||
LSString& operator=(const LSString& sRhs);
|
LSString& operator=(const LSString& sRhs);
|
||||||
|
|
||||||
// - Destructor
|
// - Destructor
|
||||||
|
@ -67,7 +68,9 @@ public:
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region Logic
|
#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
|
#pragma endregion
|
||||||
|
|
||||||
// - Utility
|
// - Utility
|
||||||
|
@ -113,9 +116,7 @@ public:
|
||||||
|
|
||||||
#pragma region Logic
|
#pragma region Logic
|
||||||
size_t StringLength(const char* pData) const;
|
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;
|
int Find(const char* pData, size_t uiOffset, size_t uiLength) const;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -153,3 +154,23 @@ private:
|
||||||
size_t m_uiCapacity = 0;
|
size_t m_uiCapacity = 0;
|
||||||
const float c_uiCapacityIncreaseFactor = 1.5;
|
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()
|
int main()
|
||||||
{
|
{
|
||||||
printf("---LSString---\n");
|
printf("---LSString---\n");
|
||||||
LSString s = "187";
|
LSString s3;
|
||||||
printf("Found: %d", s.Find("7"));
|
const LSString s1 = "187";
|
||||||
|
const LSString s2 = "361";
|
||||||
|
|
||||||
|
{
|
||||||
|
s3 = s1 + s2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// - STRING
|
// - STRING
|
||||||
{
|
{
|
||||||
printf("---LSString---\n");
|
printf("---LSString---\n");
|
||||||
|
@ -25,7 +32,7 @@ int main()
|
||||||
printf("Run: %2d: ", static_cast<int>(zRun));
|
printf("Run: %2d: ", static_cast<int>(zRun));
|
||||||
|
|
||||||
Timer tSingle("Duration in ");
|
Timer tSingle("Duration in ");
|
||||||
LSString s(nullptr);
|
LSString s = "12345";
|
||||||
|
|
||||||
for (size_t z = 0; z < 187; z++)
|
for (size_t z = 0; z < 187; z++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue