[fpc-pascal] Delete and Add for TBytes?
bo.berglund at gmail.com
Wed Jul 12 16:07:17 CEST 2017
I would like to replace a buffer handling scheme in an old application
(written in Delphi) where the buffer was originally of type string and
later when unicode appeared changed to AnsiString.
But AnsiString also causes potential headaches so I would like to get
rid of it altogether by using a TBytes container instead.
The problem is that the code utilizes heavily a few string oriented
To remove Count processed bytes from the beginning:
Delete(Buffer, 1, Count)
Buffer := Copy(Buffer, Count+1, Length(Buffer));
For adding new data (c: AnsiChar) to the end:
Buffer := Buffer + c;
I would like to instead use TBytes as container but then I would not
like to rewrite all of the code so I would like to be able to do
Delete(Buf, Index, Count); //Removes Count bytes at Index
BufAdd(Buf, b); //Extends size of Buf and puts b last
Is it possible to overload Delete() so it can be called with TBytes as
For adding data the + operator would have been fine but I have no idea
how one could do that...
Developer in Sweden
More information about the fpc-pascal