by ZippeyKeys12 » Wed Nov 08, 2017 11:13 pm
I was wondering if we could get Remove(int length, int lengthRemoved) as there seems to be a function for it in zstring:
Code: Select all
void FString::Remove(size_t index, size_t remlen)
{
if (index < Len())
{
if (index + remlen >= Len())
{
Truncate((long)index);
}
else
{
if (Data()->RefCount == 1)
{ // Can do this in place
memmove(Chars + index, Chars + index + remlen, Len() - index - remlen);
memset(Chars + Len() - remlen, 0, remlen);
Data()->Len -= (unsigned)remlen;
}
else
{ // Must do it in a copy
FStringData *old = Data();
AllocBuffer(old->Len - remlen);
StrCopy(Chars, old->Chars(), index);
StrCopy(Chars + index, old->Chars() + index + remlen, old->Len - index - remlen);
old->Release();
}
}
}
}
And I can't find a convenient alternative
Could this be added?
I was wondering if we could get Remove(int length, int lengthRemoved) as there seems to be a function for it in zstring:
[code]
void FString::Remove(size_t index, size_t remlen)
{
if (index < Len())
{
if (index + remlen >= Len())
{
Truncate((long)index);
}
else
{
if (Data()->RefCount == 1)
{ // Can do this in place
memmove(Chars + index, Chars + index + remlen, Len() - index - remlen);
memset(Chars + Len() - remlen, 0, remlen);
Data()->Len -= (unsigned)remlen;
}
else
{ // Must do it in a copy
FStringData *old = Data();
AllocBuffer(old->Len - remlen);
StrCopy(Chars, old->Chars(), index);
StrCopy(Chars + index, old->Chars() + index + remlen, old->Len - index - remlen);
old->Release();
}
}
}
}[/code]
And I can't find a convenient alternative :? Could this be added?