[serialization] Empty save_override for tracking_type, object_id_type etc

Hi, I want to write my own archive class for reading/writing to some defined binary protocol. I'm deriving my archive class from the binary_oarchive_impl template and overriding save_override functions. As protocol is defined, I don't need any additional info(bytes). So I do smth like this: class fast_binary_oarchive : // don't derive from binary_oarchive !!! public binary_oarchive_impl<fast_binary_oarchive> { typedef fast_binary_oarchive derived_t; #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS public: #else friend class boost::archive::detail::interface_oarchive<derived_t>; friend class basic_binary_oarchive<derived_t>; friend class basic_binary_oprimitive<derived_t, std::ostream>; friend class boost::archive::save_access; #endif // add base class to the places considered when matching // save function to a specific set of arguments. Note, this didn't // work on my MSVC 7.0 system // using binary_oarchive_impl<derived_t>::load_override; // so we use the sure-fire method below. This failed to work as well template<class T> void save_override(T & t, BOOST_PFTO int){ binary_oarchive_impl<fast_binary_oarchive>::save_override(t, 0); // verify that this program is in fact working by making sure // that arrays are getting passed here BOOST_STATIC_ASSERT(! (boost::is_array<T>::value) ); } // all the functions have emtpy body void save_override(const class_id_optional_type &, int) {} void save_override(const version_type&, int) {} void save_override(const class_id_type&, int) {} void save_override(const class_id_reference_type&, int) {} void save_override(const object_id_type&, int) {} void save_override(const object_reference_type&, int) {} void save_override(const tracking_type&, int) {} void save_override(const class_name_type&, int) {} public: fast_binary_oarchive(std::ostream & os, unsigned flags = no_header | no_codecvt | no_xml_tag_checking | no_tracking) : binary_oarchive_impl<derived_t>(os, flags) {} }; Is this correct? What features of the serialization library will not I be able to use?

Denis Kuznetsov wrote:
Hi,
I want to write my own archive class for reading/writing to some defined binary protocol. I'm deriving my archive class from the binary_oarchive_impl template and overriding save_override functions. As protocol is defined, I don't need any additional info(bytes). So I do smth like this:
I'm skeptical that this can be done.
// all the functions have emtpy body void save_override(const class_id_optional_type &, int) {}
no problem - optional
void save_override(const version_type&, int) {}
no versioning - load should be implemented to always return 0
void save_override(const class_id_type&, int) {} void save_override(const class_id_reference_type&, int) {}
not sure.
void save_override(const object_id_type&, int) {}
not sure
void save_override(const object_reference_type&, int) {}
better have tracking turned off - then this as well as corresponding load should never be called.
void save_override(const tracking_type&, int) {}
not sure - maybe load can always return no_tracking
void save_override(const class_name_type&, int) {}
only used for exporting pointers. so you wont' be able to do that.
public: fast_binary_oarchive(std::ostream & os, unsigned flags = no_header | no_codecvt | no_xml_tag_checking | no_tracking) : binary_oarchive_impl<derived_t>(os, flags) {}
no_tracking is not implemented has no effect
};
Is this correct? What features of the serialization library will not I be able to use?
As I said - I don't think this can be made to work without delving into the the internals of the library - but maybe I'm wrong. Robert Ramey
participants (2)
-
Denis Kuznetsov
-
Robert Ramey