mirror of
https://github.com/boostorg/serialization.git
synced 2026-02-26 17:02:17 +00:00
Merge trunk to release
[SVN r60484]
This commit is contained in:
@@ -111,9 +111,8 @@ test-suite "serialization" :
|
||||
if ! $(BOOST_ARCHIVE_LIST) {
|
||||
test-suite "serialization2" :
|
||||
[ test-bsl-run test_dll_exported : : dll_polymorphic_derived2_lib : <runtime-link>shared ]
|
||||
# [ test-bsl-run test_dll_plugin : : dll_polymorphic_derived2_lib : <runtime-link>shared ]
|
||||
[ compile test_dll_plugin.cpp ]
|
||||
[ test-bsl-run test_dll_simple : : dll_a_lib : <runtime-link>shared ]
|
||||
[ compile test_dll_plugin.cpp ]
|
||||
[ test-bsl-run test_private_ctor ]
|
||||
[ test-bsl-run test_reset_object_address : A ]
|
||||
[ test-bsl-run test_void_cast ]
|
||||
|
||||
@@ -15,6 +15,14 @@
|
||||
#define POLYMORPHIC_DERIVED2_EXPORT
|
||||
#include "polymorphic_derived2.hpp"
|
||||
|
||||
template<class Archive>
|
||||
void polymorphic_derived2::serialize(
|
||||
Archive &ar,
|
||||
const unsigned int /* file_version */
|
||||
){
|
||||
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(polymorphic_base);
|
||||
}
|
||||
|
||||
// instantiate code for text archives
|
||||
#include <boost/archive/text_oarchive.hpp>
|
||||
#include <boost/archive/text_iarchive.hpp>
|
||||
@@ -47,7 +55,6 @@ BOOST_SERIALIZATION_MWERKS_BASE_AND_DERIVED(polymorphic_base, polymorphic_derive
|
||||
// note: export has to be AFTER #includes for all archive classes
|
||||
BOOST_CLASS_EXPORT_IMPLEMENT(polymorphic_derived2)
|
||||
|
||||
// export plug-in not yet working !!!
|
||||
#if 0
|
||||
#include <boost/serialization/factory.hpp>
|
||||
BOOST_SERIALIZATION_FACTORY_0(polymorphic_derived2)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// derived1.hpp simple class test
|
||||
// polymorphic_derived2.hpp simple class test
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <boost/serialization/base_object.hpp>
|
||||
#include <boost/serialization/type_info_implementation.hpp>
|
||||
#include <boost/serialization/extended_type_info_typeid.hpp>
|
||||
#include <boost/serialization/factory.hpp>
|
||||
|
||||
#include <boost/preprocessor/empty.hpp>
|
||||
|
||||
@@ -45,9 +44,7 @@ class DLL_DECL(BOOST_PP_EMPTY()) 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 {
|
||||
return "polymorphic_derived2";
|
||||
}
|
||||
@@ -66,8 +63,6 @@ BOOST_CLASS_TYPE_INFO(
|
||||
boost::serialization::extended_type_info_typeid<polymorphic_derived2>
|
||||
)
|
||||
|
||||
BOOST_SERIALIZATION_FACTORY_0(polymorphic_derived2)
|
||||
|
||||
#undef DLL_DECL
|
||||
|
||||
#endif // POLYMORPHIC_DERIVED2_HPP
|
||||
|
||||
@@ -106,7 +106,7 @@ int main(int /* argc */, char * /* argv */[]){
|
||||
oa << BOOST_SERIALIZATION_NVP(c1_out);
|
||||
|
||||
check1 c1_non_const_out;
|
||||
oa << BOOST_SERIALIZATION_NVP(c1_non_const_out; // warn check_object_tracking
|
||||
oa << BOOST_SERIALIZATION_NVP(c1_non_const_out); // warn check_object_tracking
|
||||
|
||||
check1 * const c1_ptr_out = 0;
|
||||
oa << BOOST_SERIALIZATION_NVP(c1_ptr_out); // warn check_pointer_level
|
||||
|
||||
@@ -77,11 +77,13 @@ void save_exported(const char *testfile)
|
||||
|
||||
polymorphic_base *rb1 = new polymorphic_derived1;
|
||||
polymorphic_base *rb2 = new polymorphic_derived2;
|
||||
polymorphic_derived2 *rd21 = 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 << BOOST_SERIALIZATION_NVP(rd21);
|
||||
|
||||
delete rb1;
|
||||
delete rb2;
|
||||
@@ -95,6 +97,7 @@ void load_exported(const char *testfile)
|
||||
|
||||
polymorphic_base *rb1 = NULL;
|
||||
polymorphic_base *rb2 = NULL;
|
||||
polymorphic_derived2 *rd21 = NULL;
|
||||
|
||||
// export will permit correct serialization
|
||||
// through a pointer to a base class
|
||||
@@ -116,8 +119,18 @@ void load_exported(const char *testfile)
|
||||
::type::get_const_instance().get_derived_extended_type_info(*rb2),
|
||||
"restored pointer b2 not of correct type"
|
||||
);
|
||||
ia >> BOOST_SERIALIZATION_NVP(rd21);
|
||||
BOOST_CHECK_MESSAGE(
|
||||
boost::serialization::type_info_implementation<polymorphic_derived2>
|
||||
::type::get_const_instance()
|
||||
==
|
||||
* boost::serialization::type_info_implementation<polymorphic_derived2>
|
||||
::type::get_const_instance().get_derived_extended_type_info(*rd21),
|
||||
"restored pointer d2 not of correct type"
|
||||
);
|
||||
delete rb1;
|
||||
delete rb2;
|
||||
delete rd21;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -164,8 +164,8 @@ test_main( int /* argc */, char* /* argv */[] )
|
||||
BOOST_REQUIRE(NULL != testfile);
|
||||
|
||||
HINSTANCE hDLL; // Handle to DLL
|
||||
hDLL = LoadLibrary("dll_polymorphic_derived2.dll");
|
||||
BOOST_CHECK_MESSAGE((0 != hDLL), "Failed to find/load dll_polymorphic_derived2" );
|
||||
hDLL = LoadLibrary("plugin_polymorphic_derived2.dll");
|
||||
BOOST_CHECK_MESSAGE((0 != hDLL), "Failed to find/load plugin_polymorphic_derived2" );
|
||||
if(0 == hDLL)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
@@ -188,8 +188,8 @@ test_main( int /* argc */, char* /* argv */[] )
|
||||
BOOST_REQUIRE(NULL != testfile);
|
||||
|
||||
void * hDLL; // Handle to DLL
|
||||
hDLL = dlopen("dll_polymorphic_derived2.so", RTLD_NOW | RTLD_GLOBAL);
|
||||
BOOST_CHECK_MESSAGE((0 != hDLL), "Failed to find/load dll_polymorphic_derived2" );
|
||||
hDLL = dlopen("plugin_polymorphic_derived2.so", RTLD_NOW | RTLD_GLOBAL);
|
||||
BOOST_CHECK_MESSAGE((0 != hDLL), "Failed to find/load plugin_polymorphic_derived2" );
|
||||
if(0 == hDLL)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
|
||||
@@ -53,11 +53,28 @@ BOOST_SERIALIZATION_MWERKS_BASE_AND_DERIVED(polymorphic_base, polymorphic_derive
|
||||
|
||||
#include "polymorphic_derived2.hpp"
|
||||
|
||||
BOOST_CLASS_EXPORT_IMPLEMENT(polymorphic_derived2)
|
||||
|
||||
// MWerks users can do this to make their code work
|
||||
BOOST_SERIALIZATION_MWERKS_BASE_AND_DERIVED(polymorphic_base, polymorphic_derived2)
|
||||
|
||||
template<class Archive>
|
||||
void polymorphic_derived2::serialize(
|
||||
Archive &ar,
|
||||
const unsigned int /* file_version */
|
||||
){
|
||||
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(polymorphic_base);
|
||||
}
|
||||
|
||||
BOOST_CLASS_EXPORT_IMPLEMENT(polymorphic_derived2)
|
||||
|
||||
template EXPORT_DECL(void) polymorphic_derived2::serialize(
|
||||
test_oarchive & ar,
|
||||
const unsigned int version
|
||||
);
|
||||
template EXPORT_DECL(void) polymorphic_derived2::serialize(
|
||||
test_iarchive & ar,
|
||||
const unsigned int version
|
||||
);
|
||||
|
||||
// save exported polymorphic class
|
||||
void save_exported(const char *testfile)
|
||||
{
|
||||
|
||||
@@ -44,6 +44,14 @@ namespace std{
|
||||
#include "polymorphic_derived1.hpp"
|
||||
#include "polymorphic_derived2.hpp"
|
||||
|
||||
template<class Archive>
|
||||
void polymorphic_derived2::serialize(
|
||||
Archive &ar,
|
||||
const unsigned int /* file_version */
|
||||
){
|
||||
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(polymorphic_base);
|
||||
}
|
||||
|
||||
template void polymorphic_derived2::serialize(
|
||||
test_oarchive & ar,
|
||||
const unsigned int version
|
||||
|
||||
Reference in New Issue
Block a user