Boost logo

Boost Users :

From: Bryan Donlan (bdonlan_at_[hidden])
Date: 2006-05-30 15:44:44

Hi all,

I'm currently working on a game engine, and hoping to use boost
serialization for the world saving code. It's nearly perfect except
for one snag - serializing pointers to sprite file classes.

Ideally I'd like to simply serialize the name of the sprite file, and
on deserialization find the file in the sprite cache 'gallery', but
this requires using split serialization in all the classes that
reference sprites. Is there a way to simply override the serialization
of /pointers/ to classes?

I've tried the following:
typedef creaturesImage *p_img;

namespace boost {
    namespace serialization {
        template <class Archive>
        inline void save(Archive &ar, const p_img &obj, const int version) {
            bool isNull = (obj == NULL);
            ar & isNull;
            if (!isNull) {
                std::string name = obj->serializedName();
                ar & name;

        template <class Archive>
        inline void load(Archive &ar, p_img &obj, const int version) {
            bool isNull;
            ar & isNull;
            if (isNull)
                obj = NULL;
            else {
                std::string name;
                ar & name;
                obj =;


However, this seems to be ignored; the compiler errors complain of
such things as
/usr/include/boost/serialization/access.hpp:109: error: 'class
creaturesImage' has no member named 'serialize'
(full log at

The code in question can be found at (ser/ subdirectory and
serialization.h particularly), or by subversion at
svn:// (rev 941 contains the code cited
here; build with make openc2e_s; dependency list at


Bryan Donlan

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at