[fpc-pascal] Any recommendations for a good in-memory storage type
Graeme Geldenhuys
graemeg.lists at gmail.com
Wed Sep 22 12:31:33 CEST 2010
Hi,
While implementing drag-n-drop support in fpGUI, I created a
TfpgMimeData class. This class will hold various data items, and a
mime-type describing each of the data items. Obviously the
TfpgMimeData class should be able to handle any data type. So my
question is, what is a good universal type to store all kinds of data
(strings, images (binary data), sound etc)?
The possible ideas I can think of is the following:
TByteArray
Variants
TMemoryStream
So which one would be more fitting for any mime types, or is there
another option I didn't think of? Here is a simple usage example of
the TfpgMimeData class - to help put this in perspective:
var
m: TfpgMimeData;
d: TfpgDrag;
a: TfpgDropAction;
begin
m := TfpgMimeData.Create;
m.SetData('text/plain', 'My name is Earl');
m.SetData('text/html', 'My name is <b>Earl</b>'); // text/plain
can actually be created from this automatically
m.SetData('image/png', MyPNGImage);
d := TfpgDrag.Create(self);
d.MimeData := m;
d.StartDrag([daCopy]);
// d manages the lifespan of m
// d will be freed automatically when drag action is complete or cancelled
end;
--
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net:8080/fpgui/
More information about the fpc-pascal
mailing list