Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2006-06-23 12:41:40


>> There is a type "class_name_optional" which is serialized with the
>> class name for every type. The default implementation is to ignore
>> it - and none of the included archives override the
>> default.
>
> Where is this type defined and which method do i have to override?

I double checked - I was wrong about this. there is no class_name_optional -
it's class_id_optional.

>
>> class_id etc are only applicable to classes - not primitives. They
>> might not be available for all types - depending on the
>> implementation level - I would have to investigate that.
>
> All classes i use are exported by BOOST_CLASS_EXPORT_GUID. Is there a
> chance to fetch the classname for a given class_id,
> class_id_reference or class_id_optional on the level of archive
> derivation?

There is no function to do this. This would have to be aded to
basic_[i/o]archive.hpp.
It's never been needed - but perhaps its worthy of consideration.

> Until now I've derived three classes from boost::archive:
>
> class my_basic_xml_oarchive : public detail::common_oarchive<Archive>
> class my_xml_oarchive_impl : public
> basic_text_oprimitive<std::ostream>,
> public my_basic_xml_oarchive<Archive>
> class my_xml_oarchive : public my_xml_oarchive_impl<my_xml_oarchive>

> And more general: How can i create objects from the registered
> information about classes using the extended type info? When using
> the boost::archive is not practical for my xml format i would like to
> use as much as possible from boost to port the already implemented
> solution by myself without boost. Therefore i need to replace my own
> classfactory if possible with boost's one.

The class factory used by boost serialization is coded into iserializer.hpp.
This is sort of "ad hoc". It relies upon facilities of extended_type_info.
I would like to see it "factored out" and move to extended_type_info
which would be a natural place for it. I don't know for a fact that
that wouldn't create some other difficulties but it would be a better
conceptual fit. I would also like to see this used to create a
"C++ / poor persons COM" which would have the facility of
Microsoft COM and CORBA but only address the needs of
of C++ programmers which would make it very simple to use -
unlike the language independent methods.

So we're on the same page here as far as what we would like to
see done - of course - getting it done is another thing entirely.

> I found the struct "save_array_type" in detail/oserializer.hpp. If i
> could replace the invoke method with my own (and so for all other
> savers) i could remove e.g. the "item" xml tags used with array
> elements. Any chance?

Boost serialization as implemented in the HEAD is being enhanced by Mathias
Troyer to permit extension and customization of serialization of
arrays/collections
according to the type of archive. His motivation is to maximize performance
of
serialization of arrays on for cluster computing. The method that his been
chosen is to create an "array_wrapper" whose serialization can be varied
according to the type of archive. This will be useful in your case.
However, It
won't be part of boost serialization until 1.35. It is not under going
"finishing
touches".

Note there are other improvements comming in the serialization library which
are none of my doing. Aside from Mathias work on making serialization
of arrays more customizable, David Abrahams has improved the export
code to eliminate header ordering requirements and refined tricky code
in [i/o]serializer so that its simpler, neater, and most importantly, allows
for more compilers to pass more tests.

It would be my hope to make a generalized GUI editor which can be
used to edit any serialization files. For me - this is much easier and more
useful than trying to make XML for this purpose.

Robert Ramey


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net