Index: boost/serialization/export.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/serialization/export.hpp,v retrieving revision 1.40 diff -u -r1.40 export.hpp --- boost/serialization/export.hpp 16 Dec 2006 05:53:26 -0000 1.40 +++ boost/serialization/export.hpp 23 Mar 2007 18:48:26 -0000 @@ -88,6 +88,26 @@ BOOST_DLLEXPORT guid_initializer(const char *key = 0) BOOST_USED ; }; +template +struct alias_initializer +{ + typedef typename + boost::serialization::type_info_implementation::type eti_type; + + static void alias_register(const char *alias) + { + eti_type::alias_register(alias); + } + + static const alias_initializer& get_instance(char const* alias) + { + static alias_initializer const instance(alias); + return instance; + } + + BOOST_DLLEXPORT alias_initializer(const char *alias = 0) BOOST_USED ; +}; + template BOOST_DLLEXPORT guid_initializer::guid_initializer(const char *key) @@ -101,6 +121,13 @@ instantiate_ptr_serialization((T*)0, 0); } +template +BOOST_DLLEXPORT alias_initializer::alias_initializer(const char *alias) +{ + if(0 != alias) + alias_register(alias); +} + // On many platforms, naming a specialization of this template is // enough to cause its argument to be instantiated. template @@ -161,6 +188,14 @@ = ::boost::archive::detail::guid_initializer< T >::get_instance(K); \ } +#define BOOST_CLASS_EXPORT_ALIAS(T, K) \ +namespace \ +{ \ + ::boost::archive::detail::alias_initializer< T > const& \ + BOOST_PP_CAT(boost_serialization_alias_initializer_, __LINE__) \ + = ::boost::archive::detail::alias_initializer< T >::get_instance(K); \ +} + #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205)) // CodeWarrior fails to construct static members of class templates Index: boost/serialization/extended_type_info.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/serialization/extended_type_info.hpp,v retrieving revision 1.9 diff -u -r1.9 extended_type_info.hpp --- boost/serialization/extended_type_info.hpp 11 Dec 2005 06:14:36 -0000 1.9 +++ boost/serialization/extended_type_info.hpp 23 Mar 2007 18:48:26 -0000 @@ -45,10 +45,12 @@ // so that different derivations of this class can be simultaneously // included in implementation of sets and maps. const char * m_type_info_key; - // flag to indicate wheter its been registered by type; + // flag to indicate whether it's been registered by type; bool m_self_registered; - // flag to indicate wheter its been registered by type; + // flag to indicate whether it's been registered by type; bool m_key_registered; + // flag to indicate whether it's been registered by type; + bool m_alias_registered; // flag indicating that no virtual function should be called here // this is necessary since it seems that at least one compiler (borland // and one version of gcc call less_than above when erasing even @@ -65,6 +67,7 @@ public: void self_register(); void key_register(const char *key); + void alias_register(const char *key); bool is_destructing() const { return m_is_destructing; } Index: boost/serialization/extended_type_info_no_rtti.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/serialization/extended_type_info_no_rtti.hpp,v retrieving revision 1.8 diff -u -r1.8 extended_type_info_no_rtti.hpp --- boost/serialization/extended_type_info_no_rtti.hpp 4 Feb 2006 21:16:08 -0000 1.8 +++ boost/serialization/extended_type_info_no_rtti.hpp 23 Mar 2007 18:48:26 -0000 @@ -91,6 +91,12 @@ eti->key_register(key); // initialize key and add to table eti->self_register(); // add type to type table } + static void + alias_register(const char * alias){ + boost::serialization::extended_type_info * eti; + eti = get_instance(); + eti->alias_register(alias); // initialize alias and add to table + } }; } // namespace detail Index: boost/serialization/extended_type_info_typeid.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/serialization/extended_type_info_typeid.hpp,v retrieving revision 1.9 diff -u -r1.9 extended_type_info_typeid.hpp --- boost/serialization/extended_type_info_typeid.hpp 12 Feb 2006 05:52:03 -0000 1.9 +++ boost/serialization/extended_type_info_typeid.hpp 23 Mar 2007 18:48:26 -0000 @@ -100,6 +100,10 @@ export_register(const char * key){ get_instance()->key_register(key); } + static void + alias_register(const char * alias){ + get_instance()->alias_register(alias); + } }; } // namespace detail Index: libs/serialization/doc/archive_reference.html =================================================================== RCS file: /cvsroot/boost/boost/libs/serialization/doc/archive_reference.html,v retrieving revision 1.9 diff -u -r1.9 archive_reference.html --- libs/serialization/doc/archive_reference.html 22 Jun 2006 07:21:22 -0000 1.9 +++ libs/serialization/doc/archive_reference.html 23 Mar 2007 18:48:39 -0000 @@ -240,11 +240,11 @@ EXCEPT for one special case.
  • Instances of a derived class are serialized through a base class pointer. -
  • Such instances are not "registered" neither implicitly nor explicitly. That - is, the macro BOOT_CLASS_EXPORT is used to instantiate the serialization +
  • Such instances are not "registered", either implicitly or explicitly. That + is, the macro BOOST_CLASS_EXPORT is used to instantiate the serialization code for the included archives.
-The problem here is that BOOT_CLASS_EXPORT only generates code for those archives +The problem here is that BOOST_CLASS_EXPORT only generates code for those archives included with the library - not those added subsequently. To generate code for newly created archive classes, the following should be used.

Index: libs/serialization/src/extended_type_info.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/serialization/src/extended_type_info.cpp,v
retrieving revision 1.12
diff -u -r1.12 extended_type_info.cpp
--- libs/serialization/src/extended_type_info.cpp	4 Oct 2006 05:38:29 -0000	1.12
+++ libs/serialization/src/extended_type_info.cpp	23 Mar 2007 18:48:39 -0000
@@ -13,6 +13,7 @@
 #endif
 
 #include 
+#include 
 #include 
 #include 
 
@@ -91,7 +92,7 @@
         // note: the following can't be used as this function
         // is called from a destructor of extended_type_info.
         // This will generate an error on some machines - which
-        // makes sense be cause by this time the derived class data
+        // makes sense because by this time the derived class data
         // might be gone.  Leave this in as a reminder not to do this
         #if 0
         tkmap::type::iterator it;
@@ -119,19 +120,19 @@
     struct key_compare
     {
         bool
-        operator()(const extended_type_info * lhs, const extended_type_info * rhs) const
+        operator()(const char * lhs, const char * rhs) const
         {
             // shortcut to exploit string pooling
-            if(lhs->get_key() == rhs->get_key())
+            if(lhs == rhs)
                 return false;
-            if(NULL == lhs->get_key())
+            if(NULL == lhs)
                 return true;
-            if(NULL == rhs->get_key())
+            if(NULL == rhs)
                 return false;
-            return std::strcmp(lhs->get_key(), rhs->get_key()) < 0; 
+            return std::strcmp(lhs, rhs) < 0;
         }
     };
-    typedef std::multiset type;
+    typedef std::map type;
     //typedef std::set type;
     type m_map;
     static ktmap * m_self;
@@ -153,8 +154,7 @@
     };
     static ktmap::type::iterator
     lookup(const char *key){
-        extended_type_info_arg arg(key);
-        return m_self->m_map.find(&arg);
+        return m_self->m_map.find(key);
     }
 
 public:
@@ -162,26 +162,25 @@
         m_self = NULL;
     }
     static void
-    insert(const extended_type_info * eti){
+    insert(const char * key, const extended_type_info * eti){
         if(NULL == m_self){
             static ktmap instance;
             m_self = & instance;
         }
         // make sure that all GUIDs are unique
-        assert(lookup(eti->get_key()) == m_self->m_map.end());
-        m_self->m_map.insert(eti);
+        assert(lookup(key) == m_self->m_map.end());
+        m_self->m_map.insert(std::make_pair(key, eti));
     }
     static const extended_type_info * 
     find(const char *key)
     {
         if(NULL == m_self)
             return NULL;
-        extended_type_info_arg arg(key);
         ktmap::type::const_iterator it;
-        it = m_self->m_map.find(&arg);
+        it = m_self->m_map.find(key);
         if(it == m_self->m_map.end())
             return NULL;
-        return *it;
+        return it->second;
     }
     static void 
     purge(const extended_type_info * eti){
@@ -190,7 +189,7 @@
         // note: the following can't be used as this function
         // is called from a destructor of extended_type_info.
         // This will generate an error on some machines - which
-        // makes sense be cause by this time the derived class data
+        // makes sense because by this time the derived class data
         // might be gone.  Leave this in as a reminder not to do this
         #if 0
         ktmap::type::iterator it;
@@ -205,7 +204,7 @@
         while(i != k){
             // note that the erase might invalidate i so save it here
             ktmap::type::iterator j = i++;
-            if(*j == eti)
+            if(j->second == eti)
                 m_self->m_map.erase(j);
         }
     }
@@ -233,10 +232,18 @@
     if(NULL == key_)
         return;
     m_key = key_;
-    detail::ktmap::insert(this);
+    detail::ktmap::insert(key_, this);
     m_key_registered = true;
 }
 
+BOOST_SERIALIZATION_DECL(void)  
+extended_type_info::alias_register(const char *alias) {
+    if(NULL == alias)
+        return;
+    detail::ktmap::insert(alias, this);
+    m_alias_registered = true;
+}
+
 BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) 
 extended_type_info::extended_type_info(
     const char * type_info_key
@@ -244,6 +251,7 @@
     m_type_info_key(type_info_key),
     m_self_registered(false),
     m_key_registered(false),
+    m_alias_registered(false),
     m_is_destructing(false)
 {}
 
@@ -254,7 +262,7 @@
     BOOST_TRY{
         if(m_self_registered)
             detail::tkmap::purge(this);
-        if(m_key_registered)
+        if(m_key_registered || m_alias_registered)
             detail::ktmap::purge(this);
         unregister_void_casts(this);
     }
Index: libs/serialization/test/Jamfile
===================================================================
RCS file: /cvsroot/boost/boost/libs/serialization/test/Jamfile,v
retrieving revision 1.37
diff -u -r1.37 Jamfile
--- libs/serialization/test/Jamfile	16 Dec 2006 06:06:30 -0000	1.37
+++ libs/serialization/test/Jamfile	23 Mar 2007 18:48:39 -0000
@@ -216,6 +216,9 @@
      [ test-bsl-run_files test_derived_class_ptr ]
      [ test-bsl-run_files test_diamond ]
      [ test-bsl-run_files test_exported ]
+     [ test-bsl-run_files test_alias_write_1 ]
+     [ test-bsl-run_files test_alias_write_2 ]
+     [ test-bsl-run_files test_alias_read ]
      [ test-bsl-run_files test_class_info_load ]
      [ test-bsl-run_files test_class_info_save ]
      [ test-bsl-run_files test_object ]
Index: libs/serialization/test/Jamfile.v2
===================================================================
RCS file: /cvsroot/boost/boost/libs/serialization/test/Jamfile.v2,v
retrieving revision 1.6
diff -u -r1.6 Jamfile.v2
--- libs/serialization/test/Jamfile.v2	10 Nov 2006 19:09:56 -0000	1.6
+++ libs/serialization/test/Jamfile.v2	23 Mar 2007 18:48:39 -0000
@@ -234,6 +234,9 @@
      [ test-bsl-run_files test_derived_class_ptr ]
      [ test-bsl-run_files test_diamond ]
      [ test-bsl-run_files test_exported ]
+     [ test-bsl-run_files test_alias_write_1 ]
+     [ test-bsl-run_files test_alias_write_2 ]
+     [ test-bsl-run_files test_alias_read ]
      [ test-bsl-run_files test_class_info_load ]
      [ test-bsl-run_files test_class_info_save ]
      [ test-bsl-run_files test_object ]
Index: libs/serialization/test/test_exported.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/serialization/test/test_exported.cpp,v
retrieving revision 1.8
diff -u -r1.8 test_exported.cpp
--- libs/serialization/test/test_exported.cpp	26 May 2006 21:38:12 -0000	1.8
+++ libs/serialization/test/test_exported.cpp	23 Mar 2007 18:48:39 -0000
@@ -88,7 +88,7 @@
     delete rb2;
 }
 
-// save exported polymorphic class
+// load exported polymorphic class
 void load_exported(const char *testfile)
 {
     test_istream is(testfile, TEST_STREAM_FLAGS);