Boost logo

Boost :

From: Scott Woods (scott.suzuki_at_[hidden])
Date: 2007-12-04 16:50:44

----- Original Message -----
From: "Sebastian Redl" <sebastian.redl_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Monday, December 03, 2007 11:48 PM
Subject: Re: [boost] [rfc] I/O Chain Library, Preview Release

>> * some common usage examples might be good? i.e. configuration
>> and/or application-specific "document"
> I'll see what I can do for the next preview release. Right now I was
> happy to get a number of essential components working.

Oh for sure!

>> * is it possible to have runtime-selectable links in the IO chain?
>> e.g. user selection of the encoding to be used.
> Yes. Some components directly support runtime selection of parameters
> (like primitive serialization rules in the assembler_filter, or external
> coding in the character coder), and you can always compose chains using
> the erasure, at the cost of a bit of overhead (of course - runtime
> choices always impose overhead). For example, the SWF format contains a
> flag in the header for whether the whole file is gzip-compressed or not.
> You could read that like this:
> file_source rawswf(filename);
> assembly<native_rules, file_source> header_reader(rawswf);
> octet sig[3], version;
> if((sig[0] != 'F' && sig[0] != 'C') || sig[1] != 'W' || sig[2] != 'S') {
> throw not_swf(); }
> bool compressed = sig[0] == 'C';
> if(unsupported(version)) { throw unsupported_swf(); }
> if(version < 6 && compressed) { throw bad_swf(); }
> uint32_t length;
> source<iobyte> swfbody(compressed ?
> chain(rawswf) | zlib() :
> chain(rawswf));
> Now you can just continue reading from swfbody. The compression is
> transparent. (Aside from the loss of the seeking capability.)

IIUC, the example above appears to be an example of a "header reader" that
can be used at runtime to switch code paths inside the application. Cool but
not quite what I was asking.

Imagine you have an application that saves its configuration in a file using
the I/O chain library. You decide that the encoding will be binary to
users from fiddling. You further decide that users arent so bad and that
an advanced tab will let them switch between binary encoding, XML and
It might allow for easy exchange of configurations within a user community.

I have been working in this area and have stumbled over this issue a few
times. And ended up with crude solutions using "switch".


> Sebastian
> _______________________________________________
> Unsubscribe & other changes:

Boost list run by bdawes at, gregod at, cpdaniel at, john at