diff --git a/CMake/CMakeLists.txt b/CMake/CMakeLists.txt index f7040a1c..8b9bbbe8 100644 --- a/CMake/CMakeLists.txt +++ b/CMake/CMakeLists.txt @@ -157,6 +157,8 @@ add_library(serialization ${LINK_TYPE} ../src/extended_type_info.cpp ../src/polymorphic_iarchive.cpp ../src/polymorphic_oarchive.cpp + ../src/polymorphic_text_iarchive.cpp + ../src/polymorphic_text_oarchive.cpp ../src/stl_port.cpp ../src/text_iarchive.cpp ../src/text_oarchive.cpp @@ -240,10 +242,7 @@ function(polymorphic_archive_test test_name) set(amended_test_name ${test_name}_polymorphic_${archive-name}) message(STATUS ${amended_test_name}) add_executable(${amended_test_name} ../test/${test_name}.cpp ${arglist}) - set_property( - TARGET ${amended_test_name} - PROPERTY COMPILE_DEFINITIONS BOOST_ARCHIVE_TEST=polymorphic_${archive-name}.hpp - ) + target_compile_definitions(${amended_test_name} PUBLIC BOOST_ARCHIVE_TEST=polymorphic_${archive-name}.hpp) target_link_libraries(${amended_test_name} serialization wserialization filesystem) add_test(${amended_test_name} ${amended_test_name}) endforeach() @@ -257,13 +256,6 @@ target_link_libraries(dll_polymorphic_derived2 serialization) serialization_test(test_dll_exported) target_link_libraries(test_dll_exported dll_polymorphic_derived2) -if(0) -message(STATUS test_dll_exported) -add_executable(test_dll_exported ../test/test_dll_exported.cpp ../test/polymorphic_base.cpp) -target_link_libraries(test_dll_exported dll_polymorphic_derived2 serialization wserialization filesystem) -add_test(test_dll_exported test_dll_exported) -endif() - message(STATUS dll_a) add_library(dll_a SHARED ../test/dll_a.cpp) target_link_libraries(dll_a serialization) @@ -304,7 +296,6 @@ archive_test(test_derived) archive_test(test_derived_class A) archive_test(test_diamond) archive_test(test_diamond_complex) -archive_test(test_exported polymorphic_base polymorphic_derived2) archive_test(test_forward_list A) archive_test(test_forward_list_ptrs A) archive_test(test_helper_support) @@ -372,6 +363,7 @@ else() endif() endif() +polymorphic_archive_test(test_exported polymorphic_base polymorphic_derived2) polymorphic_archive_test(test_polymorphic test_polymorphic_A A) polymorphic_archive_test(test_polymorphic2 test_polymorphic2imp) polymorphic_archive_test(test_polymorphic_helper) diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index d7823a59..082847a5 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -74,6 +74,12 @@ SOURCES = stl_port text_iarchive text_oarchive + polymorphic_text_iarchive + polymorphic_text_oarchive + polymorphic_binary_iarchive + polymorphic_binary_oarchive + polymorphic_xml_iarchive + polymorphic_xml_oarchive void_cast archive_exception xml_grammar @@ -89,9 +95,13 @@ WSOURCES = basic_text_woprimitive text_wiarchive text_woarchive + polymorphic_text_wiarchive + polymorphic_text_woarchive xml_wgrammar xml_wiarchive xml_woarchive + polymorphic_xml_wiarchive + polymorphic_xml_woarchive ; lib boost_serialization diff --git a/include/boost/archive/polymorphic_binary_iarchive.hpp b/include/boost/archive/polymorphic_binary_iarchive.hpp index 4a898a8a..20559bd8 100644 --- a/include/boost/archive/polymorphic_binary_iarchive.hpp +++ b/include/boost/archive/polymorphic_binary_iarchive.hpp @@ -28,7 +28,7 @@ namespace boost { namespace archive { -class polymorphic_binary_iarchive : +class BOOST_SYMBOL_VISIBLE polymorphic_binary_iarchive : public detail::polymorphic_iarchive_route { public: diff --git a/include/boost/archive/polymorphic_binary_oarchive.hpp b/include/boost/archive/polymorphic_binary_oarchive.hpp index 931b243f..96febd7a 100644 --- a/include/boost/archive/polymorphic_binary_oarchive.hpp +++ b/include/boost/archive/polymorphic_binary_oarchive.hpp @@ -23,13 +23,15 @@ namespace boost { namespace archive { -typedef detail::polymorphic_oarchive_route< - binary_oarchive_impl< - binary_oarchive, - std::ostream::char_type, - std::ostream::traits_type - > - > polymorphic_binary_oarchive; +class BOOST_SYMBOL_VISIBLE polymorphic_binary_oarchive : + public detail::polymorphic_oarchive_route +{ +public: + polymorphic_binary_oarchive(std::ostream & os, unsigned int flags = 0) : + detail::polymorphic_oarchive_route(os, flags) + {} + ~polymorphic_binary_oarchive(){} +}; } // namespace archive } // namespace boost diff --git a/include/boost/archive/polymorphic_text_iarchive.hpp b/include/boost/archive/polymorphic_text_iarchive.hpp index 7bef2927..3e59bfe6 100644 --- a/include/boost/archive/polymorphic_text_iarchive.hpp +++ b/include/boost/archive/polymorphic_text_iarchive.hpp @@ -28,7 +28,7 @@ namespace boost { namespace archive { -class polymorphic_text_iarchive : +class BOOST_SYMBOL_VISIBLE polymorphic_text_iarchive : public detail::polymorphic_iarchive_route { public: diff --git a/include/boost/archive/polymorphic_text_oarchive.hpp b/include/boost/archive/polymorphic_text_oarchive.hpp index 457aad9f..233d37c7 100644 --- a/include/boost/archive/polymorphic_text_oarchive.hpp +++ b/include/boost/archive/polymorphic_text_oarchive.hpp @@ -23,9 +23,15 @@ namespace boost { namespace archive { -typedef detail::polymorphic_oarchive_route< - text_oarchive_impl -> polymorphic_text_oarchive; +class BOOST_SYMBOL_VISIBLE polymorphic_text_oarchive : + public detail::polymorphic_oarchive_route +{ +public: + polymorphic_text_oarchive(std::ostream & os, unsigned int flags = 0) : + detail::polymorphic_oarchive_route(os, flags) + {} + ~polymorphic_text_oarchive(){} +}; } // namespace archive } // namespace boost diff --git a/include/boost/archive/polymorphic_text_wiarchive.hpp b/include/boost/archive/polymorphic_text_wiarchive.hpp index 8466f05d..96afe0eb 100644 --- a/include/boost/archive/polymorphic_text_wiarchive.hpp +++ b/include/boost/archive/polymorphic_text_wiarchive.hpp @@ -32,7 +32,7 @@ namespace boost { namespace archive { -class polymorphic_text_wiarchive : +class BOOST_SYMBOL_VISIBLE polymorphic_text_wiarchive : public detail::polymorphic_iarchive_route { public: diff --git a/include/boost/archive/polymorphic_text_woarchive.hpp b/include/boost/archive/polymorphic_text_woarchive.hpp index 295625d1..fa0a3aec 100644 --- a/include/boost/archive/polymorphic_text_woarchive.hpp +++ b/include/boost/archive/polymorphic_text_woarchive.hpp @@ -27,9 +27,15 @@ namespace boost { namespace archive { -typedef detail::polymorphic_oarchive_route< - text_woarchive_impl -> polymorphic_text_woarchive; +class BOOST_SYMBOL_VISIBLE polymorphic_text_woarchive : + public detail::polymorphic_oarchive_route +{ +public: + polymorphic_text_woarchive(std::wostream & os, unsigned int flags = 0) : + detail::polymorphic_oarchive_route(os, flags) + {} + ~polymorphic_text_woarchive(){} +}; } // namespace archive } // namespace boost diff --git a/include/boost/archive/polymorphic_xml_iarchive.hpp b/include/boost/archive/polymorphic_xml_iarchive.hpp index 4dc3f894..0b17b551 100644 --- a/include/boost/archive/polymorphic_xml_iarchive.hpp +++ b/include/boost/archive/polymorphic_xml_iarchive.hpp @@ -28,7 +28,7 @@ namespace boost { namespace archive { -class polymorphic_xml_iarchive : +class BOOST_SYMBOL_VISIBLE polymorphic_xml_iarchive : public detail::polymorphic_iarchive_route { public: diff --git a/include/boost/archive/polymorphic_xml_oarchive.hpp b/include/boost/archive/polymorphic_xml_oarchive.hpp index 514f9e53..a9fc8242 100644 --- a/include/boost/archive/polymorphic_xml_oarchive.hpp +++ b/include/boost/archive/polymorphic_xml_oarchive.hpp @@ -23,10 +23,15 @@ namespace boost { namespace archive { -typedef detail::polymorphic_oarchive_route< - xml_oarchive_impl -> polymorphic_xml_oarchive; - +class BOOST_SYMBOL_VISIBLE polymorphic_xml_oarchive : + public detail::polymorphic_oarchive_route +{ +public: + polymorphic_xml_oarchive(std::ostream & os, unsigned int flags = 0) : + detail::polymorphic_oarchive_route(os, flags) + {} + ~polymorphic_xml_oarchive(){} +}; } // namespace archive } // namespace boost diff --git a/include/boost/archive/polymorphic_xml_wiarchive.hpp b/include/boost/archive/polymorphic_xml_wiarchive.hpp index d4ab7312..688ff4d0 100644 --- a/include/boost/archive/polymorphic_xml_wiarchive.hpp +++ b/include/boost/archive/polymorphic_xml_wiarchive.hpp @@ -27,7 +27,7 @@ namespace boost { namespace archive { -class polymorphic_xml_wiarchive : +class BOOST_SYMBOL_VISIBLE polymorphic_xml_wiarchive : public detail::polymorphic_iarchive_route { public: diff --git a/include/boost/archive/polymorphic_xml_woarchive.hpp b/include/boost/archive/polymorphic_xml_woarchive.hpp index dd8963fb..2606010d 100644 --- a/include/boost/archive/polymorphic_xml_woarchive.hpp +++ b/include/boost/archive/polymorphic_xml_woarchive.hpp @@ -7,7 +7,7 @@ #endif /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 -// polymorphic_xml_oarchive.hpp +// polymorphic_xml_woarchive.hpp // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . // Use, modification and distribution is subject to the Boost Software @@ -27,9 +27,15 @@ namespace boost { namespace archive { -typedef detail::polymorphic_oarchive_route< - xml_woarchive_impl -> polymorphic_xml_woarchive; +class BOOST_SYMBOL_VISIBLE polymorphic_xml_woarchive : + public detail::polymorphic_oarchive_route +{ +public: + polymorphic_xml_woarchive(std::wostream & os, unsigned int flags = 0) : + detail::polymorphic_oarchive_route(os, flags) + {} + ~polymorphic_xml_woarchive(){} +}; } // namespace archive } // namespace boost diff --git a/src/polymorphic_binary_iarchive.cpp b/src/polymorphic_binary_iarchive.cpp new file mode 100644 index 00000000..7fcca705 --- /dev/null +++ b/src/polymorphic_binary_iarchive.cpp @@ -0,0 +1,30 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_binary_iarchive.cpp: + +// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to 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) + +// See http://www.boost.org for updates, documentation, and revision history. + +#if (defined _MSC_VER) && (_MSC_VER == 1200) +# pragma warning (disable : 4786) // too long name, harmless warning +#endif + +#define BOOST_ARCHIVE_SOURCE +#include +#include + +// explicitly instantiate for this type of text stream +#include + +namespace boost { +namespace archive { +namespace detail { + +template class archive_serializer_map; + +} // detail +} // archive +} // boost diff --git a/src/polymorphic_binary_oarchive.cpp b/src/polymorphic_binary_oarchive.cpp new file mode 100644 index 00000000..8b66c5cb --- /dev/null +++ b/src/polymorphic_binary_oarchive.cpp @@ -0,0 +1,30 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_binary_oarchive.cpp: + +// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to 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) + +// See http://www.boost.org for updates, documentation, and revision history. + +#if (defined _MSC_VER) && (_MSC_VER == 1200) +# pragma warning (disable : 4786) // too long name, harmless warning +#endif + +#define BOOST_ARCHIVE_SOURCE +#include +#include + +// explicitly instantiate for this type of text stream +#include + +namespace boost { +namespace archive { +namespace detail { + +template class detail::archive_serializer_map; + +} // detail +} // archive +} // boost diff --git a/src/polymorphic_text_iarchive.cpp b/src/polymorphic_text_iarchive.cpp new file mode 100644 index 00000000..6404ec83 --- /dev/null +++ b/src/polymorphic_text_iarchive.cpp @@ -0,0 +1,30 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_text_iarchive.cpp: + +// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to 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) + +// See http://www.boost.org for updates, documentation, and revision history. + +#if (defined _MSC_VER) && (_MSC_VER == 1200) +# pragma warning (disable : 4786) // too long name, harmless warning +#endif + +#define BOOST_ARCHIVE_SOURCE +#include +#include + +// explicitly instantiate for this type of text stream +#include + +namespace boost { +namespace archive { +namespace detail { + +template class archive_serializer_map; + +} // detail +} // archive +} // boost diff --git a/src/polymorphic_text_oarchive.cpp b/src/polymorphic_text_oarchive.cpp new file mode 100644 index 00000000..4160a621 --- /dev/null +++ b/src/polymorphic_text_oarchive.cpp @@ -0,0 +1,30 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_text_oarchive.cpp: + +// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to 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) + +// See http://www.boost.org for updates, documentation, and revision history. + +#if (defined _MSC_VER) && (_MSC_VER == 1200) +# pragma warning (disable : 4786) // too long name, harmless warning +#endif + +#define BOOST_ARCHIVE_SOURCE +#include +#include + +// explicitly instantiate for this type of text stream +#include + +namespace boost { +namespace archive { +namespace detail { + +template class detail::archive_serializer_map; + +} // detail +} // archive +} // boost diff --git a/src/polymorphic_text_wiarchive.cpp b/src/polymorphic_text_wiarchive.cpp new file mode 100644 index 00000000..2089195a --- /dev/null +++ b/src/polymorphic_text_wiarchive.cpp @@ -0,0 +1,30 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_text_wiarchive.cpp: + +// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to 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) + +// See http://www.boost.org for updates, documentation, and revision history. + +#if (defined _MSC_VER) && (_MSC_VER == 1200) +# pragma warning (disable : 4786) // too long name, harmless warning +#endif + +#define BOOST_ARCHIVE_SOURCE +#include +#include + +// explicitly instantiate for this type of text stream +#include + +namespace boost { +namespace archive { +namespace detail { + +template class archive_serializer_map; + +} // detail +} // archive +} // boost diff --git a/src/polymorphic_text_woarchive.cpp b/src/polymorphic_text_woarchive.cpp new file mode 100644 index 00000000..514f1447 --- /dev/null +++ b/src/polymorphic_text_woarchive.cpp @@ -0,0 +1,30 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_text_woarchive.cpp: + +// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to 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) + +// See http://www.boost.org for updates, documentation, and revision history. + +#if (defined _MSC_VER) && (_MSC_VER == 1200) +# pragma warning (disable : 4786) // too long name, harmless warning +#endif + +#define BOOST_ARCHIVE_SOURCE +#include +#include + +// explicitly instantiate for this type of text stream +#include + +namespace boost { +namespace archive { +namespace detail { + +template class detail::archive_serializer_map; + +} // detail +} // archive +} // boost diff --git a/src/polymorphic_xml_iarchive.cpp b/src/polymorphic_xml_iarchive.cpp new file mode 100644 index 00000000..17ec7917 --- /dev/null +++ b/src/polymorphic_xml_iarchive.cpp @@ -0,0 +1,30 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_xml_iarchive.cpp: + +// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to 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) + +// See http://www.boost.org for updates, documentation, and revision history. + +#if (defined _MSC_VER) && (_MSC_VER == 1200) +# pragma warning (disable : 4786) // too long name, harmless warning +#endif + +#define BOOST_ARCHIVE_SOURCE +#include +#include + +// explicitly instantiate for this type of text stream +#include + +namespace boost { +namespace archive { +namespace detail { + +template class archive_serializer_map; + +} // detail +} // archive +} // boost diff --git a/src/polymorphic_xml_oarchive.cpp b/src/polymorphic_xml_oarchive.cpp new file mode 100644 index 00000000..124f899f --- /dev/null +++ b/src/polymorphic_xml_oarchive.cpp @@ -0,0 +1,30 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_xml_oarchive.cpp: + +// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to 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) + +// See http://www.boost.org for updates, documentation, and revision history. + +#if (defined _MSC_VER) && (_MSC_VER == 1200) +# pragma warning (disable : 4786) // too long name, harmless warning +#endif + +#define BOOST_ARCHIVE_SOURCE +#include +#include + +// explicitly instantiate for this type of text stream +#include + +namespace boost { +namespace archive { +namespace detail { + +template class detail::archive_serializer_map; + +} // detail +} // archive +} // boost diff --git a/src/polymorphic_xml_wiarchive.cpp b/src/polymorphic_xml_wiarchive.cpp new file mode 100644 index 00000000..1548c9ed --- /dev/null +++ b/src/polymorphic_xml_wiarchive.cpp @@ -0,0 +1,30 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_xml_wiarchive.cpp: + +// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to 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) + +// See http://www.boost.org for updates, documentation, and revision history. + +#if (defined _MSC_VER) && (_MSC_VER == 1200) +# pragma warning (disable : 4786) // too long name, harmless warning +#endif + +#define BOOST_ARCHIVE_SOURCE +#include +#include + +// explicitly instantiate for this type of text stream +#include + +namespace boost { +namespace archive { +namespace detail { + +template class archive_serializer_map; + +} // detail +} // archive +} // boost diff --git a/src/polymorphic_xml_woarchive.cpp b/src/polymorphic_xml_woarchive.cpp new file mode 100644 index 00000000..47989456 --- /dev/null +++ b/src/polymorphic_xml_woarchive.cpp @@ -0,0 +1,30 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_xml_woarchive.cpp: + +// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to 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) + +// See http://www.boost.org for updates, documentation, and revision history. + +#if (defined _MSC_VER) && (_MSC_VER == 1200) +# pragma warning (disable : 4786) // too long name, harmless warning +#endif + +#define BOOST_ARCHIVE_SOURCE +#include +#include + +// explicitly instantiate for this type of text stream +#include + +namespace boost { +namespace archive { +namespace detail { + +template class detail::archive_serializer_map; + +} // detail +} // archive +} // boost diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 3be6e8fa..37f5e392 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -70,7 +70,6 @@ test-suite "serialization" : [ test-bsl-run_files test_derived_class_ptr : A ] [ test-bsl-run_files test_diamond ] [ test-bsl-run_files test_diamond_complex ] - [ test-bsl-run_files test_exported : polymorphic_base polymorphic_derived2 ] [ test-bsl-run_files test_forward_list : A : : [ requires cxx11_hdr_forward_list ] ] # BOOST_NO_CXX11_HDR_FORWARD_LIST [ test-bsl-run_files test_forward_list_ptrs : A : : [ requires cxx11_hdr_forward_list ] ] # BOOST_NO_CXX11_HDR_FORWARD_LIST [ test-bsl-run_files test_helper_support ] @@ -118,6 +117,7 @@ test-suite "serialization" : [ test-bsl-run_files test_shared_ptr_multi_base ] [ test-bsl-run_files test_shared_ptr_132 : : : [ requires auto_ptr ] ] # BOOST_NO_AUTO_PTR + [ test-bsl-run_polymorphic_archive test_exported : polymorphic_base polymorphic_derived2 ] [ test-bsl-run_polymorphic_archive test_polymorphic : test_polymorphic_A A ] [ test-bsl-run_polymorphic_archive test_polymorphic2 : test_polymorphic2imp ] [ test-bsl-run_polymorphic_archive test_polymorphic_helper ] diff --git a/test/polymorphic_derived2.cpp b/test/polymorphic_derived2.cpp index 8890c161..06984fee 100644 --- a/test/polymorphic_derived2.cpp +++ b/test/polymorphic_derived2.cpp @@ -12,20 +12,12 @@ #include #include -#define POLYMORPHIC_BASE_EXPORT +#define POLYMORPHIC_BASE_IMPORT #include "polymorphic_base.hpp" #define POLYMORPHIC_DERIVED2_EXPORT #include "polymorphic_derived2.hpp" -template -POLYMORPHIC_DERIVED2_DLL_DECL -void polymorphic_derived2::serialize( - Archive &ar, - const unsigned int /* file_version */ -){ - ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(polymorphic_base); -} POLYMORPHIC_DERIVED2_DLL_DECL const char * polymorphic_derived2::get_key() const { return "polymorphic_derived2"; @@ -35,51 +27,12 @@ polymorphic_derived2::polymorphic_derived2(){} POLYMORPHIC_DERIVED2_DLL_DECL polymorphic_derived2::~polymorphic_derived2(){} -// instantiate code for text archives -#include -#include - -template -POLYMORPHIC_DERIVED2_DLL_DECL -void polymorphic_derived2::serialize( - boost::archive::text_oarchive & ar, - const unsigned int version -); -template -POLYMORPHIC_DERIVED2_DLL_DECL -void polymorphic_derived2::serialize( - boost::archive::text_iarchive & ar, - const unsigned int version -); - -/*// instantiate code for polymorphic archives +// instantiate code for polymorphic archives #include #include -template -POLYMORPHIC_DERIVED2_DLL_DECL -void polymorphic_derived2::serialize( - boost::archive::polymorphic_oarchive & ar, - const unsigned int version -); -template -POLYMORPHIC_DERIVED2_DLL_DECL -void polymorphic_derived2::serialize( - boost::archive::polymorphic_iarchive & ar, - const unsigned int version -); -*/ - // MWerks users can do this to make their code work BOOST_SERIALIZATION_MWERKS_BASE_AND_DERIVED(polymorphic_base, polymorphic_derived2) - -#if 0 -#include -BOOST_SERIALIZATION_FACTORY_0(polymorphic_derived2) - -template -POLYMORPHIC_DERIVED2_DLL_DECL -void polymorphic_derived2 * -boost::serialization::factory(std::va_list ap); -#endif +// note: export has to be AFTER #includes for all archive classes +BOOST_CLASS_EXPORT_IMPLEMENT(polymorphic_derived2) diff --git a/test/polymorphic_derived2.hpp b/test/polymorphic_derived2.hpp index b611f366..050c72b9 100644 --- a/test/polymorphic_derived2.hpp +++ b/test/polymorphic_derived2.hpp @@ -40,6 +40,9 @@ #include "polymorphic_base.hpp" +#include +#include + class POLYMORPHIC_DERIVED2_DLL_DECL polymorphic_derived2 : public polymorphic_base { @@ -48,7 +51,9 @@ class POLYMORPHIC_DERIVED2_DLL_DECL polymorphic_derived2 : void serialize( Archive &ar, const unsigned int /* file_version */ - ); + ){ + ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(polymorphic_base); + } virtual const char * get_key() const; public: polymorphic_derived2(); diff --git a/test/test_dll_exported.cpp b/test/test_dll_exported.cpp index 4360b682..397b5c90 100644 --- a/test/test_dll_exported.cpp +++ b/test/test_dll_exported.cpp @@ -36,7 +36,6 @@ namespace std{ #endif // for now, only test with simple text archive -#define BOOST_ARCHIVE_TEST text_archive.hpp #include "test_tools.hpp" #include diff --git a/test/test_exported.cpp b/test/test_exported.cpp index d95e8b8a..2f05ecea 100644 --- a/test/test_exported.cpp +++ b/test/test_exported.cpp @@ -24,14 +24,14 @@ namespace std{ #include #include -#include +#include +#include -#include #include "test_tools.hpp" #include "polymorphic_base.hpp" -class polymorphic_derived1 : +class polymorphic_derived1 : public polymorphic_base { friend class boost::serialization::access; @@ -46,45 +46,29 @@ public: ~polymorphic_derived1(){} }; -BOOST_CLASS_EXPORT(polymorphic_derived1) +BOOST_CLASS_EXPORT_KEY(polymorphic_derived1) +BOOST_CLASS_EXPORT_IMPLEMENT(polymorphic_derived1) // MWerks users can do this to make their code work BOOST_SERIALIZATION_MWERKS_BASE_AND_DERIVED(polymorphic_base, polymorphic_derived1) +#define POLYMORPHIC_DERIVED2_IMPORT #include "polymorphic_derived2.hpp" -//#include "polymorphic_derived2.cpp" - -// MWerks users can do this to make their code work -BOOST_SERIALIZATION_MWERKS_BASE_AND_DERIVED(polymorphic_base, polymorphic_derived2) - -BOOST_CLASS_EXPORT_IMPLEMENT(polymorphic_derived2) - -/* -template -void polymorphic_derived2::serialize( - test_oarchive & ar, - const unsigned int version -); -template -void polymorphic_derived2::serialize( - test_iarchive & ar, - const unsigned int version -); -*/ // save exported polymorphic class void save_exported(const char *testfile) { test_ostream os(testfile, TEST_STREAM_FLAGS); - test_oarchive oa(os, TEST_ARCHIVE_FLAGS); + test_oarchive oa_implementation(os, TEST_ARCHIVE_FLAGS); + boost::archive::polymorphic_oarchive & oa_interface = oa_implementation; polymorphic_base *rb1 = new polymorphic_derived1; polymorphic_base *rb2 = new polymorphic_derived2; // export will permit correct serialization // through a pointer to a base class - oa << BOOST_SERIALIZATION_NVP(rb1); - oa << BOOST_SERIALIZATION_NVP(rb2); + oa_interface << BOOST_SERIALIZATION_NVP(rb1); + oa_interface << BOOST_SERIALIZATION_NVP(rb2); delete rb1; delete rb2; @@ -94,14 +78,15 @@ void save_exported(const char *testfile) void load_exported(const char *testfile) { test_istream is(testfile, TEST_STREAM_FLAGS); - test_iarchive ia(is, TEST_ARCHIVE_FLAGS); + test_iarchive ia_implementation(is, TEST_ARCHIVE_FLAGS); + boost::archive::polymorphic_iarchive & ia_interface = ia_implementation; polymorphic_base *rb1 = NULL; polymorphic_base *rb2 = NULL; // export will permit correct serialization // through a pointer to a base class - ia >> BOOST_SERIALIZATION_NVP(rb1); + ia_interface >> BOOST_SERIALIZATION_NVP(rb1); BOOST_CHECK_MESSAGE( boost::serialization::type_info_implementation ::type::get_const_instance() @@ -111,7 +96,7 @@ void load_exported(const char *testfile) "restored pointer b1 not of correct type" ); - ia >> BOOST_SERIALIZATION_NVP(rb2); + ia_interface >> BOOST_SERIALIZATION_NVP(rb2); BOOST_CHECK_MESSAGE( boost::serialization::type_info_implementation ::type::get_const_instance() diff --git a/test/test_tools.hpp b/test/test_tools.hpp index 677e087e..ed45ee0b 100644 --- a/test/test_tools.hpp +++ b/test/test_tools.hpp @@ -225,6 +225,12 @@ main(int argc, char * argv[]){ #include "binary_archive.hpp" #include "xml_archive.hpp" #include "xml_warchive.hpp" + +#include "polymorphic_text_archive.hpp" +#include "polymorphic_text_warchive.hpp" +#include "polymorphic_binary_archive.hpp" +#include "polymorphic_xml_archive.hpp" +#include "polymorphic_xml_warchive.hpp" */ /////////////////////////////////////////////