=== modified file 'boost/archive/basic_archive.hpp' --- boost/archive/basic_archive.hpp 2008-05-29 13:43:23 +0000 +++ boost/archive/basic_archive.hpp 2008-05-29 13:46:27 +0000 @@ -82,6 +82,24 @@ } }; +struct class_name_optional_type : private boost::noncopyable { + char *t; + operator const char * & () const { + return const_cast(t); + } + operator char * () { + return t; + } + explicit class_name_optional_type(const char *key_) + : t(const_cast(key_)){} + explicit class_name_optional_type(char *key_) + : t(key_){} + class_name_optional_type & operator=(const class_name_optional_type & rhs){ + t = rhs.t; + return *this; + } +}; + enum archive_flags { no_header = 1, // suppress archive header info no_codecvt = 2, // suppress alteration of codecvt facet @@ -113,6 +131,7 @@ BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_reference_type, primitive_type) BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_optional_type, primitive_type) BOOST_CLASS_IMPLEMENTATION(boost::archive::class_name_type, primitive_type) +BOOST_CLASS_IMPLEMENTATION(boost::archive::class_name_optional_type, primitive_type) BOOST_CLASS_IMPLEMENTATION(boost::archive::object_id_type, primitive_type) BOOST_CLASS_IMPLEMENTATION(boost::archive::object_reference_type, primitive_type) BOOST_CLASS_IMPLEMENTATION(boost::archive::tracking_type, primitive_type) === modified file 'boost/archive/basic_binary_oarchive.hpp' --- boost/archive/basic_binary_oarchive.hpp 2008-05-29 13:43:23 +0000 +++ boost/archive/basic_binary_oarchive.hpp 2008-05-29 14:01:17 +0000 @@ -104,6 +104,12 @@ * this->This() << s; } + // explicitly convert to char * to avoid compile ambiguities + void save_override(const class_name_optional_type & t, int){ + const std::string s(t); + * this->This() << s; + } + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) init(); === modified file 'boost/archive/basic_text_oarchive.hpp' --- boost/archive/basic_text_oarchive.hpp 2008-05-29 13:43:23 +0000 +++ boost/archive/basic_text_oarchive.hpp 2008-05-29 13:59:56 +0000 @@ -112,6 +112,10 @@ const std::string s(t); * this->This() << s; } + void save_override(const class_name_optional_type & t, int){ + const std::string s(t); + * this->This() << s; + } BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) init(); === modified file 'boost/archive/basic_xml_oarchive.hpp' --- boost/archive/basic_xml_oarchive.hpp 2008-05-29 13:43:23 +0000 +++ boost/archive/basic_xml_oarchive.hpp 2008-05-29 14:00:34 +0000 @@ -115,6 +115,8 @@ BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) save_override(const class_name_type & t, int); BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + save_override(const class_name_optional_type & t, int); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) save_override(const tracking_type & t, int); BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) === modified file 'boost/archive/detail/basic_oarchive.hpp' --- boost/archive/detail/basic_oarchive.hpp 2008-05-29 13:43:23 +0000 +++ boost/archive/detail/basic_oarchive.hpp 2008-05-29 13:55:17 +0000 @@ -60,6 +60,7 @@ virtual void vsave(const class_id_optional_type t) = 0; virtual void vsave(const class_id_reference_type t) = 0; virtual void vsave(const class_name_type & t) = 0; + virtual void vsave(const class_name_optional_type & t) = 0; virtual void vsave(const tracking_type t) = 0; protected: basic_oarchive(unsigned int flags); === modified file 'boost/archive/detail/common_oarchive.hpp' --- boost/archive/detail/common_oarchive.hpp 2008-05-29 13:43:23 +0000 +++ boost/archive/detail/common_oarchive.hpp 2008-05-29 13:55:48 +0000 @@ -52,6 +52,9 @@ virtual void vsave(const class_name_type & t){ * this->This() << t; } + virtual void vsave(const class_name_optional_type & t){ + * this->This() << t; + } virtual void vsave(const tracking_type t){ * this->This() << t; } === modified file 'boost/archive/impl/basic_xml_oarchive.ipp' --- boost/archive/impl/basic_xml_oarchive.ipp 2008-05-29 13:43:23 +0000 +++ boost/archive/impl/basic_xml_oarchive.ipp 2008-05-29 13:58:53 +0000 @@ -201,6 +201,15 @@ } template BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_oarchive::save_override(const class_name_optional_type & t, int) +{ + const char * key = t; + if(NULL == key) + return; + write_attribute(CLASS_NAME(), key); +} +template +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) basic_xml_oarchive::save_override(const tracking_type & t, int) { write_attribute(TRACKING(), t.t); // extra .t is for borland === modified file 'libs/serialization/src/basic_oarchive.cpp' --- libs/serialization/src/basic_oarchive.cpp 2008-05-29 13:43:23 +0000 +++ libs/serialization/src/basic_oarchive.cpp 2008-06-08 14:35:36 +0000 @@ -315,28 +315,34 @@ const cobject_type & co = register_type(bos); if(! co.initialized){ ar.vsave(co.class_id); + const serialization::extended_type_info *eti = & bos.get_eti(); + const char * key = NULL; + if(NULL != eti) + key = eti->get_key(); + if(NULL == key){ + // without an external class name + // we won't be able to de-serialize it so bail now + boost::throw_exception( + archive_exception(archive_exception::unregistered_class) + ); + } + // if its a previously unregistered class if((cobject_info_set.size() > original_count)){ if(bos.is_polymorphic()){ - const serialization::extended_type_info *eti = & bos.get_eti(); - const char * key = NULL; - if(NULL != eti) - key = eti->get_key(); - if(NULL != key){ - // the following is required by IBM C++ compiler which - // makes a copy when passing a non-const to a const. This - // is permitted by the standard but rarely seen in practice - const class_name_type cn(key); - // write out the external class identifier - ar.vsave(cn); - } - else - // without an external class name - // we won't be able to de-serialize it so bail now - boost::throw_exception( - archive_exception(archive_exception::unregistered_class) - ); + // the following is required by IBM C++ compiler which + // makes a copy when passing a non-const to a const. This + // is permitted by the standard but rarely seen in practice + const class_name_type cn(key); + // write out the external class identifier + ar.vsave(cn); + } else { + const class_name_optional_type cno(key); + ar.vsave(cno); } + } else { + const class_name_optional_type cno(key); + ar.vsave(cno); } if(bos.class_info()){ ar.vsave(tracking_type(bos.tracking(m_flags)));