[fpc-pascal] Any recommendations for a good in-memory storage type

Zaher Dirkey parmaja at gmail.com
Tue Sep 28 08:44:25 CEST 2010


On Wed, Sep 22, 2010 at 1:31 PM, Graeme Geldenhuys
<graemeg.lists at gmail.com>wrote:

> 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;
>
>
Just initial idea.

TfpgMimeData class(TfpgDragData);
Picture:TPic ...
end;

var
 m: TfpgDragData;
 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');
     (m as TfpgMimeData).Picture.Assign(MyPNGImage);

     d := TfpgDrag.Create(self);
     d.DragData := m;
     d.StartDrag([daCopy]);

     // d manages the lifespan of m
     // d will be freed automatically when drag action is complete or
cancelled
end;

-- 
Zaher Dirkey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20100928/b2369373/attachment.html>


More information about the fpc-pascal mailing list