mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Add experimental insert() function to string class
This commit is contained in:
parent
2f1611fe87
commit
9925a9e9b4
@ -487,6 +487,27 @@ namespace std
|
||||
}
|
||||
}
|
||||
|
||||
void insert(size_t Index, size_t Count, char Ch)
|
||||
{
|
||||
strdbg("%#lx: String insert: %d, %d, '%c'",
|
||||
this, Index, Count, Ch);
|
||||
if (Index > this->Length)
|
||||
return;
|
||||
|
||||
size_t NewLength = this->Length + Count;
|
||||
this->resize(NewLength);
|
||||
|
||||
for (size_t i = this->Length - 1; i >= Index + Count; i--)
|
||||
this->Data[i] = this->Data[i - Count];
|
||||
|
||||
for (size_t i = 0; i < Count; i++)
|
||||
this->Data[Index + i] = Ch;
|
||||
|
||||
strdbg("%#lx: String inserted: \"%s\" (data: %#lx, length: %d, capacity: %d)",
|
||||
this, this->Data, this->Data, this->Length, this->Capacity);
|
||||
}
|
||||
|
||||
|
||||
string operator+(const string &Other) const
|
||||
{
|
||||
string result = *this;
|
||||
|
Loading…
x
Reference in New Issue
Block a user