Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2004-11-12 00:52:15


Pavel,

I've been watching this thread with mild interest. Your idea to specify a
specializations for specific pairs of archives / class serializations never
occurred to me. Before reading this I hadn't figured out how to do this.

This is really, really, really cool.

It preserves the extreme simplicty of the usage of serialization, its power
and completeness while permitting infinite flexibility.

I was plannng to include a demo/test of the usage of serializaton for debug
and transaction logs. Frankly, I was missing the magic piece you just
supplied. This will permit the serialization library to dovetail with any
varieties of format libraries.

Good Work

Robert Ramey

"Pavel Vozenilek" <pavel_vozenilek_at_[hidden]> wrote in message
news:cmu1n0$p1j$1_at_sea.gmane.org...
> > I've just finished documenting a small library, available here:
> >
> > http://home.comcast.net/~jturkanis/format_lite/
> >
> I took (brief) look and have question about feasibility of other idea:
>
> - would it be possible to combine format_lite functionality with
> Boost.Serialization to take advantage of both libs?
>
>
> Imagine solution like:
>
> // the formatting info is provided via boost::archive compatible object
> formatted_text_oarchive arch(a_ostream, default_formatting_settings ....);
>
> arch << my_data;
>
>
> class MyObject
> {
> template<class Archive>
> void serialize(Archive& ar, const unsigned) {
> .... normal serialization code, used when we DO NOT do
formatting
> output
> }
> // specialization for debug formatting
> template<>
> void serialize<formatted_text_oarchive>(....) {
> ar << my_vector; // default formatting will apply
>
> ar << "some info text...";
> ar.increase_indentation();
>
> // use different formatting for next vector
> punctuate<vector<...>(ar)(....);
> ar << my_other_vector;
> }
> };
>
>
> The advantages I see:
> - the whole infrastructure of Boost.Serialization is available and ready
> and it handles all situations like cycles. format_lite could
concentrate
> on just formatting.
>
> - the debugging output can be separated from other serialization types
> (but doesn't need to be)
>
> - formatting directives can be "inherited" from
> "higher level of data" to "lower levels". Newly added data would
> not need formatting of its own by default. Change on higher level
> would propagate itself "down".
>
> - indentation for pretty printing could be handled (semi)automatically
> by formatting archive.
>
> - multiple formatting styles could be provided for any class.
>
>
> My experience is that Serialization is quite easy to use and
> lightweight enough so I do not consider it any disadvantage
> for practical use.
>
> /Pavel
>
>
>
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk