Re: 100% pure Win32 IDE
- From: "Jon Robertson" <jonrobertson@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: 6 Sep 2006 16:08:13 -0700
Craig Stuntz [TeamB] wrote:
A huge advantage of XML over INI files for those with Delphi
Enterprise is the XML data binding wizard. Just write a sample XML
config file, run the data binding wizard, and now you have an object
model for your configuration settings. So in a simple case your code
looks like this:
A huge advantage of DFM over XML for those with any edition of Delphi is the ability to easily stream components in and out of a persistent storage. Just derive your config object from TComponent, stream the component in and out, and now you have an object model for your configuration settings, without needing an expensive edition of Delphi or a XML engine.
Here's an example of streaming to/from a dataset field. Omit the ObjectTextToBinary and ObjectBinaryToText calls, and change TMemoField to TBlobField, to store the object in binary form (much more efficient but more difficult to troubleshoot while in Query Analyzer :D ):
procedure ObjectToField(AObject: TComponent; AField: TMemoField);
var
msBinaryDFM : TMemoryStream;
msTextDFM : TMemoryStream;
begin
msBinaryDFM := TMemoryStream.Create();
msTextDFM := TMemoryStream.Create();
try
msBinaryDFM.WriteComponent(AObject);
msBinaryDFM.Seek(0, soFromBeginning);
ObjectBinaryToText(msBinaryDFM, msTextDFM);
msTextDFM.Seek(0, soFromBeginning);
if not (AField.DataSet.State in dsEditModes) then
AField.DataSet.Edit();
try
AField.LoadFromStream(msTextDFM);
finally
AField.DataSet.Post();
end;
finally
msBinaryDFM.Free();
msTextDFM.Free();
end;
end;
procedure FieldToObject(AField: TMemoField; AObject: TComponent);
var
msBinaryDFM : TMemoryStream;
msTextDFM : TMemoryStream;
begin
msBinaryDFM := TMemoryStream.Create();
msTextDFM := TMemoryStream.Create();
try
AField.SaveToStream(msTextDFM);
msTextDFM.Seek(0, soFromBeginning);
ObjectTextToBinary(msTextDFM, msBinaryDFM);
msBinaryDFM.Seek(0, soFromBeginning);
msBinaryDFM.ReadComponent(AObject);
finally
msBinaryDFM.Free();
msTextDFM.Free();
end;
end;
.
- References:
- 100% pure Win32 IDE
- From: Brian Twinings
- Re: 100% pure Win32 IDE
- From: Bruce McGee
- Re: 100% pure Win32 IDE
- From: Brian Moelk
- Re: 100% pure Win32 IDE
- From: Nick Hodges (Borland/DTG)
- Re: 100% pure Win32 IDE
- From: Marco Caspers
- Re: 100% pure Win32 IDE
- From: Ingvar Nilsen
- Re: 100% pure Win32 IDE
- From: Marco Caspers
- Re: 100% pure Win32 IDE
- From: Craig Stuntz [TeamB]
- 100% pure Win32 IDE
- Prev by Date: Re: Turbos on high demand - Borland Server down?
- Next by Date: Re: When will we be able to buy Turbo Professional licenses?
- Previous by thread: Re: 100% pure Win32 IDE
- Next by thread: Re: 100% pure Win32 IDE
- Index(es):
Relevant Pages
|