views:

439

answers:

3

I am working with QuantumGrid 6 from Devexpress. I need to store the grids settings in an xml configuration file. Unfortunately, the grid does not allow XML as a storage option. I can however export the settings to a stream.

I'm thinking to export to a stream then convert the stream to text and store it as an xml value. I guess the text must only contain printable characters and it would be nice if it was compressed in some way.

Can somebody suggest a method of encoding the stream?

+3  A: 

Use standard IdEncoderMIME / IdDecoderMime from the Indy Misc palette. You have some methods for encoding streams.

Francis Lee
+3  A: 

You can use SimpleStorage, a XML storage based framework I created. You can download it from here.

SimpleStorage Download

It was made to solve problems like yours. To do what you want you need a single line of code:

SrcStorage.Ensure('Data').Filter('gzip').AsBinary.LoadFromStream(MemoryStream);

Not only it automatically base64 encodes the data but it also supports filter so you can gzip on the fly.

So with three lines of code you can do it all:

SrcStorage := CreateStorage('BinaryStorage'); SrcStorage.Ensure('Data').Filter('gzip').AsBinary.LoadFromStream(MemoryStream); SrcStorage.SaveToFile('Data.xml');

It uses OmniXML a very good delphi XML library. You can find all info on the download page.

Runner
A: 

I have done this using DIMimeStreams, encoding to a tStringStream, then placing the stream.datastring as the text portion of a specific element. If you want to add encryption, then I would add the routines found in LockBox to encrypt the stream prior to the MIME step. The latest version of LockBox, compiled for 2009 is available on the songbeamer website. You can also compress using just about any compression routine which compresses to a stream, and then run through the mime step.

skamradt