|
SerializationCode Structure |
namespace
of a classes and templates is syncronized
with the directory in which the file is found. For example, the class declaration
boost::archive::text_oarchive
is included with the following declaration
#include <boost/archive/text_oarchive.hpp>
By convention, these header files are named: boost/serialization/xxx.hpp where xxx is the name of the header file which contains the type to be serialized. For example, the declaration
#include <boost/serialization/list.hpp>
includes the code to implement serialization of the STL
std::list
type. While
#include <boost/serialization/shared_ptr.hpp>
includes code to implement serialization of the BOOST boost::shared_ptr
type.
Note that including the serialization header for a type automatically includes the
appropriate header of the type to be serialized.
As of this writing, the library includes templates of all STL library templates as well
as templates for boost::optional
,
boost::shared_ptr
, and
boost::scoped_ptr
.
Presumably, this list will expand with the passage of time.
class_id_type
and others to
record information in archives that is required to reconstruct the original
data structure. These are handled exactly as any other serializable type.
That is, the can be handled as simple primitives such as they are in simple
text files, or with special code as they are in xml archives.
basic_xml_oarchive.hpp
includes code to guarentee that any object not attached to a name will
trap during compile time. On the other hand, basic_text_oarchive.hpp
contains code to strip out and ingore any names attached to objects.
The trade offs related to library implementation via pre-compiled code and templated headers are well known. This library uses both. It uses templated headers to generate code to serialize user and primitive types and it uses pre-compiled library code for that part of the code which only depends upon the archive type. Building of the library generates and compiles code for all archives implemented.
This is a ripe topic in itself. Its touched upon by the boost iterator libraries, View Template Library, and others.
The code for these iterators is really independent of this library. But since it hasn't been and probably won't be reviewed outside of this context. I've left in a directory local to the serialization library: boost/archive/iterators. These iterators are described in Dataflow Iterators.
© Copyright Robert Ramey 2002-2004. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)