Remove from String Function

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Remove from String Function

Re: Remove from String Function

by ZippeyKeys12 » Sun Nov 12, 2017 3:42 pm

:o Thank you so much! :D

Re: Remove from String Function

by _mental_ » Sun Nov 12, 2017 6:45 am

Added in 5d83ee5.

Remove from String Function

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?

Top