The documentation "Serialization Archive Class Reference" on http://boost.org/libs/serialization/doc/archive_reference.html is wrong, or at lease very incomplete: Brian Stempel wrote:
I am wanting to serialize some C++ data structures into a binary stream, and I'm wanting to send that binary stream to an embedded python interpreter, where it can unpack the data and make use of it.
I have exactly the same problem: I need several kind of my own defined streamer. One is to write binary data 1:1, as Brian would like to do; my other idea is: Use the operator& syntax to stream either into a file, or into an SQL database, depending on the streamer (in my idea, the SQL-streamer would be similar to the existing XML-archive, but the XML-tags would here name tables and column names). Now I started by reading the "Serialization Archive Class Reference" on http://boost.org/libs/serialization/doc/archive_reference.html, which describes how to implement my own archive. Unfortunately, if I copy the code from the "simplest possible output archive" there into a header file, then write a code file that does nothing except including that header, the result is not compilable (GNU g++ 4.1.2). First problem (solved): friend class boost::archive::load_access is undefined, so I have to add a forward declaration: namespace boost { namespace archive { class load_access; } } Second problem (solved): I need to include boost/archive/detail/iserializer.hpp, otherwise I get: /usr/include/boost/archive/detail/interface_iarchive.hpp: In member function ‘const boost::archive::detail::basic_pointer_iserializer* boost::archive::detail::interface_iarchive<Archive>::register_type(T*)’: /usr/include/boost/archive/detail/interface_iarchive.hpp:54: error: ‘instantiate_pointer_iserializer’ is not a member of ‘boost::archive::detail’ /usr/include/boost/archive/detail/interface_iarchive.hpp:58: error: invalid use of undefined type ‘const struct boost::archive::detail::basic_pointer_iserializer’ /usr/include/boost/archive/detail/basic_iarchive.hpp:41: error: forward declaration of ‘const struct boost::archive::detail::basic_pointer_iserializer’ Then I can compile if the "main()" is empty. Third problem (unsolved): When I try to instantiate the archive abd store something in the archive, then it does not compile at all. See the attached files test.cpp and errors. Try: g++ test.cpp What's missing? One point is: There's no default constructor! - What is meant by the "int flags" parameter? - What else is missing? - Who can provide a minimal sample that works? Thank you Regards Marc