mirror of
https://github.com/boostorg/serialization.git
synced 2026-07-22 13:43:39 +00:00
Compare commits
106 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 738695b707 | |||
| 08455abe23 | |||
| 90e22bb58b | |||
| 449e659de3 | |||
| 4986fc2097 | |||
| 52cbea8c16 | |||
| ed435d5a31 | |||
| a362331b93 | |||
| b430b6d674 | |||
| 2792359662 | |||
| 7a078733a1 | |||
| 75c224103d | |||
| 297b7c3b52 | |||
| 8ca532a4d5 | |||
| 226af45461 | |||
| b4b8cbab00 | |||
| 3c438dfddb | |||
| 2b61be1285 | |||
| d3bb8d0e50 | |||
| 89dc4a26b1 | |||
| 6477759341 | |||
| 69d1b26937 | |||
| bc0279429b | |||
| b73329fe45 | |||
| 63b6ffa765 | |||
| 24024425f1 | |||
| 4ee479a03e | |||
| 8378c75f32 | |||
| 7d216b4761 | |||
| f94da2c724 | |||
| fea1826e06 | |||
| 8eb388fe39 | |||
| 8bbcca5341 | |||
| 0676016ce3 | |||
| be2846e2d1 | |||
| b87dc62e69 | |||
| 2c2a4a53d0 | |||
| eb35302b76 | |||
| a2a8890dfb | |||
| f4be906175 | |||
| 2e8e91a5cc | |||
| 089d57b855 | |||
| 0ba417dd1c | |||
| 9e90f233a1 | |||
| 9e7cd200e7 | |||
| d327f90bd8 | |||
| 8d0b0db5de | |||
| daf20da064 | |||
| 71851223c3 | |||
| 64dc620992 | |||
| 40314f94df | |||
| d21a064a69 | |||
| 3d179caaec | |||
| cd2f77defb | |||
| 621a3ea8a3 | |||
| 8b4e08490b | |||
| f44dc8da2c | |||
| 480a8c94b0 | |||
| 2557639490 | |||
| 932b4221ff | |||
| a5cb34ff8e | |||
| 0bccdf6da7 | |||
| ad1e1e5d5a | |||
| dd09b03d33 | |||
| 96f818ee03 | |||
| 791f1bde64 | |||
| d1ed17a656 | |||
| 8b7e756746 | |||
| eaf85795f3 | |||
| 81b44504c5 | |||
| bebea0fda9 | |||
| 0c8a1d615a | |||
| 632df7aab5 | |||
| 49f8f59da2 | |||
| 0a87904d14 | |||
| b0a794da38 | |||
| 62bf8fc1e1 | |||
| 09730b8741 | |||
| 1d86261581 | |||
| 6456a6d18f | |||
| c936a94c1a | |||
| 4dc778270a | |||
| 4bd64df332 | |||
| acbd1f88f9 | |||
| aba55e6180 | |||
| 51b1df323b | |||
| 247f223d82 | |||
| 619250c93a | |||
| 66ccdc00f1 | |||
| a8bbbea4e7 | |||
| c3552e1d03 | |||
| c518afa8ad | |||
| 29593efac2 | |||
| 5986edcfd3 | |||
| d558b6da91 | |||
| 4d11c54e60 | |||
| 1fda900179 | |||
| 0c7141fb78 | |||
| 6e24d1eb48 | |||
| fceaca0a34 | |||
| b98b458293 | |||
| 26366fecb5 | |||
| 058f1fed43 | |||
| 6b33d1cd4e | |||
| ec74c5a143 | |||
| 58b4f73c70 |
+81
-47
@@ -1,4 +1,4 @@
|
||||
# Copyright 2016 Peter Dimov
|
||||
# Copyright 2016, 2017 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@@ -6,66 +6,100 @@ language: cpp
|
||||
|
||||
sudo: false
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
cache:
|
||||
ccache: true
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /feature\/.*/
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- BOGUS_JOB=true
|
||||
|
||||
matrix:
|
||||
|
||||
exclude:
|
||||
- env: BOGUS_JOB=true
|
||||
|
||||
include:
|
||||
- os: linux
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc
|
||||
|
||||
- os: linux
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc-5
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc-6
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc-7
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc-7 LINK=static
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang LINK=static
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang LINK=static
|
||||
|
||||
install:
|
||||
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||
- cd ..
|
||||
- git clone -b $TRAVIS_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule init libs/align
|
||||
- git submodule init libs/array
|
||||
- git submodule init libs/assert
|
||||
- git submodule init libs/bind
|
||||
- git submodule init libs/compatibility
|
||||
- git submodule init libs/concept_check
|
||||
- git submodule init libs/config
|
||||
- git submodule init libs/container
|
||||
- git submodule init libs/core
|
||||
- git submodule init libs/detail
|
||||
- git submodule init libs/filesystem
|
||||
- git submodule init libs/function
|
||||
- git submodule init libs/functional
|
||||
- git submodule init libs/integer
|
||||
- git submodule init libs/intrusive
|
||||
- git submodule init libs/io
|
||||
- git submodule init libs/iterator
|
||||
- git submodule init libs/lexical_cast
|
||||
- git submodule init libs/math
|
||||
- git submodule init libs/move
|
||||
- git submodule init libs/mpl
|
||||
- git submodule init libs/numeric/conversion
|
||||
- git submodule init libs/optional
|
||||
- git submodule init libs/predef
|
||||
- git submodule init libs/preprocessor
|
||||
- git submodule init libs/range
|
||||
- git submodule init libs/smart_ptr
|
||||
- git submodule init libs/spirit
|
||||
- git submodule init libs/static_assert
|
||||
- git submodule init libs/system
|
||||
- git submodule init libs/throw_exception
|
||||
- git submodule init libs/tuple
|
||||
- git submodule init libs/type_index
|
||||
- git submodule init libs/type_traits
|
||||
- git submodule init libs/unordered
|
||||
- git submodule init libs/utility
|
||||
- git submodule init libs/variant
|
||||
- git submodule init tools/build
|
||||
- git submodule update --depth 1
|
||||
- git submodule update --init tools/build
|
||||
- git submodule update --init libs/config
|
||||
- git submodule update --init tools/boostdep
|
||||
- cp -r $TRAVIS_BUILD_DIR/* libs/serialization
|
||||
- python tools/boostdep/depinst/depinst.py serialization
|
||||
- ./bootstrap.sh
|
||||
- ./b2 headers
|
||||
|
||||
script:
|
||||
- TOOLSET=gcc,clang
|
||||
- if [ $TRAVIS_OS_NAME == osx ]; then TOOLSET=clang; fi
|
||||
- ./b2 libs/serialization/test toolset=$TOOLSET
|
||||
- ./b2 -j 3 libs/serialization/test toolset=$TOOLSET link=${LINK:-shared}
|
||||
|
||||
notifications:
|
||||
email:
|
||||
|
||||
+21
-5
@@ -26,7 +26,7 @@ add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
|
||||
if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
|
||||
add_definitions( -ftemplate-depth=300 )
|
||||
# we use gcc to test for C++03 compatibility
|
||||
add_definitions( std=c++03 )
|
||||
add_definitions( -std=c++03 )
|
||||
message(STATUS "compiler is g++ c++03")
|
||||
set(COMPILER_SUPPORTS_CXX11 FALSE)
|
||||
elseif( CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
|
||||
@@ -112,6 +112,7 @@ set(Boost_DETAILED_FAILURE_MSG true)
|
||||
set(Boost_FOUND true)
|
||||
|
||||
find_package(Boost REQUIRED COMPONENTS system filesystem)
|
||||
include(CheckIncludeFileCXX)
|
||||
|
||||
message(STATUS "Boost_FOUND is ${Boost_FOUND}")
|
||||
|
||||
@@ -165,7 +166,6 @@ add_library(serialization ${LINK_TYPE}
|
||||
../src/extended_type_info.cpp
|
||||
../src/polymorphic_iarchive.cpp
|
||||
../src/polymorphic_oarchive.cpp
|
||||
../src/singleton.cpp
|
||||
../src/stl_port.cpp
|
||||
../src/text_iarchive.cpp
|
||||
../src/text_oarchive.cpp
|
||||
@@ -251,7 +251,8 @@ endfunction(polymorphic_archive_test)
|
||||
|
||||
enable_testing()
|
||||
|
||||
# serialization(test_dll_exported dll_polymorphic_derived2_lib)
|
||||
serialization_test(test_dll_exported polymorphic_derived2 polymorphic_base)
|
||||
|
||||
# serialization(test_dll_simple dll_a_lib)
|
||||
# compile test_dll_plugin.cpp
|
||||
# Running the following test requires that the test know the directory
|
||||
@@ -265,6 +266,7 @@ serialization_test(test_mult_archive_types)
|
||||
serialization_test(test_iterators)
|
||||
serialization_test(test_iterators_base64)
|
||||
serialization_test(test_inclusion)
|
||||
serialization_test(test_inclusion2)
|
||||
serialization_test(test_smart_cast)
|
||||
serialization_test(test_codecvt_null ../src/codecvt_null)
|
||||
serialization_test(test_strong_typedef)
|
||||
@@ -320,6 +322,14 @@ archive_test(test_shared_ptr_multi_base)
|
||||
archive_test(test_shared_ptr_132)
|
||||
archive_test(test_simple_class A)
|
||||
archive_test(test_simple_class_ptr A)
|
||||
CHECK_INCLUDE_FILE_CXX(slist SLIST_FOUND)
|
||||
if(SLIST_FOUND)
|
||||
message(STATUS "slist header found")
|
||||
archive_test(test_slist A)
|
||||
archive_test(test_slist_ptr A)
|
||||
else()
|
||||
message(STATUS "slist header NOT found")
|
||||
endif()
|
||||
archive_test(test_stack A)
|
||||
archive_test(test_split)
|
||||
archive_test(test_tracking)
|
||||
@@ -333,12 +343,18 @@ archive_test(test_set_boost_unordered A)
|
||||
if(COMPILER_SUPPORTS_CXX11)
|
||||
archive_test(test_set_unordered A)
|
||||
else()
|
||||
archive_test(test_set_hashed A)
|
||||
CHECK_INCLUDE_FILE_CXX(hash_set HASH_SET_FOUND)
|
||||
if(HASH_SET_FOUND)
|
||||
archive_test(test_set_hashed A)
|
||||
endif()
|
||||
endif()
|
||||
if(COMPILER_SUPPORTS_CXX11)
|
||||
archive_test(test_map_unordered A)
|
||||
else()
|
||||
archive_test(test_map_hashed A)
|
||||
CHECK_INCLUDE_FILE_CXX(hash_map HASH_MAP_FOUND)
|
||||
if(HASH_MAP_FOUND)
|
||||
archive_test(test_map_hashed A)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
polymorphic_archive_test(test_polymorphic test_polymorphic_A A)
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
# Copyright 2016 Peter Dimov
|
||||
# Copyright 2016 Robert Ramey
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
version: 1.0.{build}-{branch}
|
||||
|
||||
shallow_clone: true
|
||||
|
||||
branches:
|
||||
only:
|
||||
- develop
|
||||
# - master
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- BUILD_TOOLSET: gcc
|
||||
BUILD_LINK: static
|
||||
- BUILD_TOOLSET: gcc
|
||||
BUILD_LINK: shared
|
||||
- BUILD_TOOLSET: msvc-14.0
|
||||
BUILD_LINK: static
|
||||
- BUILD_TOOLSET: msvc-14.0
|
||||
BUILD_LINK: shared
|
||||
|
||||
install:
|
||||
- cd ..
|
||||
- git clone -b %APPVEYOR_REPO_BRANCH% https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule init libs/align
|
||||
- git submodule init libs/array
|
||||
- git submodule init libs/assert
|
||||
- git submodule init libs/bind
|
||||
- git submodule init libs/compatibility
|
||||
- git submodule init libs/concept_check
|
||||
- git submodule init libs/config
|
||||
- git submodule init libs/container
|
||||
- git submodule init libs/container_hash
|
||||
- git submodule init libs/core
|
||||
- git submodule init libs/detail
|
||||
- git submodule init libs/filesystem
|
||||
- git submodule init libs/function
|
||||
- git submodule init libs/functional
|
||||
- git submodule init libs/integer
|
||||
- git submodule init libs/intrusive
|
||||
- git submodule init libs/io
|
||||
- git submodule init libs/iterator
|
||||
- git submodule init libs/lexical_cast
|
||||
- git submodule init libs/math
|
||||
- git submodule init libs/move
|
||||
- git submodule init libs/mpl
|
||||
- git submodule init libs/numeric/conversion
|
||||
- git submodule init libs/optional
|
||||
- git submodule init libs/predef
|
||||
- git submodule init libs/preprocessor
|
||||
- git submodule init libs/range
|
||||
- git submodule init libs/smart_ptr
|
||||
- git submodule init libs/spirit
|
||||
- git submodule init libs/static_assert
|
||||
- git submodule init libs/system
|
||||
- git submodule init libs/throw_exception
|
||||
- git submodule init libs/tuple
|
||||
- git submodule init libs/type_index
|
||||
- git submodule init libs/type_traits
|
||||
- git submodule init libs/unordered
|
||||
- git submodule init libs/utility
|
||||
- git submodule init libs/variant
|
||||
- git submodule init libs/winapi
|
||||
- git submodule init tools/build
|
||||
- git submodule update
|
||||
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\serialization
|
||||
- set PATH=C:\mingw-w64\i686-6.3.0-posix-dwarf-rt_v5-rev1\mingw32\bin;%CD%;%PATH%
|
||||
- bootstrap gcc
|
||||
- b2 headers
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- cd libs/serialization/test
|
||||
- b2 -j2 toolset=%BUILD_TOOLSET% link=%BUILD_LINK%
|
||||
+1
-2
@@ -82,8 +82,7 @@ SOURCES =
|
||||
xml_archive_exception
|
||||
codecvt_null
|
||||
utf8_codecvt_facet
|
||||
singleton
|
||||
;
|
||||
;
|
||||
|
||||
WSOURCES =
|
||||
basic_text_wiprimitive
|
||||
|
||||
+1
-1
@@ -292,7 +292,7 @@ included in the code module containing the serialization code.
|
||||
|
||||
</code></pre>
|
||||
|
||||
All of these archives implement the same inteface. Hence, it should suffice to describe only one
|
||||
All of these archives implement the same interface. Hence, it should suffice to describe only one
|
||||
of them in detail. For this purpose we will use the text archive.
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -568,10 +568,10 @@ void myclass::serialize(Archive & ar, const unsigned int version){
|
||||
...
|
||||
}
|
||||
|
||||
BOOST_EXPORT_CLASS_IMPLEMENT(my_class)
|
||||
BOOST_CLASS_EXPORT_IMPLEMENT(my_class)
|
||||
|
||||
#include <boost/archive/text_oarchive>
|
||||
#include <boost/archive/text_iarchive<
|
||||
#include <boost/archive/text_iarchive>
|
||||
template myclass::serialize(boost::archive::text_oarchive & ar, const unsigned int version);
|
||||
template myclass::serialize(boost::archive::text_iarchive & ar, const unsigned int version);
|
||||
... // repeat for each archive class to be used.
|
||||
|
||||
@@ -127,11 +127,11 @@ public:
|
||||
}
|
||||
|
||||
// used for text output
|
||||
operator int () const {
|
||||
operator base_type () const {
|
||||
return t;
|
||||
}
|
||||
// used for text input
|
||||
operator int_least16_t &() {
|
||||
operator base_type &() {
|
||||
return t;
|
||||
}
|
||||
bool operator==(const class_id_type & rhs) const {
|
||||
@@ -151,7 +151,10 @@ private:
|
||||
public:
|
||||
object_id_type(): t(0) {};
|
||||
// note: presumes that size_t >= unsigned int.
|
||||
explicit object_id_type(const std::size_t & t_) : t(t_){
|
||||
// use explicit cast to silence useless warning
|
||||
explicit object_id_type(const std::size_t & t_) : t(static_cast<base_type>(t_)){
|
||||
// make quadriple sure that we haven't lost any real integer
|
||||
// precision
|
||||
BOOST_ASSERT(t_ <= boost::integer_traits<base_type>::const_max);
|
||||
}
|
||||
object_id_type(const object_id_type & t_) :
|
||||
@@ -162,11 +165,11 @@ public:
|
||||
return *this;
|
||||
}
|
||||
// used for text output
|
||||
operator uint_least32_t () const {
|
||||
operator base_type () const {
|
||||
return t;
|
||||
}
|
||||
// used for text input
|
||||
operator uint_least32_t & () {
|
||||
operator base_type & () {
|
||||
return t;
|
||||
}
|
||||
bool operator==(const object_id_type & rhs) const {
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace std{
|
||||
|
||||
//#include <boost/mpl/placeholders.hpp>
|
||||
#include <boost/serialization/is_bitwise_serializable.hpp>
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include <boost/serialization/array_wrapper.hpp>
|
||||
|
||||
#include <boost/archive/basic_streambuf_locale_saver.hpp>
|
||||
#include <boost/archive/codecvt_null.hpp>
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace std{
|
||||
|
||||
//#include <boost/mpl/placeholders.hpp>
|
||||
#include <boost/serialization/is_bitwise_serializable.hpp>
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include <boost/serialization/array_wrapper.hpp>
|
||||
|
||||
#include <boost/archive/basic_streambuf_locale_saver.hpp>
|
||||
#include <boost/archive/codecvt_null.hpp>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
//
|
||||
// note the fact that on libraries without wide characters, ostream is
|
||||
// is not a specialization of basic_ostream which in fact is not defined
|
||||
// in such cases. So we can't use basic_ostream<IStream::char_type> but rather
|
||||
// in such cases. So we can't use basic_istream<IStream::char_type> but rather
|
||||
// use two template parameters
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
@@ -89,8 +89,7 @@ protected:
|
||||
// leaving the archive in an undetermined state
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
|
||||
load_override(class_id_type & t);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
|
||||
load_override(class_id_optional_type & /* t */){}
|
||||
void load_override(class_id_optional_type & /* t */){}
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
|
||||
load_override(object_id_type & t);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
|
||||
|
||||
@@ -18,8 +18,11 @@
|
||||
|
||||
#include <locale>
|
||||
#include <cstddef> // NULL, size_t
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
#include <cwchar> // for mbstate_t
|
||||
#endif
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/serialization/force_include.hpp>
|
||||
#include <boost/archive/detail/auto_link_archive.hpp>
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
@@ -60,9 +63,10 @@ public:
|
||||
};
|
||||
|
||||
template<>
|
||||
class BOOST_SYMBOL_VISIBLE codecvt_null<wchar_t> : public std::codecvt<wchar_t, char, std::mbstate_t>
|
||||
class BOOST_WARCHIVE_DECL codecvt_null<wchar_t> :
|
||||
public std::codecvt<wchar_t, char, std::mbstate_t>
|
||||
{
|
||||
virtual BOOST_WARCHIVE_DECL std::codecvt_base::result
|
||||
virtual std::codecvt_base::result
|
||||
do_out(
|
||||
std::mbstate_t & state,
|
||||
const wchar_t * first1,
|
||||
@@ -72,7 +76,7 @@ class BOOST_SYMBOL_VISIBLE codecvt_null<wchar_t> : public std::codecvt<wchar_t,
|
||||
char * last2,
|
||||
char * & next2
|
||||
) const;
|
||||
virtual BOOST_WARCHIVE_DECL std::codecvt_base::result
|
||||
virtual std::codecvt_base::result
|
||||
do_in(
|
||||
std::mbstate_t & state,
|
||||
const char * first1,
|
||||
@@ -92,7 +96,7 @@ public:
|
||||
explicit codecvt_null(std::size_t no_locale_manage = 0) :
|
||||
std::codecvt<wchar_t, char, std::mbstate_t>(no_locale_manage)
|
||||
{}
|
||||
virtual ~codecvt_null(){};
|
||||
//virtual ~codecvt_null(){};
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
|
||||
@@ -35,11 +35,12 @@ class extended_type_info;
|
||||
|
||||
// note: referred to as Curiously Recurring Template Patter (CRTP)
|
||||
template<class Archive>
|
||||
class BOOST_SYMBOL_VISIBLE common_iarchive :
|
||||
class BOOST_SYMBOL_VISIBLE common_iarchive :
|
||||
public basic_iarchive,
|
||||
public interface_iarchive<Archive>
|
||||
{
|
||||
friend class interface_iarchive<Archive>;
|
||||
friend class basic_iarchive;
|
||||
private:
|
||||
virtual void vload(version_type & t){
|
||||
* this->This() >> t;
|
||||
|
||||
@@ -38,6 +38,7 @@ class BOOST_SYMBOL_VISIBLE common_oarchive :
|
||||
public interface_oarchive<Archive>
|
||||
{
|
||||
friend class interface_oarchive<Archive>;
|
||||
friend class basic_oarchive;
|
||||
private:
|
||||
virtual void vsave(const version_type t){
|
||||
* this->This() << t;
|
||||
|
||||
@@ -57,11 +57,10 @@ namespace std{
|
||||
|
||||
#include <boost/serialization/assume_abstract.hpp>
|
||||
|
||||
#ifndef BOOST_MSVC
|
||||
#define DONT_USE_HAS_NEW_OPERATOR ( \
|
||||
BOOST_WORKAROUND(__IBMCPP__, < 1210) \
|
||||
|| defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x590) \
|
||||
)
|
||||
#if !defined(BOOST_MSVC) && \
|
||||
(BOOST_WORKAROUND(__IBMCPP__, < 1210) || \
|
||||
defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x590))
|
||||
#define DONT_USE_HAS_NEW_OPERATOR 1
|
||||
#else
|
||||
#define DONT_USE_HAS_NEW_OPERATOR 0
|
||||
#endif
|
||||
@@ -77,10 +76,10 @@ namespace std{
|
||||
#include <boost/serialization/type_info_implementation.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/void_cast.hpp>
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
#include <boost/serialization/singleton.hpp>
|
||||
#include <boost/serialization/wrapper.hpp>
|
||||
#include <boost/serialization/array_wrapper.hpp>
|
||||
|
||||
// the following is need only for dynamic cast of polymorphic pointers
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
@@ -90,6 +89,8 @@ namespace std{
|
||||
#include <boost/archive/detail/archive_serializer_map.hpp>
|
||||
#include <boost/archive/detail/check.hpp>
|
||||
|
||||
#include <boost/core/addressof.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace serialization {
|
||||
@@ -234,7 +235,7 @@ struct heap_allocation {
|
||||
// that the class might have class specific new with NO
|
||||
// class specific delete at all. Patches (compatible with
|
||||
// C++03) welcome!
|
||||
delete t;
|
||||
(operator delete)(t);
|
||||
}
|
||||
};
|
||||
struct doesnt_have_new_operator {
|
||||
@@ -243,7 +244,7 @@ struct heap_allocation {
|
||||
}
|
||||
static void invoke_delete(T * t) {
|
||||
// Note: I'm reliance upon automatic conversion from T * to void * here
|
||||
delete t;
|
||||
(operator delete)(t);
|
||||
}
|
||||
};
|
||||
static T * invoke_new() {
|
||||
@@ -406,7 +407,7 @@ struct load_non_pointer_type {
|
||||
struct load_standard {
|
||||
template<class T>
|
||||
static void invoke(Archive &ar, const T & t){
|
||||
void * x = & const_cast<T &>(t);
|
||||
void * x = boost::addressof(const_cast<T &>(t));
|
||||
ar.load_object(
|
||||
x,
|
||||
boost::serialization::singleton<
|
||||
@@ -484,7 +485,7 @@ struct load_pointer_type {
|
||||
};
|
||||
|
||||
template<class T>
|
||||
static const basic_pointer_iserializer * register_type(Archive &ar, const T & /*t*/){
|
||||
static const basic_pointer_iserializer * register_type(Archive &ar, const T* const /*t*/){
|
||||
// there should never be any need to load an abstract polymorphic
|
||||
// class pointer. Inhibiting code generation for this
|
||||
// permits abstract base classes to be used - note: exception
|
||||
@@ -523,7 +524,7 @@ struct load_pointer_type {
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static void check_load(T & /* t */){
|
||||
static void check_load(T * const /* t */){
|
||||
check_pointer_level< T >();
|
||||
check_pointer_tracking< T >();
|
||||
}
|
||||
@@ -537,8 +538,8 @@ struct load_pointer_type {
|
||||
|
||||
template<class Tptr>
|
||||
static void invoke(Archive & ar, Tptr & t){
|
||||
check_load(*t);
|
||||
const basic_pointer_iserializer * bpis_ptr = register_type(ar, *t);
|
||||
check_load(t);
|
||||
const basic_pointer_iserializer * bpis_ptr = register_type(ar, t);
|
||||
const basic_pointer_iserializer * newbpis_ptr = ar.load_pointer(
|
||||
// note major hack here !!!
|
||||
// I tried every way to convert Tptr &t (where Tptr might
|
||||
@@ -605,7 +606,7 @@ template<class Archive, class T>
|
||||
inline void load(Archive & ar, T &t){
|
||||
// if this assertion trips. It means we're trying to load a
|
||||
// const object with a compiler that doesn't have correct
|
||||
// funtion template ordering. On other compilers, this is
|
||||
// function template ordering. On other compilers, this is
|
||||
// handled below.
|
||||
detail::check_const_loading< T >();
|
||||
typedef
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <cstddef> // NULL
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
@@ -56,8 +57,9 @@
|
||||
#include <boost/serialization/type_info_implementation.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/void_cast.hpp>
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
#include <boost/serialization/array_wrapper.hpp>
|
||||
|
||||
#include <boost/serialization/singleton.hpp>
|
||||
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
@@ -67,6 +69,8 @@
|
||||
#include <boost/archive/detail/archive_serializer_map.hpp>
|
||||
#include <boost/archive/detail/check.hpp>
|
||||
|
||||
#include <boost/core/addressof.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace serialization {
|
||||
@@ -252,7 +256,7 @@ struct save_non_pointer_type {
|
||||
template<class T>
|
||||
static void invoke(Archive &ar, const T & t){
|
||||
ar.save_object(
|
||||
& t,
|
||||
boost::addressof(t),
|
||||
boost::serialization::singleton<
|
||||
oserializer<Archive, T>
|
||||
>::get_const_instance()
|
||||
@@ -260,6 +264,8 @@ struct save_non_pointer_type {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// adds class information to the archive. This includes
|
||||
// serialization level and class version
|
||||
struct save_conditional {
|
||||
@@ -337,7 +343,7 @@ struct save_pointer_type {
|
||||
};
|
||||
|
||||
template<class T>
|
||||
static const basic_pointer_oserializer * register_type(Archive &ar, T & /*t*/){
|
||||
static const basic_pointer_oserializer * register_type(Archive &ar, T* const /*t*/){
|
||||
// there should never be any need to save an abstract polymorphic
|
||||
// class pointer. Inhibiting code generation for this
|
||||
// permits abstract base classes to be used - note: exception
|
||||
@@ -404,7 +410,7 @@ struct save_pointer_type {
|
||||
// if its not a pointer to a more derived type
|
||||
const void *vp = static_cast<const void *>(&t);
|
||||
if(*this_type == *true_type){
|
||||
const basic_pointer_oserializer * bpos = register_type(ar, t);
|
||||
const basic_pointer_oserializer * bpos = register_type(ar, &t);
|
||||
ar.save_pointer(vp, bpos);
|
||||
return;
|
||||
}
|
||||
@@ -463,7 +469,7 @@ struct save_pointer_type {
|
||||
|
||||
template<class TPtr>
|
||||
static void invoke(Archive &ar, const TPtr t){
|
||||
register_type(ar, * t);
|
||||
register_type(ar, t);
|
||||
if(NULL == t){
|
||||
basic_oarchive & boa
|
||||
= boost::serialization::smart_cast_reference<basic_oarchive &>(ar);
|
||||
|
||||
@@ -9,26 +9,21 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
// std::codecvt_utf8 doesn't seem to work for msvc
|
||||
// versions prior to MSVC 14.0
|
||||
#ifdef BOOST_NO_STD_WSTREAMBUF
|
||||
#error "wide char i/o not supported on this platform"
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900 \
|
||||
|| defined( BOOST_NO_CXX11_HDR_CODECVT )
|
||||
#include <boost/archive/detail/decl.hpp>
|
||||
#define BOOST_UTF8_BEGIN_NAMESPACE \
|
||||
namespace boost { namespace archive { namespace detail {
|
||||
#define BOOST_UTF8_DECL BOOST_ARCHIVE_DECL
|
||||
#define BOOST_UTF8_END_NAMESPACE }}}
|
||||
// use boost's utf8 codecvt facet
|
||||
#include <boost/archive/detail/decl.hpp>
|
||||
#define BOOST_UTF8_BEGIN_NAMESPACE \
|
||||
namespace boost { namespace archive { namespace detail {
|
||||
#define BOOST_UTF8_DECL BOOST_ARCHIVE_DECL
|
||||
#define BOOST_UTF8_END_NAMESPACE }}}
|
||||
|
||||
#include <boost/detail/utf8_codecvt_facet.hpp>
|
||||
#include <boost/detail/utf8_codecvt_facet.hpp>
|
||||
|
||||
#undef BOOST_UTF8_END_NAMESPACE
|
||||
#undef BOOST_UTF8_DECL
|
||||
#undef BOOST_UTF8_BEGIN_NAMESPACE
|
||||
|
||||
#undef BOOST_UTF8_END_NAMESPACE
|
||||
#undef BOOST_UTF8_DECL
|
||||
#undef BOOST_UTF8_BEGIN_NAMESPACE
|
||||
#else
|
||||
#include <codecvt>
|
||||
namespace boost { namespace archive { namespace detail {
|
||||
typedef std::codecvt_utf8<wchar_t> utf8_codecvt_facet;
|
||||
} } }
|
||||
#endif // BOOST_NO_CXX11_HDR_CODECVT
|
||||
#endif // BOOST_ARCHIVE_DETAIL_UTF8_CODECVT_FACET_HPP
|
||||
|
||||
@@ -47,6 +47,10 @@ archive_serializer_map<Archive>::insert(const basic_serializer * bs){
|
||||
template<class Archive>
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
|
||||
archive_serializer_map<Archive>::erase(const basic_serializer * bs){
|
||||
BOOST_ASSERT(! boost::serialization::singleton<
|
||||
extra_detail::map<Archive>
|
||||
>::is_destroyed()
|
||||
);
|
||||
if(boost::serialization::singleton<
|
||||
extra_detail::map<Archive>
|
||||
>::is_destroyed())
|
||||
|
||||
@@ -84,6 +84,8 @@ basic_binary_iprimitive<Archive, Elem, Tr>::init()
|
||||
);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||
template<class Archive, class Elem, class Tr>
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
|
||||
basic_binary_iprimitive<Archive, Elem, Tr>::load(wchar_t * ws)
|
||||
@@ -93,6 +95,8 @@ basic_binary_iprimitive<Archive, Elem, Tr>::load(wchar_t * ws)
|
||||
load_binary(ws, l * sizeof(wchar_t) / sizeof(char));
|
||||
ws[l] = L'\0';
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
template<class Archive, class Elem, class Tr>
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
|
||||
@@ -110,7 +114,6 @@ basic_binary_iprimitive<Archive, Elem, Tr>::load(std::string & s)
|
||||
load_binary(&(*s.begin()), l);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
template<class Archive, class Elem, class Tr>
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
|
||||
basic_binary_iprimitive<Archive, Elem, Tr>::load(char * s)
|
||||
@@ -120,7 +123,6 @@ basic_binary_iprimitive<Archive, Elem, Tr>::load(char * s)
|
||||
load_binary(s, l);
|
||||
s[l] = '\0';
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_STD_WSTRING
|
||||
template<class Archive, class Elem, class Tr>
|
||||
|
||||
@@ -71,6 +71,7 @@ basic_binary_oprimitive<Archive, Elem, Tr>::save(const std::string &s)
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||
template<class Archive, class Elem, class Tr>
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
|
||||
basic_binary_oprimitive<Archive, Elem, Tr>::save(const wchar_t * ws)
|
||||
@@ -91,6 +92,7 @@ basic_binary_oprimitive<Archive, Elem, Tr>::save(const std::wstring &ws)
|
||||
save_binary(ws.data(), l * sizeof(wchar_t) / sizeof(char));
|
||||
}
|
||||
#endif
|
||||
#endif // BOOST_NO_CWCHAR
|
||||
|
||||
template<class Archive, class Elem, class Tr>
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL
|
||||
|
||||
@@ -56,7 +56,7 @@ text_wiarchive_impl<Archive>::load(std::string &s)
|
||||
s.resize(0);
|
||||
s.reserve(size);
|
||||
while(size-- > 0){
|
||||
int x = is.narrow(is.get(), '\0');
|
||||
char x = is.narrow(is.get(), '\0');
|
||||
s += x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,13 +161,13 @@ xml_wiarchive_impl<Archive>::xml_wiarchive_impl(
|
||||
gimpl(new xml_wgrammar())
|
||||
{
|
||||
if(0 == (flags & no_codecvt)){
|
||||
std::locale l = std::locale(
|
||||
archive_locale = std::locale(
|
||||
is_.getloc(),
|
||||
new boost::archive::detail::utf8_codecvt_facet
|
||||
);
|
||||
// libstdc++ crashes without this
|
||||
is_.sync();
|
||||
is_.imbue(l);
|
||||
is_.imbue(archive_locale);
|
||||
}
|
||||
if(0 == (flags & no_header))
|
||||
init();
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
|
||||
#include <cstring> // strlen
|
||||
#include <cstdlib> // mbtowc
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
#include <cwchar> // wcslen
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
@@ -101,7 +103,6 @@ xml_woarchive_impl<Archive>::save(const char * s){
|
||||
template<class Archive>
|
||||
BOOST_WARCHIVE_DECL void
|
||||
xml_woarchive_impl<Archive>::save(const wchar_t * ws){
|
||||
os << ws;
|
||||
typedef iterators::xml_escape<const wchar_t *> xmbtows;
|
||||
std::copy(
|
||||
xmbtows(ws),
|
||||
@@ -124,12 +125,12 @@ xml_woarchive_impl<Archive>::xml_woarchive_impl(
|
||||
basic_xml_oarchive<Archive>(flags)
|
||||
{
|
||||
if(0 == (flags & no_codecvt)){
|
||||
std::locale l = std::locale(
|
||||
archive_locale = std::locale(
|
||||
os_.getloc(),
|
||||
new boost::archive::detail::utf8_codecvt_facet
|
||||
);
|
||||
os_.flush();
|
||||
os_.imbue(l);
|
||||
os_.imbue(archive_locale);
|
||||
}
|
||||
if(0 == (flags & no_header))
|
||||
this->init();
|
||||
@@ -141,7 +142,7 @@ xml_woarchive_impl<Archive>::~xml_woarchive_impl(){
|
||||
if(std::uncaught_exception())
|
||||
return;
|
||||
if(0 == (this->get_flags() & no_header)){
|
||||
save(L"</boost_serialization>\n");
|
||||
os << L"</boost_serialization>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ template<class CharType>
|
||||
struct from_6_bit {
|
||||
typedef CharType result_type;
|
||||
CharType operator()(CharType t) const{
|
||||
const char * lookup_table =
|
||||
static const char * lookup_table =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789"
|
||||
|
||||
@@ -37,7 +37,7 @@ template<class CharType>
|
||||
struct to_6_bit {
|
||||
typedef CharType result_type;
|
||||
CharType operator()(CharType t) const{
|
||||
const signed char lookup_table[] = {
|
||||
static const signed char lookup_table[] = {
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,
|
||||
|
||||
@@ -102,7 +102,8 @@ public:
|
||||
super_t(base),
|
||||
m_bnext(NULL),
|
||||
m_bend(NULL),
|
||||
m_full(false)
|
||||
m_full(false),
|
||||
m_current_value(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
@@ -56,7 +56,7 @@ class istream_iterator :
|
||||
|
||||
//Access the value referred to
|
||||
Elem dereference() const {
|
||||
return m_istream->peek();
|
||||
return static_cast<Elem>(m_istream->peek());
|
||||
}
|
||||
|
||||
void increment(){
|
||||
@@ -75,14 +75,14 @@ public:
|
||||
}
|
||||
|
||||
istream_iterator() :
|
||||
m_istream(NULL)
|
||||
m_istream(NULL),
|
||||
m_current_value(NULL)
|
||||
{}
|
||||
|
||||
istream_iterator(const istream_iterator<Elem> & rhs) :
|
||||
m_istream(rhs.m_istream),
|
||||
m_current_value(rhs.m_current_value)
|
||||
{}
|
||||
|
||||
};
|
||||
|
||||
} // namespace iterators
|
||||
|
||||
@@ -18,14 +18,16 @@
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstddef> // size_t
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
#include <cwchar> // mbstate_t
|
||||
|
||||
#endif
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::mbstate_t;
|
||||
} // namespace std
|
||||
#endif
|
||||
|
||||
#include <boost/archive/detail/utf8_codecvt_facet.hpp>
|
||||
#include <boost/iterator/iterator_adaptor.hpp>
|
||||
|
||||
@@ -84,12 +86,15 @@ class mb_from_wchar
|
||||
wchar_t value = * this->base_reference();
|
||||
const wchar_t *wend;
|
||||
char *bend;
|
||||
std::codecvt_base::result r = m_codecvt_facet.out(
|
||||
m_mbs,
|
||||
& value, & value + 1, wend,
|
||||
m_buffer, m_buffer + sizeof(m_buffer), bend
|
||||
BOOST_VERIFY(
|
||||
m_codecvt_facet.out(
|
||||
m_mbs,
|
||||
& value, & value + 1, wend,
|
||||
m_buffer, m_buffer + sizeof(m_buffer), bend
|
||||
)
|
||||
==
|
||||
std::codecvt_base::ok
|
||||
);
|
||||
BOOST_ASSERT(std::codecvt_base::ok == r);
|
||||
m_bnext = 0;
|
||||
m_bend = bend - m_buffer;
|
||||
}
|
||||
|
||||
@@ -111,6 +111,7 @@ public:
|
||||
transform_width(T start) :
|
||||
super_t(Base(static_cast< T >(start))),
|
||||
m_buffer_out_full(false),
|
||||
m_buffer_out(0),
|
||||
// To disable GCC warning, but not truly necessary
|
||||
//(m_buffer_in will be initialized later before being
|
||||
//used because m_remaining_bits == 0)
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
#include <boost/assert.hpp>
|
||||
#include <cctype>
|
||||
#include <cstddef> // size_t
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
#include <cwchar> // mbstate_t
|
||||
#endif
|
||||
#include <algorithm> // copy
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <boost/serialization/throw_exception.hpp>
|
||||
@@ -42,11 +44,11 @@ class xml_unescape
|
||||
return unescape<xml_unescape<Base>, Base>::dereference();
|
||||
}
|
||||
public:
|
||||
// workaround msvc 7.1 ICU crash
|
||||
#if defined(BOOST_MSVC)
|
||||
// msvc versions prior to 14.0 crash with and ICE
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1900)
|
||||
typedef int value_type;
|
||||
#else
|
||||
typedef typename this_t::value_type value_type;
|
||||
typedef typename super_t::value_type value_type;
|
||||
#endif
|
||||
|
||||
void drain_residue(const char *literal);
|
||||
|
||||
@@ -65,10 +65,10 @@ protected:
|
||||
basic_text_oprimitive<std::ostream>::save(t);
|
||||
}
|
||||
void save(const version_type & t){
|
||||
save(static_cast<const unsigned int>(t));
|
||||
save(static_cast<unsigned int>(t));
|
||||
}
|
||||
void save(const boost::serialization::item_version_type & t){
|
||||
save(static_cast<const unsigned int>(t));
|
||||
save(static_cast<unsigned int>(t));
|
||||
}
|
||||
BOOST_ARCHIVE_DECL void
|
||||
save(const char * t);
|
||||
|
||||
@@ -78,10 +78,10 @@ protected:
|
||||
basic_text_oprimitive<std::wostream>::save(t);
|
||||
}
|
||||
void save(const version_type & t){
|
||||
save(static_cast<const unsigned int>(t));
|
||||
save(static_cast<unsigned int>(t));
|
||||
}
|
||||
void save(const boost::serialization::item_version_type & t){
|
||||
save(static_cast<const unsigned int>(t));
|
||||
save(static_cast<unsigned int>(t));
|
||||
}
|
||||
BOOST_WARCHIVE_DECL void
|
||||
save(const char * t);
|
||||
|
||||
@@ -44,7 +44,9 @@ inline std::size_t wcslen(const wchar_t * ws)
|
||||
|
||||
#else
|
||||
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
#include <cwchar>
|
||||
#endif
|
||||
#ifdef BOOST_NO_STDC_NAMESPACE
|
||||
namespace std{ using ::wcslen; }
|
||||
#endif
|
||||
|
||||
@@ -65,11 +65,11 @@ protected:
|
||||
}
|
||||
void
|
||||
save(const version_type & t){
|
||||
save(static_cast<const unsigned int>(t));
|
||||
save(static_cast<unsigned int>(t));
|
||||
}
|
||||
void
|
||||
save(const boost::serialization::item_version_type & t){
|
||||
save(static_cast<const unsigned int>(t));
|
||||
save(static_cast<unsigned int>(t));
|
||||
}
|
||||
BOOST_ARCHIVE_DECL void
|
||||
save(const char * t);
|
||||
|
||||
@@ -62,6 +62,7 @@ protected:
|
||||
friend class basic_xml_iarchive<Archive>;
|
||||
friend class load_access;
|
||||
#endif
|
||||
std::locale archive_locale;
|
||||
boost::scoped_ptr<xml_wgrammar> gimpl;
|
||||
std::wistream & get_is(){
|
||||
return is;
|
||||
|
||||
@@ -74,11 +74,11 @@ protected:
|
||||
}
|
||||
void
|
||||
save(const version_type & t){
|
||||
save(static_cast<const unsigned int>(t));
|
||||
save(static_cast<unsigned int>(t));
|
||||
}
|
||||
void
|
||||
save(const boost::serialization::item_version_type & t){
|
||||
save(static_cast<const unsigned int>(t));
|
||||
save(static_cast<unsigned int>(t));
|
||||
}
|
||||
BOOST_WARCHIVE_DECL void
|
||||
save(const char * t);
|
||||
|
||||
@@ -6,135 +6,32 @@
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
//#include <iostream>
|
||||
// for serialization of <array>. If <array> not supported by the standard
|
||||
// library - this file becomes empty. This is to avoid breaking backward
|
||||
// compatibiliy for applications which used this header to support
|
||||
// serialization of native arrays. Code to serialize native arrays is
|
||||
// now always include by default. RR
|
||||
|
||||
#include <boost/config.hpp> // msvc 6.0 needs this for warning suppression
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
|
||||
#include <iostream>
|
||||
#include <cstddef> // std::size_t
|
||||
namespace std{
|
||||
using ::size_t;
|
||||
} // namespace std
|
||||
#endif
|
||||
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/split_member.hpp>
|
||||
#include <boost/serialization/wrapper.hpp>
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
#include <boost/mpl/always.hpp>
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/mpl/bool_fwd.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
namespace boost { namespace serialization {
|
||||
|
||||
// traits to specify whether to use an optimized array serialization
|
||||
|
||||
template <class Archive>
|
||||
struct use_array_optimization : boost::mpl::always<boost::mpl::false_> {};
|
||||
|
||||
template<class T>
|
||||
class array_wrapper :
|
||||
public wrapper_traits<const array_wrapper< T > >
|
||||
{
|
||||
private:
|
||||
array_wrapper & operator=(const array_wrapper & rhs);
|
||||
// note: I would like to make the copy constructor private but this breaks
|
||||
// make_array. So I make make_array a friend
|
||||
template<class Tx, class S>
|
||||
friend const boost::serialization::array_wrapper<Tx> make_array(Tx * t, S s);
|
||||
public:
|
||||
|
||||
array_wrapper(const array_wrapper & rhs) :
|
||||
m_t(rhs.m_t),
|
||||
m_element_count(rhs.m_element_count)
|
||||
{}
|
||||
public:
|
||||
array_wrapper(T * t, std::size_t s) :
|
||||
m_t(t),
|
||||
m_element_count(s)
|
||||
{}
|
||||
|
||||
// default implementation
|
||||
template<class Archive>
|
||||
void serialize_optimized(Archive &ar, const unsigned int, mpl::false_ ) const
|
||||
{
|
||||
// default implemention does the loop
|
||||
std::size_t c = count();
|
||||
T * t = address();
|
||||
while(0 < c--)
|
||||
ar & boost::serialization::make_nvp("item", *t++);
|
||||
}
|
||||
|
||||
// optimized implementation
|
||||
template<class Archive>
|
||||
void serialize_optimized(Archive &ar, const unsigned int version, mpl::true_ )
|
||||
{
|
||||
boost::serialization::split_member(ar, *this, version);
|
||||
}
|
||||
|
||||
// default implementation
|
||||
template<class Archive>
|
||||
void save(Archive &ar, const unsigned int version) const
|
||||
{
|
||||
ar.save_array(*this,version);
|
||||
}
|
||||
|
||||
// default implementation
|
||||
template<class Archive>
|
||||
void load(Archive &ar, const unsigned int version)
|
||||
{
|
||||
ar.load_array(*this,version);
|
||||
}
|
||||
|
||||
// default implementation
|
||||
template<class Archive>
|
||||
void serialize(Archive &ar, const unsigned int version)
|
||||
{
|
||||
typedef typename
|
||||
boost::serialization::use_array_optimization<Archive>::template apply<
|
||||
typename remove_const< T >::type
|
||||
>::type use_optimized;
|
||||
serialize_optimized(ar,version,use_optimized());
|
||||
}
|
||||
|
||||
T * address() const
|
||||
{
|
||||
return m_t;
|
||||
}
|
||||
|
||||
std::size_t count() const
|
||||
{
|
||||
return m_element_count;
|
||||
}
|
||||
|
||||
private:
|
||||
T * const m_t;
|
||||
const std::size_t m_element_count;
|
||||
};
|
||||
|
||||
template<class T, class S>
|
||||
inline
|
||||
const array_wrapper< T > make_array(T* t, S s){
|
||||
const array_wrapper< T > a(t, s);
|
||||
return a;
|
||||
}
|
||||
|
||||
} } // end namespace boost::serialization
|
||||
|
||||
// I can't figure out why BOOST_NO_CXX11_HDR_ARRAY
|
||||
// has been set for clang-11. So just make sure
|
||||
// it's reset now. Needs further research!!!
|
||||
|
||||
#if defined(_LIBCPP_VERSION)
|
||||
#undef BOOST_NO_CXX11_HDR_ARRAY
|
||||
#endif
|
||||
#include <boost/serialization/array_wrapper.hpp>
|
||||
|
||||
#ifndef BOOST_NO_CXX11_HDR_ARRAY
|
||||
|
||||
#include <array>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
|
||||
namespace boost { namespace serialization {
|
||||
// implement serialization for std::array
|
||||
|
||||
template <class Archive, class T, std::size_t N>
|
||||
void serialize(Archive& ar, std::array<T,N>& a, const unsigned int /* version */)
|
||||
{
|
||||
@@ -145,27 +42,7 @@ void serialize(Archive& ar, std::array<T,N>& a, const unsigned int /* version */
|
||||
|
||||
}
|
||||
} } // end namespace boost::serialization
|
||||
#endif
|
||||
|
||||
#include <boost/array.hpp>
|
||||
|
||||
namespace boost { namespace serialization {
|
||||
// implement serialization for boost::array
|
||||
template <class Archive, class T, std::size_t N>
|
||||
void serialize(Archive& ar, boost::array<T,N>& a, const unsigned int /* version */)
|
||||
{
|
||||
ar & boost::serialization::make_nvp("elems", a.elems);
|
||||
}
|
||||
|
||||
} } // end namespace boost::serialization
|
||||
|
||||
#define BOOST_SERIALIZATION_USE_ARRAY_OPTIMIZATION(Archive) \
|
||||
namespace boost { namespace serialization { \
|
||||
template <> struct use_array_optimization<Archive> { \
|
||||
template <class ValueType> \
|
||||
struct apply : boost::mpl::apply1<Archive::use_array_optimization \
|
||||
, typename boost::remove_const<ValueType>::type \
|
||||
>::type {}; \
|
||||
}; }}
|
||||
#endif // BOOST_NO_CXX11_HDR_ARRAY
|
||||
|
||||
#endif //BOOST_SERIALIZATION_ARRAY_HPP
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef BOOST_SERIALIZATION_ARRAY_OPTIMIZATON_HPP
|
||||
#define BOOST_SERIALIZATION_ARRAY_OPTIMIZATON_HPP
|
||||
|
||||
// (C) Copyright 2005 Matthias Troyer and Dave Abrahams
|
||||
// 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)
|
||||
|
||||
#include <boost/config.hpp> // msvc 6.0 needs this for warning suppression
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::size_t;
|
||||
} // namespace std
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/always.hpp>
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
|
||||
namespace boost { namespace serialization {
|
||||
|
||||
template <class Archive>
|
||||
struct use_array_optimization : boost::mpl::always<boost::mpl::false_> {};
|
||||
|
||||
} } // end namespace boost::serialization
|
||||
|
||||
#define BOOST_SERIALIZATION_USE_ARRAY_OPTIMIZATION(Archive) \
|
||||
namespace boost { namespace serialization { \
|
||||
template <> struct use_array_optimization<Archive> { \
|
||||
template <class ValueType> \
|
||||
struct apply : boost::mpl::apply1<Archive::use_array_optimization \
|
||||
, typename boost::remove_const<ValueType>::type \
|
||||
>::type {}; \
|
||||
}; }}
|
||||
|
||||
#endif //BOOST_SERIALIZATION_ARRAY_OPTIMIZATON_HPP
|
||||
@@ -0,0 +1,121 @@
|
||||
#ifndef BOOST_SERIALIZATION_ARRAY_WRAPPER_HPP
|
||||
#define BOOST_SERIALIZATION_ARRAY_WRAPPER_HPP
|
||||
|
||||
// (C) Copyright 2005 Matthias Troyer and Dave Abrahams
|
||||
// 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)
|
||||
|
||||
//#include <iostream>
|
||||
|
||||
#include <boost/config.hpp> // msvc 6.0 needs this for warning suppression
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::size_t;
|
||||
} // namespace std
|
||||
#endif
|
||||
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/split_member.hpp>
|
||||
#include <boost/serialization/wrapper.hpp>
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
#include <boost/serialization/array_optimization.hpp>
|
||||
#include <boost/mpl/always.hpp>
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/mpl/bool_fwd.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
|
||||
namespace boost { namespace serialization {
|
||||
|
||||
template<class T>
|
||||
class array_wrapper :
|
||||
public wrapper_traits<const array_wrapper< T > >
|
||||
{
|
||||
private:
|
||||
array_wrapper & operator=(const array_wrapper & rhs);
|
||||
// note: I would like to make the copy constructor private but this breaks
|
||||
// make_array. So I make make_array a friend
|
||||
template<class Tx, class S>
|
||||
friend const boost::serialization::array_wrapper<Tx> make_array(Tx * t, S s);
|
||||
public:
|
||||
|
||||
array_wrapper(const array_wrapper & rhs) :
|
||||
m_t(rhs.m_t),
|
||||
m_element_count(rhs.m_element_count)
|
||||
{}
|
||||
public:
|
||||
array_wrapper(T * t, std::size_t s) :
|
||||
m_t(t),
|
||||
m_element_count(s)
|
||||
{}
|
||||
|
||||
// default implementation
|
||||
template<class Archive>
|
||||
void serialize_optimized(Archive &ar, const unsigned int, mpl::false_ ) const
|
||||
{
|
||||
// default implemention does the loop
|
||||
std::size_t c = count();
|
||||
T * t = address();
|
||||
while(0 < c--)
|
||||
ar & boost::serialization::make_nvp("item", *t++);
|
||||
}
|
||||
|
||||
// optimized implementation
|
||||
template<class Archive>
|
||||
void serialize_optimized(Archive &ar, const unsigned int version, mpl::true_ )
|
||||
{
|
||||
boost::serialization::split_member(ar, *this, version);
|
||||
}
|
||||
|
||||
// default implementation
|
||||
template<class Archive>
|
||||
void save(Archive &ar, const unsigned int version) const
|
||||
{
|
||||
ar.save_array(*this,version);
|
||||
}
|
||||
|
||||
// default implementation
|
||||
template<class Archive>
|
||||
void load(Archive &ar, const unsigned int version)
|
||||
{
|
||||
ar.load_array(*this,version);
|
||||
}
|
||||
|
||||
// default implementation
|
||||
template<class Archive>
|
||||
void serialize(Archive &ar, const unsigned int version)
|
||||
{
|
||||
typedef typename
|
||||
boost::serialization::use_array_optimization<Archive>::template apply<
|
||||
typename remove_const< T >::type
|
||||
>::type use_optimized;
|
||||
serialize_optimized(ar,version,use_optimized());
|
||||
}
|
||||
|
||||
T * address() const
|
||||
{
|
||||
return m_t;
|
||||
}
|
||||
|
||||
std::size_t count() const
|
||||
{
|
||||
return m_element_count;
|
||||
}
|
||||
|
||||
private:
|
||||
T * const m_t;
|
||||
const std::size_t m_element_count;
|
||||
};
|
||||
|
||||
template<class T, class S>
|
||||
inline
|
||||
const array_wrapper< T > make_array(T* t, S s){
|
||||
const array_wrapper< T > a(t, s);
|
||||
return a;
|
||||
}
|
||||
|
||||
} } // end namespace boost::serialization
|
||||
|
||||
|
||||
#endif //BOOST_SERIALIZATION_ARRAY_WRAPPER_HPP
|
||||
@@ -55,7 +55,7 @@ struct binary_object :
|
||||
m_size = rhs.m_size;
|
||||
return *this;
|
||||
}
|
||||
binary_object(/* const */ void * const t, std::size_t size) :
|
||||
binary_object(const void * const t, std::size_t size) :
|
||||
m_t(t),
|
||||
m_size(size)
|
||||
{}
|
||||
@@ -69,7 +69,7 @@ struct binary_object :
|
||||
// wrappers follow the naming convention make_xxxxx
|
||||
inline
|
||||
const binary_object
|
||||
make_binary_object(/* const */ void * t, std::size_t size){
|
||||
make_binary_object(const void * t, std::size_t size){
|
||||
return binary_object(t, size);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef BOOST_SERIALIZATION_BOOST_ARRAY_HPP
|
||||
#define BOOST_SERIALIZATION_BOOST_ARRAY_HPP
|
||||
|
||||
// (C) Copyright 2005 Matthias Troyer and Dave Abrahams
|
||||
// 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)
|
||||
|
||||
//#include <iostream>
|
||||
|
||||
#include <boost/config.hpp> // msvc 6.0 needs this for warning suppression
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::size_t;
|
||||
} // namespace std
|
||||
#endif
|
||||
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/array.hpp>
|
||||
|
||||
namespace boost { namespace serialization {
|
||||
// implement serialization for boost::array
|
||||
template <class Archive, class T, std::size_t N>
|
||||
void serialize(Archive& ar, boost::array<T,N>& a, const unsigned int /* version */)
|
||||
{
|
||||
ar & boost::serialization::make_nvp("elems", a.elems);
|
||||
}
|
||||
|
||||
} } // end namespace boost::serialization
|
||||
|
||||
|
||||
#endif //BOOST_SERIALIZATION_BOOST_ARRAY_HPP
|
||||
@@ -64,7 +64,7 @@ collection_load_impl(
|
||||
Archive & ar,
|
||||
T & t,
|
||||
collection_size_type count,
|
||||
item_version_type
|
||||
item_version_type /*item_version*/
|
||||
){
|
||||
t.resize(count);
|
||||
typename T::iterator hint;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
// helper function templates for serialization of collections
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/serialization.hpp>
|
||||
#include <boost/serialization/version.hpp>
|
||||
@@ -60,7 +61,7 @@ inline void save_collection(
|
||||
// note borland emits a no-op without the explicit namespace
|
||||
boost::serialization::save_construct_data_adl(
|
||||
ar,
|
||||
&(*it),
|
||||
boost::addressof(*it),
|
||||
item_version
|
||||
);
|
||||
ar << boost::serialization::make_nvp("item", *it++);
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
// (C) Copyright 2005 Matthias Troyer
|
||||
// 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.
|
||||
|
||||
#ifndef BOOST_SERIALIZATION_DETAIL_GET_DATA_HPP
|
||||
#define BOOST_SERIALIZATION_DETAIL_GET_DATA_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
|
||||
#define STD _STLP_STD
|
||||
#else
|
||||
#define STD std
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <valarray>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
namespace detail {
|
||||
|
||||
template <class T, class Allocator>
|
||||
T* get_data(STD::vector<T,Allocator>& v)
|
||||
{
|
||||
return v.empty() ? 0 : &(v[0]);
|
||||
}
|
||||
|
||||
template <class T, class Allocator>
|
||||
T* get_data(STD::vector<T,Allocator> const & v)
|
||||
{
|
||||
return get_data(const_cast<STD::vector<T,Allocator>&>(v));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T* get_data(STD::valarray<T>& v)
|
||||
{
|
||||
return v.size()==0 ? 0 : &(v[0]);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
const T* get_data(STD::valarray<T> const& v)
|
||||
{
|
||||
return get_data(const_cast<STD::valarray<T>&>(v));
|
||||
}
|
||||
|
||||
} // detail
|
||||
} // serialization
|
||||
} // boost
|
||||
|
||||
#undef STD
|
||||
|
||||
#endif // BOOST_SERIALIZATION_DETAIL_GET_DATA_HPP
|
||||
@@ -18,31 +18,37 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION >= 1101) \
|
||||
|| ! defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
#if ! defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
#include <type_traits>
|
||||
namespace boost{
|
||||
namespace serialization {
|
||||
namespace detail {
|
||||
|
||||
template<typename T>
|
||||
struct is_default_constructible : std::is_default_constructible<T> {};
|
||||
struct is_default_constructible : public std::is_default_constructible<T> {};
|
||||
|
||||
} // detail
|
||||
} // serializaition
|
||||
} // boost
|
||||
#else
|
||||
// we don't have standard library support for is_default_constructible
|
||||
// so we fake it by using boost::has_trivial_construtor. But this is not
|
||||
// actually correct because it's possible that a default constructor
|
||||
// to be non trivial. So when using this, make sure you're not using your
|
||||
// own definition of of T() but are using the actual default one!
|
||||
#include <boost/type_traits/has_trivial_constructor.hpp>
|
||||
namespace boost{
|
||||
namespace serialization {
|
||||
namespace detail {
|
||||
|
||||
template<typename T>
|
||||
struct is_default_constructible : boost::has_trivial_constructor<T> {};
|
||||
struct is_default_constructible : public boost::has_trivial_constructor<T> {};
|
||||
|
||||
} // detail
|
||||
} // serializaition
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // BOOST_SERIALIZATION_DETAIL_IS_DEFAULT_CONSTRUCTIBLE_HPP
|
||||
|
||||
@@ -48,32 +48,33 @@ namespace boost { \
|
||||
namespace serialization { \
|
||||
template<> \
|
||||
T * factory<T, N>(std::va_list ap){ \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N,0) \
|
||||
,A0 a0 = va_arg(ap, A0); \
|
||||
,BOOST_PP_IF(BOOST_PP_GREATER(N,1) \
|
||||
,A1 a1 = va_arg(ap, A1); \
|
||||
,BOOST_PP_IF(BOOST_PP_GREATER(N,2) \
|
||||
,A2 a2 = va_arg(ap, A2); \
|
||||
,BOOST_PP_IF(BOOST_PP_GREATER(N,3) \
|
||||
,A3 a3 = va_arg(ap, A3); \
|
||||
,BOOST_PP_EMPTY() \
|
||||
)))) \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 0) \
|
||||
, A0 a0 = va_arg(ap, A0);, BOOST_PP_EMPTY()) \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 1) \
|
||||
, A1 a1 = va_arg(ap, A1);, BOOST_PP_EMPTY()) \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 2) \
|
||||
, A2 a2 = va_arg(ap, A2);, BOOST_PP_EMPTY()) \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 3) \
|
||||
, A3 a3 = va_arg(ap, A3);, BOOST_PP_EMPTY()) \
|
||||
return new T( \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N,0) \
|
||||
,a0 \
|
||||
,BOOST_PP_IF(BOOST_PP_GREATER(N,1) \
|
||||
,a1 \
|
||||
,BOOST_PP_IF(BOOST_PP_GREATER(N,2) \
|
||||
,a2 \
|
||||
,BOOST_PP_IF(BOOST_PP_GREATER(N,3) \
|
||||
,a3 \
|
||||
,BOOST_PP_EMPTY() \
|
||||
)))) \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 0) \
|
||||
, a0, BOOST_PP_EMPTY()) \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 1)) \
|
||||
, BOOST_PP_COMMA, BOOST_PP_EMPTY)() \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 1) \
|
||||
, a1, BOOST_PP_EMPTY()) \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 2)) \
|
||||
, BOOST_PP_COMMA, BOOST_PP_EMPTY)() \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 2) \
|
||||
, a2, BOOST_PP_EMPTY()) \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 3)) \
|
||||
, BOOST_PP_COMMA, BOOST_PP_EMPTY)() \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 3) \
|
||||
, a3, BOOST_PP_EMPTY()) \
|
||||
); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
/**/
|
||||
} /**/
|
||||
|
||||
#define BOOST_SERIALIZATION_FACTORY_4(T, A0, A1, A2, A3) \
|
||||
BOOST_SERIALIZATION_FACTORY(4, T, A0, A1, A2, A3)
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <boost/serialization/traits.hpp>
|
||||
#include <boost/serialization/wrapper.hpp>
|
||||
|
||||
#include <boost/core/addressof.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
@@ -43,7 +45,7 @@ struct nvp :
|
||||
public:
|
||||
explicit nvp(const char * name_, T & t) :
|
||||
// note: added _ to suppress useless gcc warning
|
||||
std::pair<const char *, T *>(name_, & t)
|
||||
std::pair<const char *, T *>(name_, boost::addressof(t))
|
||||
{}
|
||||
|
||||
const char * name() const {
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#include <boost/serialization/detail/stack_constructor.hpp>
|
||||
#include <boost/serialization/detail/is_default_constructible.hpp>
|
||||
#include <boost/serialization/force_include.hpp>
|
||||
|
||||
// function specializations must be defined in the appropriate
|
||||
// namespace - boost::serialization
|
||||
@@ -46,24 +47,15 @@ void save(
|
||||
// default constructor. It's possible that this could change sometime
|
||||
// in the future, but for now, one will have to work around it. This can
|
||||
// be done by serialization the optional<T> as optional<T *>
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::serialization::detail::is_default_constructible<T>::value
|
||||
|| boost::is_pointer<T>::value
|
||||
);
|
||||
#if ! defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::serialization::detail::is_default_constructible<T>::value
|
||||
|| boost::is_pointer<T>::value
|
||||
);
|
||||
#endif
|
||||
const bool tflag = t.is_initialized();
|
||||
ar << boost::serialization::make_nvp("initialized", tflag);
|
||||
if (tflag){
|
||||
const boost::serialization::item_version_type item_version(version< T >::value);
|
||||
#if 0
|
||||
const boost::archive::library_version_type library_version(
|
||||
ar.get_library_version()
|
||||
};
|
||||
if(boost::archive::library_version_type(3) < library_version){
|
||||
ar << BOOST_SERIALIZATION_NVP(item_version);
|
||||
}
|
||||
#else
|
||||
ar << BOOST_SERIALIZATION_NVP(item_version);
|
||||
#endif
|
||||
ar << boost::serialization::make_nvp("value", *t);
|
||||
}
|
||||
}
|
||||
@@ -72,7 +64,7 @@ template<class Archive, class T>
|
||||
void load(
|
||||
Archive & ar,
|
||||
boost::optional< T > & t,
|
||||
const unsigned int /*version*/
|
||||
const unsigned int version
|
||||
){
|
||||
bool tflag;
|
||||
ar >> boost::serialization::make_nvp("initialized", tflag);
|
||||
@@ -81,20 +73,18 @@ void load(
|
||||
return;
|
||||
}
|
||||
|
||||
boost::serialization::item_version_type item_version(0);
|
||||
boost::archive::library_version_type library_version(
|
||||
ar.get_library_version()
|
||||
);
|
||||
if(boost::archive::library_version_type(3) < library_version){
|
||||
ar >> BOOST_SERIALIZATION_NVP(item_version);
|
||||
if(0 == version){
|
||||
boost::serialization::item_version_type item_version(0);
|
||||
boost::archive::library_version_type library_version(
|
||||
ar.get_library_version()
|
||||
);
|
||||
if(boost::archive::library_version_type(3) < library_version){
|
||||
ar >> BOOST_SERIALIZATION_NVP(item_version);
|
||||
}
|
||||
}
|
||||
detail::stack_allocate<T> tp;
|
||||
ar >> boost::serialization::make_nvp("value", tp.reference());
|
||||
t.reset(boost::move(tp.reference()));
|
||||
ar.reset_object_address(
|
||||
t.get_ptr(),
|
||||
& tp.reference()
|
||||
);
|
||||
if(! t.is_initialized())
|
||||
t = T();
|
||||
ar >> boost::serialization::make_nvp("value", *t);
|
||||
}
|
||||
|
||||
template<class Archive, class T>
|
||||
@@ -106,7 +96,12 @@ void serialize(
|
||||
boost::serialization::split_free(ar, t, version);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
struct version<boost::optional<T> > {
|
||||
BOOST_STATIC_CONSTANT(int, value = 1);
|
||||
};
|
||||
|
||||
} // serialization
|
||||
} // namespace boost
|
||||
} // boost
|
||||
|
||||
#endif // BOOST_SERIALIZATION_OPTIONAL_HPP_
|
||||
|
||||
@@ -57,7 +57,8 @@ inline void load_set_collection(Archive & ar, Container &s)
|
||||
ar >> boost::serialization::make_nvp("item", t.reference());
|
||||
typename Container::iterator result =
|
||||
s.insert(hint, boost::move(t.reference()));
|
||||
ar.reset_object_address(& (* result), & t.reference());
|
||||
const type * new_address = & (* result);
|
||||
ar.reset_object_address(new_address, & t.reference());
|
||||
hint = result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,57 +81,64 @@ namespace serialization {
|
||||
// attempt to retieve a mutable instances while locked will
|
||||
// generate a assertion if compiled for debug.
|
||||
|
||||
class BOOST_SYMBOL_VISIBLE singleton_module :
|
||||
public boost::noncopyable
|
||||
{
|
||||
private:
|
||||
static bool & get_lock();
|
||||
public:
|
||||
BOOST_SERIALIZATION_DECL static void lock();
|
||||
BOOST_SERIALIZATION_DECL static void unlock();
|
||||
BOOST_SERIALIZATION_DECL static bool is_locked();
|
||||
};
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class T>
|
||||
class singleton_wrapper : public T
|
||||
{
|
||||
public:
|
||||
static bool m_is_destroyed;
|
||||
~singleton_wrapper(){
|
||||
m_is_destroyed = true;
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
bool detail::singleton_wrapper< T >::m_is_destroyed = false;
|
||||
|
||||
} // detail
|
||||
|
||||
// note usage of BOOST_DLLEXPORT. These functions are in danger of
|
||||
// being eliminated by the optimizer when building an application in
|
||||
// release mode. Usage of the macro is meant to signal the compiler/linker
|
||||
// to avoid dropping these functions which seem to be unreferenced.
|
||||
// This usage is not related to autolinking.
|
||||
|
||||
class BOOST_SYMBOL_VISIBLE singleton_module :
|
||||
public boost::noncopyable
|
||||
{
|
||||
private:
|
||||
BOOST_DLLEXPORT static bool & get_lock() BOOST_USED {
|
||||
static bool lock = false;
|
||||
return lock;
|
||||
}
|
||||
|
||||
public:
|
||||
BOOST_DLLEXPORT static void lock(){
|
||||
get_lock() = true;
|
||||
}
|
||||
BOOST_DLLEXPORT static void unlock(){
|
||||
get_lock() = false;
|
||||
}
|
||||
BOOST_DLLEXPORT static bool is_locked(){
|
||||
return get_lock();
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class singleton : public singleton_module
|
||||
{
|
||||
private:
|
||||
BOOST_DLLEXPORT static T & instance;
|
||||
static T & m_instance;
|
||||
// include this to provoke instantiation at pre-execution time
|
||||
static void use(T const *) {}
|
||||
BOOST_DLLEXPORT static T & get_instance() {
|
||||
static detail::singleton_wrapper< T > t;
|
||||
static T & get_instance() {
|
||||
// use a wrapper so that types T with protected constructors
|
||||
// can be used
|
||||
class singleton_wrapper : public T {};
|
||||
static singleton_wrapper t;
|
||||
|
||||
// refer to instance, causing it to be instantiated (and
|
||||
// initialized at startup on working compilers)
|
||||
BOOST_ASSERT(! detail::singleton_wrapper< T >::m_is_destroyed);
|
||||
use(& instance);
|
||||
BOOST_ASSERT(! is_destroyed());
|
||||
|
||||
// note that the following is absolutely essential.
|
||||
// commenting out this statement will cause compilers to fail to
|
||||
// construct the instance at pre-execution time. This would prevent
|
||||
// our usage/implementation of "locking" and introduce uncertainty into
|
||||
// the sequence of object initializaition.
|
||||
use(& m_instance);
|
||||
|
||||
return static_cast<T &>(t);
|
||||
}
|
||||
static bool & get_is_destroyed(){
|
||||
static bool is_destroyed;
|
||||
return is_destroyed;
|
||||
}
|
||||
|
||||
public:
|
||||
BOOST_DLLEXPORT static T & get_mutable_instance(){
|
||||
BOOST_ASSERT(! is_locked());
|
||||
@@ -141,16 +148,24 @@ public:
|
||||
return get_instance();
|
||||
}
|
||||
BOOST_DLLEXPORT static bool is_destroyed(){
|
||||
return detail::singleton_wrapper< T >::m_is_destroyed;
|
||||
return get_is_destroyed();
|
||||
}
|
||||
BOOST_DLLEXPORT singleton(){
|
||||
get_is_destroyed() = false;
|
||||
}
|
||||
BOOST_DLLEXPORT ~singleton() {
|
||||
get_is_destroyed() = true;
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
BOOST_DLLEXPORT T & singleton< T >::instance = singleton< T >::get_instance();
|
||||
T & singleton< T >::m_instance = singleton< T >::get_instance();
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
@@ -18,10 +18,13 @@
|
||||
|
||||
#include <valarray>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/addressof.hpp>
|
||||
|
||||
#include <boost/serialization/collections_save_imp.hpp>
|
||||
#include <boost/serialization/collections_load_imp.hpp>
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
#include <boost/serialization/detail/get_data.hpp>
|
||||
#include <boost/serialization/array_wrapper.hpp>
|
||||
|
||||
// function specializations must be defined in the appropriate
|
||||
// namespace - boost::serialization
|
||||
@@ -42,12 +45,13 @@ void save( Archive & ar, const STD::valarray<U> &t, const unsigned int /*file_ve
|
||||
{
|
||||
const collection_size_type count(t.size());
|
||||
ar << BOOST_SERIALIZATION_NVP(count);
|
||||
if (t.size())
|
||||
if (t.size()){
|
||||
// explict template arguments to pass intel C++ compiler
|
||||
ar << serialization::make_array<const U, collection_size_type>(
|
||||
static_cast<const U *>(&t[0]),
|
||||
static_cast<const U *>( boost::addressof(t[0]) ),
|
||||
count
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
template<class Archive, class U>
|
||||
@@ -56,12 +60,13 @@ void load( Archive & ar, STD::valarray<U> &t, const unsigned int /*file_version
|
||||
collection_size_type count;
|
||||
ar >> BOOST_SERIALIZATION_NVP(count);
|
||||
t.resize(count);
|
||||
if (t.size())
|
||||
if (t.size()){
|
||||
// explict template arguments to pass intel C++ compiler
|
||||
ar >> serialization::make_array<U, collection_size_type>(
|
||||
static_cast<U *>(&t[0]),
|
||||
static_cast<U *>( boost::addressof(t[0]) ),
|
||||
count
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// split non-intrusive serialization function member into separate
|
||||
|
||||
@@ -43,8 +43,8 @@ namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template<class Archive>
|
||||
struct variant_save_visitor :
|
||||
boost::static_visitor<>
|
||||
struct variant_save_visitor :
|
||||
boost::static_visitor<>
|
||||
{
|
||||
variant_save_visitor(Archive& ar) :
|
||||
m_ar(ar)
|
||||
@@ -100,7 +100,8 @@ struct variant_impl {
|
||||
head_type value;
|
||||
ar >> BOOST_SERIALIZATION_NVP(value);
|
||||
v = value;
|
||||
ar.reset_object_address(& boost::get<head_type>(v), & value);
|
||||
head_type * new_address = & boost::get<head_type>(v);
|
||||
ar.reset_object_address(new_address, & value);
|
||||
return;
|
||||
}
|
||||
typedef typename mpl::pop_front<S>::type type;
|
||||
@@ -155,4 +156,23 @@ inline void serialize(
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
//template<typename T0_, BOOST_VARIANT_ENUM_SHIFTED_PARAMS(typename T)>
|
||||
|
||||
#include <boost/serialization/tracking.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template<BOOST_VARIANT_ENUM_PARAMS(/* typename */ class T)>
|
||||
struct tracking_level<
|
||||
variant<BOOST_VARIANT_ENUM_PARAMS(T)>
|
||||
>{
|
||||
typedef mpl::integral_c_tag tag;
|
||||
typedef mpl::int_< ::boost::serialization::track_always> type;
|
||||
BOOST_STATIC_CONSTANT(int, value = type::value);
|
||||
};
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
#endif //BOOST_SERIALIZATION_VARIANT_HPP
|
||||
|
||||
@@ -31,8 +31,7 @@
|
||||
#include <boost/serialization/collections_save_imp.hpp>
|
||||
#include <boost/serialization/collections_load_imp.hpp>
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include <boost/serialization/detail/get_data.hpp>
|
||||
#include <boost/serialization/array_wrapper.hpp>
|
||||
#include <boost/mpl/bool_fwd.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
|
||||
@@ -181,13 +181,14 @@ void_caster_primitive<Derived, Base>::void_caster_primitive() :
|
||||
void_caster(
|
||||
& type_info_implementation<Derived>::type::get_const_instance(),
|
||||
& type_info_implementation<Base>::type::get_const_instance(),
|
||||
// note:I wanted to displace from 0 here, but at least one compiler
|
||||
// treated 0 by not shifting it at all.
|
||||
/* note about displacement:
|
||||
* displace 0: at least one compiler treated 0 by not shifting it at all
|
||||
* displace by small value (8): caused ICE on certain mingw gcc versions */
|
||||
reinterpret_cast<std::ptrdiff_t>(
|
||||
static_cast<Derived *>(
|
||||
reinterpret_cast<Base *>(8)
|
||||
reinterpret_cast<Base *>(1 << 20)
|
||||
)
|
||||
) - 8
|
||||
) - (1 << 20)
|
||||
)
|
||||
{
|
||||
recursive_register();
|
||||
|
||||
@@ -77,6 +77,14 @@ archive_exception::archive_exception(
|
||||
break;
|
||||
case input_stream_error:
|
||||
length = append(length, "input stream error");
|
||||
if(NULL != e1){
|
||||
length = append(length, "-");
|
||||
length = append(length, e1);
|
||||
}
|
||||
if(NULL != e2){
|
||||
length = append(length, "-");
|
||||
length = append(length, e2);
|
||||
}
|
||||
break;
|
||||
case invalid_class_name:
|
||||
length = append(length, "class name too long");
|
||||
@@ -105,6 +113,14 @@ archive_exception::archive_exception(
|
||||
break;
|
||||
case output_stream_error:
|
||||
length = append(length, "output stream error");
|
||||
if(NULL != e1){
|
||||
length = append(length, "-");
|
||||
length = append(length, e1);
|
||||
}
|
||||
if(NULL != e2){
|
||||
length = append(length, "-");
|
||||
length = append(length, e2);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BOOST_ASSERT(false);
|
||||
|
||||
@@ -77,10 +77,13 @@ BOOST_ARCHIVE_SIGNATURE(){
|
||||
// 13- simplified visibility, removed Borland, removed pfto
|
||||
// 14- improved visibility, refactor map/set
|
||||
// 15- corrections to optional and collection loading
|
||||
// 16- eliminated dependency on <codecvt> which is buggy in some libraries
|
||||
// and now officially deprecated in the standard
|
||||
// 17- Boost 1.68 August 2018
|
||||
|
||||
BOOST_SYMBOL_VISIBLE library_version_type
|
||||
BOOST_ARCHIVE_VERSION(){
|
||||
return library_version_type(15);
|
||||
return library_version_type(17);
|
||||
}
|
||||
|
||||
} // namespace archive
|
||||
|
||||
@@ -459,6 +459,12 @@ basic_iarchive_impl::load_pointer(
|
||||
cobject_id & co = cobject_id_vector[i];
|
||||
bpis_ptr = co.bpis_ptr;
|
||||
|
||||
if (bpis_ptr == NULL) {
|
||||
boost::serialization::throw_exception(
|
||||
archive_exception(archive_exception::unregistered_class)
|
||||
);
|
||||
}
|
||||
|
||||
load_preamble(ar, co);
|
||||
|
||||
// extra line to evade borland issue
|
||||
@@ -487,7 +493,7 @@ basic_iarchive_impl::load_pointer(
|
||||
m_pending.version = co.file_version;
|
||||
|
||||
// predict next object id to be created
|
||||
const unsigned int ui = object_id_vector.size();
|
||||
const size_t ui = object_id_vector.size();
|
||||
|
||||
serialization::state_saver<object_id_type> w_end(m_moveable_objects.end);
|
||||
|
||||
|
||||
@@ -106,8 +106,9 @@ class basic_oarchive_impl {
|
||||
m_class_id(class_id),
|
||||
m_initialized(false)
|
||||
{}
|
||||
cobject_type(const basic_oserializer & bos)
|
||||
: m_bos_ptr(& bos)
|
||||
cobject_type(const basic_oserializer & bos) :
|
||||
m_bos_ptr(& bos),
|
||||
m_initialized(false)
|
||||
{}
|
||||
cobject_type(
|
||||
const cobject_type & rhs
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
# pragma warning(disable : 4244 4511 4512)
|
||||
#endif
|
||||
|
||||
#include <cerrno> // errno
|
||||
#include <cstring> // strerror(errno)
|
||||
|
||||
// spirit stuff
|
||||
#include <boost/spirit/include/classic_operators.hpp>
|
||||
#include <boost/spirit/include/classic_actions.hpp>
|
||||
@@ -31,7 +34,6 @@
|
||||
#endif
|
||||
|
||||
// for head_iterator test
|
||||
//#include <boost/bind.hpp>
|
||||
#include <boost/function.hpp>
|
||||
|
||||
#include <boost/io/ios_state.hpp>
|
||||
@@ -145,8 +147,7 @@ template<class String>
|
||||
struct append_char {
|
||||
String & contents;
|
||||
void operator()(const unsigned int char_value) const {
|
||||
const typename String::value_type z = char_value;
|
||||
contents += z;
|
||||
contents += static_cast<typename String::value_type>(char_value);
|
||||
}
|
||||
append_char(String & contents_)
|
||||
: contents(contents_)
|
||||
@@ -189,8 +190,14 @@ bool basic_xml_grammar<CharType>::my_parse(
|
||||
for(;;){
|
||||
CharType result;
|
||||
is.get(result);
|
||||
if(is.fail())
|
||||
return false;
|
||||
if(is.fail()){
|
||||
boost::serialization::throw_exception(
|
||||
boost::archive::archive_exception(
|
||||
archive_exception::input_stream_error,
|
||||
std::strerror(errno)
|
||||
)
|
||||
);
|
||||
}
|
||||
if(is.eof())
|
||||
return false;
|
||||
arg += result;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
BOOST_WARCHIVE_DECL std::codecvt_base::result
|
||||
std::codecvt_base::result
|
||||
codecvt_null<wchar_t>::do_out(
|
||||
std::mbstate_t & /*state*/,
|
||||
const wchar_t * first1,
|
||||
@@ -46,7 +46,7 @@ codecvt_null<wchar_t>::do_out(
|
||||
return std::codecvt_base::ok;
|
||||
}
|
||||
|
||||
BOOST_WARCHIVE_DECL std::codecvt_base::result
|
||||
std::codecvt_base::result
|
||||
codecvt_null<wchar_t>::do_in(
|
||||
std::mbstate_t & /*state*/,
|
||||
const char * first1,
|
||||
|
||||
@@ -125,6 +125,7 @@ BOOST_SERIALIZATION_DECL void
|
||||
extended_type_info::key_unregister() const{
|
||||
if(NULL == get_key())
|
||||
return;
|
||||
BOOST_ASSERT(! singleton<detail::ktmap>::is_destroyed());
|
||||
if(! singleton<detail::ktmap>::is_destroyed()){
|
||||
detail::ktmap & x = singleton<detail::ktmap>::get_mutable_instance();
|
||||
detail::ktmap::iterator start = x.lower_bound(this);
|
||||
|
||||
@@ -95,19 +95,18 @@ BOOST_SERIALIZATION_DECL void
|
||||
extended_type_info_typeid_0::type_unregister()
|
||||
{
|
||||
if(NULL != m_ti){
|
||||
BOOST_ASSERT(! singleton<tkmap>::is_destroyed());
|
||||
if(! singleton<tkmap>::is_destroyed()){
|
||||
tkmap & x = singleton<tkmap>::get_mutable_instance();
|
||||
tkmap::iterator start = x.lower_bound(this);
|
||||
tkmap::iterator end = x.upper_bound(this);
|
||||
BOOST_ASSERT(start != end);
|
||||
|
||||
// remove entry in map which corresponds to this type
|
||||
do{
|
||||
if(this == *start)
|
||||
x.erase(start++);
|
||||
else
|
||||
++start;
|
||||
}while(start != end);
|
||||
// remove all entries in map which corresponds to this type
|
||||
// make sure that we don't use any invalidated iterators
|
||||
for(;;){
|
||||
const tkmap::iterator & it = x.find(this);
|
||||
if(it == x.end())
|
||||
break;
|
||||
x.erase(it);
|
||||
};
|
||||
}
|
||||
}
|
||||
m_ti = NULL;
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// singleton.cpp
|
||||
//
|
||||
// Copyright (c) 201 5 Robert Ramey, Indiana University (garcia@osl.iu.edu)
|
||||
// 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)
|
||||
//
|
||||
|
||||
// it marks our code with proper attributes as being exported when
|
||||
// we're compiling it while marking it import when just the headers
|
||||
// is being included.
|
||||
#define BOOST_SERIALIZATION_SOURCE
|
||||
#include <boost/serialization/config.hpp>
|
||||
#include <boost/serialization/singleton.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
bool & singleton_module::get_lock(){
|
||||
static bool lock = false;
|
||||
return lock;
|
||||
}
|
||||
|
||||
BOOST_SERIALIZATION_DECL void singleton_module::lock(){
|
||||
get_lock() = true;
|
||||
}
|
||||
BOOST_SERIALIZATION_DECL void singleton_module::unlock(){
|
||||
get_lock() = false;
|
||||
}
|
||||
BOOST_SERIALIZATION_DECL bool singleton_module::is_locked() {
|
||||
return get_lock();
|
||||
}
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
+14
-15
@@ -4,20 +4,19 @@
|
||||
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifdef BOOST_NO_STD_WSTREAMBUF
|
||||
#error "wide char i/o not supported on this platform"
|
||||
#else
|
||||
// #ifdef BOOST_NO_CXX11_HDR_CODECVT
|
||||
#if 1
|
||||
# define BOOST_ARCHIVE_SOURCE
|
||||
#include <boost/archive/detail/decl.hpp>
|
||||
#define BOOST_UTF8_BEGIN_NAMESPACE \
|
||||
namespace boost { namespace archive { namespace detail {
|
||||
#define BOOST_UTF8_DECL BOOST_ARCHIVE_DECL
|
||||
#define BOOST_UTF8_END_NAMESPACE }}}
|
||||
#include <boost/detail/utf8_codecvt_facet.ipp>
|
||||
#undef BOOST_UTF8_END_NAMESPACE
|
||||
#undef BOOST_UTF8_DECL
|
||||
#undef BOOST_UTF8_BEGIN_NAMESPACE
|
||||
#endif // BOOST_NO_CXX11_HDR_CODECVT
|
||||
#endif // BOOST_NO_STD_WSTREAMBUF
|
||||
#endif
|
||||
|
||||
// include boost implementation of utf8 codecvt facet
|
||||
# define BOOST_ARCHIVE_SOURCE
|
||||
#include <boost/archive/detail/decl.hpp>
|
||||
#define BOOST_UTF8_BEGIN_NAMESPACE \
|
||||
namespace boost { namespace archive { namespace detail {
|
||||
#define BOOST_UTF8_DECL BOOST_ARCHIVE_DECL
|
||||
#define BOOST_UTF8_END_NAMESPACE }}}
|
||||
#include <boost/detail/utf8_codecvt_facet.ipp>
|
||||
#undef BOOST_UTF8_END_NAMESPACE
|
||||
#undef BOOST_UTF8_DECL
|
||||
#undef BOOST_UTF8_BEGIN_NAMESPACE
|
||||
|
||||
@@ -276,6 +276,7 @@ void_caster::recursive_register(bool includes_virtual_base) const {
|
||||
|
||||
BOOST_SERIALIZATION_DECL void
|
||||
void_caster::recursive_unregister() const {
|
||||
BOOST_ASSERT(! void_caster_registry::is_destroyed());
|
||||
if(void_caster_registry::is_destroyed())
|
||||
return;
|
||||
|
||||
|
||||
+9
-8
@@ -48,7 +48,7 @@ void accumulate(std::size_t & s, const T & t){
|
||||
s += *tptr++;
|
||||
}
|
||||
}
|
||||
|
||||
A_DLL_DECL
|
||||
A::operator std::size_t () const {
|
||||
std::size_t retval = 0;
|
||||
accumulate(retval, b);
|
||||
@@ -76,8 +76,9 @@ A::operator std::size_t () const {
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push) // Save warning settings.
|
||||
#pragma warning(disable : 4244) // Disable possible loss of data warning
|
||||
#endif
|
||||
|
||||
#endif
|
||||
A_DLL_DECL
|
||||
A::A() :
|
||||
b(true),
|
||||
#ifndef BOOST_NO_INT64_T
|
||||
@@ -111,8 +112,8 @@ A::A() :
|
||||
#pragma warning(pop) // Restore warnings to previous state.
|
||||
#endif
|
||||
|
||||
bool A::operator==(const A &rhs) const
|
||||
{
|
||||
A_DLL_DECL bool
|
||||
A::operator==(const A &rhs) const {
|
||||
if(b != rhs.b)
|
||||
return false;
|
||||
if(l != rhs.l)
|
||||
@@ -160,13 +161,13 @@ bool A::operator==(const A &rhs) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool A::operator!=(const A &rhs) const
|
||||
{
|
||||
A_DLL_DECL bool
|
||||
A::operator!=(const A &rhs) const {
|
||||
return ! (*this == rhs);
|
||||
}
|
||||
|
||||
bool A::operator<(const A &rhs) const
|
||||
{
|
||||
A_DLL_DECL bool
|
||||
A::operator<(const A &rhs) const {
|
||||
if(b != rhs.b)
|
||||
return b < rhs.b;
|
||||
#ifndef BOOST_NO_INT64_T
|
||||
|
||||
+19
-79
@@ -18,100 +18,42 @@
|
||||
|
||||
#include <ostream> // for friend output operators
|
||||
#include <cstddef> // size_t
|
||||
#include <string>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::size_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include <boost/serialization/access.hpp>
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
|
||||
#include <boost/archive/dinkumware.hpp>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/string.hpp>
|
||||
|
||||
#include <boost/preprocessor/facilities/empty.hpp>
|
||||
|
||||
#if defined(A_IMPORT)
|
||||
#define DLL_DECL BOOST_SYMBOL_IMPORT
|
||||
#elif defined(A_EXPORT)
|
||||
#define DLL_DECL BOOST_SYMBOL_EXPORT
|
||||
#else
|
||||
#define DLL_DECL
|
||||
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SERIALIZATION_DYN_LINK)
|
||||
#if defined(A_IMPORT)
|
||||
#define A_DLL_DECL BOOST_SYMBOL_IMPORT
|
||||
#pragma message("A imported")
|
||||
#elif defined(A_EXPORT)
|
||||
#define A_DLL_DECL BOOST_SYMBOL_EXPORT
|
||||
#pragma message ("A exported")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
class DLL_DECL A
|
||||
{
|
||||
#ifndef A_DLL_DECL
|
||||
#define A_DLL_DECL
|
||||
#endif
|
||||
|
||||
class A_DLL_DECL A {
|
||||
private:
|
||||
friend class boost::serialization::access;
|
||||
// note: from an aesthetic perspective, I would much prefer to have this
|
||||
// defined out of line. Unfortunately, this trips a bug in the VC 6.0
|
||||
// compiler. So hold our nose and put it her to permit running of tests.
|
||||
// mscvc 6.0 requires template functions to be implemented. For this
|
||||
// reason we can't make abstract.
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
template<class Archive>
|
||||
void serialize(
|
||||
Archive &ar,
|
||||
const unsigned int /* file_version */
|
||||
){
|
||||
ar & BOOST_SERIALIZATION_NVP(b);
|
||||
#ifndef BOOST_NO_INT64_T
|
||||
ar & BOOST_SERIALIZATION_NVP(f);
|
||||
ar & BOOST_SERIALIZATION_NVP(g);
|
||||
#endif
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, <= 0x551 )
|
||||
int i;
|
||||
if(BOOST_DEDUCED_TYPENAME Archive::is_saving::value){
|
||||
i = l;
|
||||
ar & BOOST_SERIALIZATION_NVP(i);
|
||||
}
|
||||
else{
|
||||
ar & BOOST_SERIALIZATION_NVP(i);
|
||||
l = i;
|
||||
}
|
||||
#else
|
||||
ar & BOOST_SERIALIZATION_NVP(l);
|
||||
#endif
|
||||
ar & BOOST_SERIALIZATION_NVP(m);
|
||||
ar & BOOST_SERIALIZATION_NVP(n);
|
||||
ar & BOOST_SERIALIZATION_NVP(o);
|
||||
ar & BOOST_SERIALIZATION_NVP(p);
|
||||
ar & BOOST_SERIALIZATION_NVP(q);
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
ar & BOOST_SERIALIZATION_NVP(r);
|
||||
#endif
|
||||
ar & BOOST_SERIALIZATION_NVP(c);
|
||||
ar & BOOST_SERIALIZATION_NVP(s);
|
||||
ar & BOOST_SERIALIZATION_NVP(t);
|
||||
ar & BOOST_SERIALIZATION_NVP(u);
|
||||
ar & BOOST_SERIALIZATION_NVP(v);
|
||||
ar & BOOST_SERIALIZATION_NVP(w);
|
||||
ar & BOOST_SERIALIZATION_NVP(x);
|
||||
ar & BOOST_SERIALIZATION_NVP(y);
|
||||
#ifndef BOOST_NO_STD_WSTRING
|
||||
ar & BOOST_SERIALIZATION_NVP(z);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
template<class Archive>
|
||||
void serialize(
|
||||
Archive &ar,
|
||||
const unsigned int /* file_version */
|
||||
);
|
||||
#endif
|
||||
template<class Archive>
|
||||
void serialize(
|
||||
Archive &ar,
|
||||
const unsigned int /* file_version */
|
||||
);
|
||||
bool b;
|
||||
#ifndef BOOST_NO_INT64_T
|
||||
boost::int64_t f;
|
||||
@@ -152,6 +94,4 @@ public:
|
||||
friend std::ostream & operator<<(std::ostream & os, A const & a);
|
||||
};
|
||||
|
||||
#undef DLL_DECL
|
||||
|
||||
#endif // BOOST_SERIALIZATION_TEST_A_HPP
|
||||
|
||||
+2
-6
@@ -8,13 +8,11 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#if ! BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
|
||||
#include <boost/archive/dinkumware.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include "A.hpp"
|
||||
|
||||
template<class Archive>
|
||||
@@ -59,6 +57,4 @@ void A::serialize(
|
||||
#ifndef BOOST_NO_STD_WSTRING
|
||||
ar & BOOST_SERIALIZATION_NVP(z);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // workaround BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
};
|
||||
|
||||
+35
-35
@@ -9,13 +9,13 @@
|
||||
project libs/serialization/test
|
||||
: id serialization_test
|
||||
: requirements <source>/boost/filesystem
|
||||
: requirements <source>/boost/system
|
||||
;
|
||||
|
||||
# import rules for testing conditional on config file variables
|
||||
import ../../config/checks/config : requires ;
|
||||
|
||||
# import rules from the boost serialization test
|
||||
# import ../util/test : test-bsl-run-no-lib ;
|
||||
import ../util/test :
|
||||
run-template
|
||||
run-invoke
|
||||
@@ -28,34 +28,28 @@ import ../util/test :
|
||||
;
|
||||
|
||||
BOOST_ARCHIVE_LIST = [ modules.peek : BOOST_ARCHIVE_LIST ] ;
|
||||
|
||||
lib dll_a_lib
|
||||
|
||||
lib a
|
||||
:
|
||||
dll_a.cpp
|
||||
../build//boost_serialization
|
||||
:
|
||||
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
|
||||
;
|
||||
lib polymorphic_base
|
||||
:
|
||||
polymorphic_base.cpp
|
||||
../build//boost_serialization
|
||||
:
|
||||
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
|
||||
;
|
||||
|
||||
lib dll_base_lib
|
||||
:
|
||||
dll_base.cpp
|
||||
../build//boost_serialization
|
||||
:
|
||||
;
|
||||
|
||||
lib dll_derived2_lib
|
||||
lib polymorphic_derived2
|
||||
:
|
||||
dll_derived2.cpp
|
||||
dll_base_lib
|
||||
../build//boost_serialization
|
||||
:
|
||||
;
|
||||
|
||||
lib dll_polymorphic_derived2_lib
|
||||
:
|
||||
polymorphic_derived2.cpp
|
||||
polymorphic_derived2.cpp
|
||||
../build//boost_serialization
|
||||
:
|
||||
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
|
||||
;
|
||||
|
||||
test-suite "serialization" :
|
||||
@@ -84,6 +78,7 @@ test-suite "serialization" :
|
||||
[ test-bsl-run_files test_list : A ]
|
||||
[ test-bsl-run_files test_list_ptrs : A ]
|
||||
[ test-bsl-run_files test_map : A ]
|
||||
[ test-bsl-run_files test_map_hashed : A : : [ requires hash ] ] # BOOST_HAS_HASH
|
||||
[ test-bsl-run_files test_map_unordered : A : : [ requires cxx11_hdr_unordered_map ] ] # BOOST_NO_CXX11_HDR_UNORDERED_MAP
|
||||
[ test-bsl-run_files test_map_boost_unordered : A ]
|
||||
[ test-bsl-run_files test_mi ]
|
||||
@@ -107,6 +102,8 @@ test-suite "serialization" :
|
||||
[ test-bsl-run_files test_set_boost_unordered : A ]
|
||||
[ test-bsl-run_files test_simple_class : A ]
|
||||
[ test-bsl-run_files test_simple_class_ptr : A ]
|
||||
[ test-bsl-run_files test_slist : A : : [ requires slist ] ] # BOOST_HAS_SLIST ]
|
||||
[ test-bsl-run_files test_slist_ptrs : A : : [ requires slist ] ] # BOOST_HAS_SLIST ] ]
|
||||
[ test-bsl-run_files test_split ]
|
||||
[ test-bsl-run_files test_stack : A ]
|
||||
[ test-bsl-run_files test_tracking ]
|
||||
@@ -119,7 +116,7 @@ test-suite "serialization" :
|
||||
[ test-bsl-run_files test_optional ]
|
||||
[ test-bsl-run_files test_shared_ptr ]
|
||||
[ test-bsl-run_files test_shared_ptr_multi_base ]
|
||||
[ test-bsl-run_files test_shared_ptr_132 ]
|
||||
[ test-bsl-run_files test_shared_ptr_132 : : : [ requires auto_ptr ] ] # BOOST_NO_AUTO_PTR
|
||||
[ 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 ]
|
||||
@@ -130,13 +127,18 @@ test-suite "serialization" :
|
||||
|
||||
if ! $(BOOST_ARCHIVE_LIST) {
|
||||
test-suite "serialization2" :
|
||||
[ test-bsl-run-no-lib test_inclusion ]
|
||||
[ test-bsl-run test_dll_exported : : dll_polymorphic_derived2_lib ]
|
||||
[ test-bsl-run test_dll_simple : : dll_a_lib ]
|
||||
[ compile test_dll_plugin.cpp ]
|
||||
# Running the following test requires that the test know the directory
|
||||
# in which the dll is stored. I don't know how to extract this from bjam
|
||||
# [ test-bsl-run test_dll_plugin : : dll_polymorphic_derived2_lib ]
|
||||
[ test-bsl-run test_inclusion ]
|
||||
[ test-bsl-run test_inclusion2 ]
|
||||
# boost build has the feature that the building if libraries vs dll is automatic
|
||||
# in that dependent libraries are built the same way - shared/static - that
|
||||
# the application is. On some platforms (e.g windows) this is required to avoid
|
||||
# problems of linking incompatible versions of the runtime library. So
|
||||
# we suppress tests of our dlls when using static libraries
|
||||
[ test-bsl-run test_dll_exported : : polymorphic_derived2 : <link>static:<build>no ]
|
||||
|
||||
# [ test-bsl-run test_dll_plugin : : polymorphic_derived2 : <link>static:<build>no <target-os>linux:<linkflags>-ldl ]
|
||||
|
||||
[ test-bsl-run test_dll_simple : : a : ]
|
||||
[ test-bsl-run test_private_ctor ]
|
||||
[ test-bsl-run test_reset_object_address : A ]
|
||||
[ test-bsl-run test_void_cast ]
|
||||
@@ -144,13 +146,10 @@ if ! $(BOOST_ARCHIVE_LIST) {
|
||||
[ test-bsl-run test_iterators ]
|
||||
[ test-bsl-run test_iterators_base64 ]
|
||||
[ test-bsl-run test_smart_cast ]
|
||||
[ test-bsl-run test_codecvt_null
|
||||
: ../src/codecvt_null
|
||||
:
|
||||
: [ requires std_wstreambuf ]
|
||||
]
|
||||
|
||||
#[ test-bsl-run test_z ]
|
||||
[ test-bsl-run test_codecvt_null ]
|
||||
[ test-bsl-run test_singleton ]
|
||||
|
||||
# [ test-bsl-run test_z ]
|
||||
|
||||
# should fail compilation
|
||||
[ compile-fail test_not_serializable.cpp ]
|
||||
@@ -168,6 +167,7 @@ if ! $(BOOST_ARCHIVE_LIST) {
|
||||
[ compile test_const_save_warn1.cpp ]
|
||||
[ compile test_const_save_warn2.cpp ]
|
||||
[ compile test_const_save_warn3.cpp ]
|
||||
|
||||
# note - library unable to detect these errors for now
|
||||
#[ compile test_const_save_warn1_nvp.cpp ]
|
||||
#[ compile test_const_save_warn2_nvp.cpp ]
|
||||
|
||||
+5
-4
@@ -1,3 +1,4 @@
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// dll_a.cpp
|
||||
|
||||
@@ -20,12 +21,12 @@
|
||||
#include <boost/archive/text_iarchive.hpp>
|
||||
|
||||
template
|
||||
BOOST_SYMBOL_EXPORT void A::serialize(
|
||||
A_DLL_DECL void A::serialize(
|
||||
boost::archive::text_oarchive &ar,
|
||||
const unsigned int /* file_version */
|
||||
);
|
||||
template
|
||||
BOOST_SYMBOL_EXPORT void A::serialize(
|
||||
A_DLL_DECL void A::serialize(
|
||||
boost::archive::text_iarchive &ar,
|
||||
const unsigned int /* file_version */
|
||||
);
|
||||
@@ -36,12 +37,12 @@ BOOST_SYMBOL_EXPORT void A::serialize(
|
||||
#include <boost/archive/polymorphic_iarchive.hpp>
|
||||
|
||||
template
|
||||
BOOST_SYMBOL_EXPORT void A::serialize(
|
||||
A_DLL_DECL void A::serialize(
|
||||
boost::archive::polymorphic_oarchive &ar,
|
||||
const unsigned int /* file_version */
|
||||
);
|
||||
template
|
||||
BOOST_SYMBOL_EXPORT void A::serialize(
|
||||
A_DLL_DECL void A::serialize(
|
||||
boost::archive::polymorphic_iarchive &ar,
|
||||
const unsigned int /* file_version */
|
||||
);
|
||||
|
||||
@@ -11,13 +11,7 @@
|
||||
#include <boost/serialization/export.hpp>
|
||||
|
||||
#define POLYMORPHIC_BASE_EXPORT
|
||||
|
||||
#include "polymorphic_base.hpp"
|
||||
|
||||
BOOST_CLASS_EXPORT_IMPLEMENT(polymorphic_base)
|
||||
|
||||
const char * polymorphic_base::get_key() const{
|
||||
return
|
||||
boost::serialization::type_info_implementation<
|
||||
polymorphic_base
|
||||
>::type::get_const_instance().get_key();
|
||||
}
|
||||
|
||||
+15
-10
@@ -24,15 +24,21 @@
|
||||
#include <boost/serialization/type_info_implementation.hpp>
|
||||
#include <boost/serialization/extended_type_info_no_rtti.hpp>
|
||||
|
||||
#if defined(POLYMORPHIC_BASE_IMPORT)
|
||||
#define DLL_DECL BOOST_SYMBOL_IMPORT
|
||||
#elif defined(POLYMORPHIC_BASE_EXPORT)
|
||||
#define DLL_DECL BOOST_SYMBOL_EXPORT
|
||||
#else
|
||||
#define DLL_DECL
|
||||
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SERIALIZATION_DYN_LINK)
|
||||
#if defined(POLYMORPHIC_BASE_IMPORT)
|
||||
#define POLYMORPHIC_BASE_DLL_DECL BOOST_SYMBOL_IMPORT
|
||||
#pragma message ("polymorphic_base imported")
|
||||
#elif defined(POLYMORPHIC_BASE_EXPORT)
|
||||
#define POLYMORPHIC_BASE_DLL_DECL BOOST_SYMBOL_EXPORT
|
||||
#pragma message ("polymorphic_base exported")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
class BOOST_SYMBOL_VISIBLE polymorphic_base
|
||||
#ifndef POLYMORPHIC_BASE_DLL_DECL
|
||||
#define POLYMORPHIC_BASE_DLL_DECL
|
||||
#endif
|
||||
|
||||
class POLYMORPHIC_BASE_DLL_DECL polymorphic_base
|
||||
{
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
@@ -48,16 +54,15 @@ public:
|
||||
virtual ~polymorphic_base(){};
|
||||
};
|
||||
|
||||
#undef DLL_DECL
|
||||
|
||||
BOOST_SERIALIZATION_ASSUME_ABSTRACT(polymorphic_base)
|
||||
|
||||
// the no_rtti system requires this !!!
|
||||
BOOST_CLASS_EXPORT_KEY(polymorphic_base)
|
||||
|
||||
|
||||
BOOST_CLASS_TYPE_INFO(
|
||||
polymorphic_base,
|
||||
boost::serialization::extended_type_info_no_rtti<polymorphic_base>
|
||||
extended_type_info_no_rtti<polymorphic_base>
|
||||
)
|
||||
|
||||
#endif // POLYMORPHIC_BASE_HPP
|
||||
|
||||
@@ -12,26 +12,23 @@
|
||||
#include <boost/serialization/extended_type_info_no_rtti.hpp>
|
||||
#include <boost/serialization/export.hpp>
|
||||
|
||||
#define POLYMORPHIC_BASE_EXPORT
|
||||
#include "polymorphic_base.hpp"
|
||||
|
||||
#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>
|
||||
|
||||
template BOOST_SYMBOL_EXPORT void polymorphic_derived2::serialize(
|
||||
template
|
||||
void polymorphic_derived2::serialize(
|
||||
boost::archive::text_oarchive & ar,
|
||||
const unsigned int version
|
||||
);
|
||||
template BOOST_SYMBOL_EXPORT void polymorphic_derived2::serialize(
|
||||
template
|
||||
void polymorphic_derived2::serialize(
|
||||
boost::archive::text_iarchive & ar,
|
||||
const unsigned int version
|
||||
);
|
||||
@@ -40,11 +37,13 @@ template BOOST_SYMBOL_EXPORT void polymorphic_derived2::serialize(
|
||||
#include <boost/archive/polymorphic_iarchive.hpp>
|
||||
#include <boost/archive/polymorphic_oarchive.hpp>
|
||||
|
||||
template BOOST_SYMBOL_EXPORT void polymorphic_derived2::serialize(
|
||||
template
|
||||
void polymorphic_derived2::serialize(
|
||||
boost::archive::polymorphic_oarchive & ar,
|
||||
const unsigned int version
|
||||
);
|
||||
template BOOST_SYMBOL_EXPORT void polymorphic_derived2::serialize(
|
||||
template
|
||||
void polymorphic_derived2::serialize(
|
||||
boost::archive::polymorphic_iarchive & ar,
|
||||
const unsigned int version
|
||||
);
|
||||
@@ -60,6 +59,7 @@ BOOST_CLASS_EXPORT_IMPLEMENT(polymorphic_derived2)
|
||||
BOOST_SERIALIZATION_FACTORY_0(polymorphic_derived2)
|
||||
|
||||
template
|
||||
BOOST_SYMBOL_EXPORT void polymorphic_derived2 *
|
||||
POLYMORPHIC_DERIVED2_DLL_DECL
|
||||
void polymorphic_derived2 *
|
||||
boost::serialization::factory<polymorphic_derived2, 0>(std::va_list ap);
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef POLYMORPHIC_DERIVED2_HPP
|
||||
#define POLYMORPHIC_DERIVED2_HPP
|
||||
#ifndef BOOST_SERIALIZATION_TEST_POLYMORPHIC_DERIVED2_HPP
|
||||
#define BOOST_SERIALIZATION_TEST_POLYMORPHIC_DERIVED2_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
@@ -24,19 +24,23 @@
|
||||
#include <boost/serialization/type_info_implementation.hpp>
|
||||
#include <boost/serialization/extended_type_info_typeid.hpp>
|
||||
|
||||
#include <boost/preprocessor/empty.hpp>
|
||||
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SERIALIZATION_DYN_LINK)
|
||||
#if defined(POLYMORPHIC_DERIVED2_IMPORT)
|
||||
#define POLYMORPHIC_DERIVED2_DLL_DECL BOOST_SYMBOL_IMPORT
|
||||
#pragma message ("polymorphic_derived2 imported")
|
||||
#elif defined(POLYMORPHIC_DERIVED2_EXPORT)
|
||||
#define POLYMORPHIC_DERIVED2_DLL_DECL BOOST_SYMBOL_EXPORT
|
||||
#pragma message ("polymorphic_derived2 exported")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef POLYMORPHIC_DERIVED2_DLL_DECL
|
||||
#define POLYMORPHIC_DERIVED2_DLL_DECL
|
||||
#endif
|
||||
|
||||
#include "polymorphic_base.hpp"
|
||||
|
||||
#if defined(POLYMORPHIC_DERIVED2_IMPORT)
|
||||
#define DLL_DECL BOOST_SYMBOL_IMPORT
|
||||
#elif defined(POLYMORPHIC_DERIVED2_EXPORT)
|
||||
#define DLL_DECL BOOST_SYMBOL_EXPORT
|
||||
#else
|
||||
#define DLL_DECL
|
||||
#endif
|
||||
|
||||
class DLL_DECL polymorphic_derived2 :
|
||||
class POLYMORPHIC_DERIVED2_DLL_DECL polymorphic_derived2 :
|
||||
public polymorphic_base
|
||||
{
|
||||
friend class boost::serialization::access;
|
||||
@@ -44,10 +48,15 @@ class 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 {
|
||||
return "polymorphic_derived2";
|
||||
}
|
||||
public:
|
||||
polymorphic_derived2(){}
|
||||
~polymorphic_derived2(){}
|
||||
};
|
||||
|
||||
// we use this because we want to assign a key to this type
|
||||
@@ -63,7 +72,5 @@ BOOST_CLASS_TYPE_INFO(
|
||||
boost::serialization::extended_type_info_typeid<polymorphic_derived2>
|
||||
)
|
||||
|
||||
#undef DLL_DECL
|
||||
|
||||
#endif // POLYMORPHIC_DERIVED2_HPP
|
||||
#endif // BOOST_SERIALIZATION_TEST_POLYMORPHIC_DERIVED2_HPP
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace std{
|
||||
#include "test_tools.hpp"
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/serialization/boost_array.hpp>
|
||||
|
||||
#include "A.hpp"
|
||||
#include "A.ipp"
|
||||
|
||||
@@ -143,6 +143,7 @@ int test2(){
|
||||
ia >> BOOST_SERIALIZATION_NVP(j2);
|
||||
}
|
||||
BOOST_CHECK(*j1 == *j2);
|
||||
delete j1;
|
||||
BOOST_CHECK(j2 == j2->j);
|
||||
std::remove(testfile);
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@@ -44,6 +44,7 @@ int test_main( int /* argc */, char* /* argv */[] )
|
||||
}
|
||||
BOOST_CHECK(tb != tb1);
|
||||
BOOST_CHECK(*tb == *tb1);
|
||||
delete tb;
|
||||
std::remove(testfile);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -198,6 +198,7 @@ test_main( int /* argc */, char* /* argv */[] )
|
||||
BOOST_CHECK(1 == save_count);
|
||||
BOOST_CHECK(1 == load_count);
|
||||
BOOST_CHECK(*bp2 == *bp);
|
||||
delete bp;
|
||||
std::remove(testfile);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@@ -45,7 +45,6 @@ namespace std{
|
||||
#include <boost/serialization/export.hpp>
|
||||
#include <boost/serialization/access.hpp>
|
||||
|
||||
#define POLYMORPHIC_BASE_IMPORT
|
||||
#include "polymorphic_base.hpp"
|
||||
|
||||
class polymorphic_derived1 : public polymorphic_base
|
||||
@@ -62,12 +61,13 @@ public:
|
||||
virtual ~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_DERIVED_IMPORT
|
||||
#define POLYMORPHIC_DERIVED2_IMPORT
|
||||
#include "polymorphic_derived2.hpp"
|
||||
|
||||
// save exported polymorphic class
|
||||
@@ -86,8 +86,9 @@ void save_exported(const char *testfile)
|
||||
oa << BOOST_SERIALIZATION_NVP(rb2);
|
||||
oa << BOOST_SERIALIZATION_NVP(rd21);
|
||||
|
||||
delete rb1;
|
||||
delete rd21;
|
||||
delete rb2;
|
||||
delete rb1;
|
||||
}
|
||||
|
||||
// save exported polymorphic class
|
||||
@@ -129,9 +130,9 @@ void load_exported(const char *testfile)
|
||||
::type::get_const_instance().get_derived_extended_type_info(*rd21),
|
||||
"restored pointer d2 not of correct type"
|
||||
);
|
||||
delete rb1;
|
||||
delete rb2;
|
||||
delete rd21;
|
||||
delete rb2;
|
||||
delete rb1;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -165,10 +165,10 @@ test_main( int /* argc */, char* /* argv */[] )
|
||||
BOOST_REQUIRE(NULL != testfile);
|
||||
|
||||
HINSTANCE hDLL; // Handle to DLL
|
||||
hDLL = LoadLibrary(_T("plugin_polymorphic_derived2.dll"));
|
||||
hDLL = LoadLibrary(_T("polymorphic_derived2.dll"));
|
||||
BOOST_CHECK_MESSAGE(
|
||||
(0 != hDLL),
|
||||
"Failed to find/load plugin_polymorphic_derived2"
|
||||
"Failed to find/load polymorphic_derived2"
|
||||
);
|
||||
if(0 == hDLL)
|
||||
return EXIT_FAILURE;
|
||||
@@ -192,8 +192,9 @@ test_main( int /* argc */, char* /* argv */[] )
|
||||
BOOST_REQUIRE(NULL != testfile);
|
||||
|
||||
void * hDLL; // Handle to DLL
|
||||
hDLL = dlopen("plugin_polymorphic_derived2.so", RTLD_NOW | RTLD_GLOBAL);
|
||||
hDLL = dlopen("polymorphic_derived2.so", RTLD_NOW | RTLD_GLOBAL);
|
||||
BOOST_CHECK_MESSAGE((0 != hDLL), "Failed to find/load plugin_polymorphic_derived2" );
|
||||
BOOST_CHECK_MESSAGE((0 != hDLL), dlerror() );
|
||||
if(0 == hDLL)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
|
||||
+2
-10
@@ -56,21 +56,13 @@ BOOST_SERIALIZATION_MWERKS_BASE_AND_DERIVED(polymorphic_base, polymorphic_derive
|
||||
// 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 BOOST_SYMBOL_EXPORT void polymorphic_derived2::serialize(
|
||||
template void polymorphic_derived2::serialize(
|
||||
test_oarchive & ar,
|
||||
const unsigned int version
|
||||
);
|
||||
template BOOST_SYMBOL_EXPORT void polymorphic_derived2::serialize(
|
||||
template void polymorphic_derived2::serialize(
|
||||
test_iarchive & ar,
|
||||
const unsigned int version
|
||||
);
|
||||
|
||||
@@ -44,89 +44,6 @@ struct ptr_equal_to {
|
||||
}
|
||||
};
|
||||
|
||||
#include <boost/serialization/list.hpp>
|
||||
void test_list(){
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(NULL != testfile);
|
||||
|
||||
std::list<A *> alist;
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
A * free_a_ptr = new A;
|
||||
alist.push_back(free_a_ptr);
|
||||
alist.push_back(new A);
|
||||
// verify that first element is the same as the free pointer
|
||||
BOOST_CHECK((*alist.begin()) == free_a_ptr);
|
||||
oa << boost::serialization::make_nvp("alist", alist);
|
||||
oa << boost::serialization::make_nvp("free_a_ptr", free_a_ptr);
|
||||
}
|
||||
std::list<A *> alist1;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
A * free_a_ptr1;
|
||||
ia >> boost::serialization::make_nvp("alist", alist1);
|
||||
ia >> boost::serialization::make_nvp("free_a_ptr", free_a_ptr1);
|
||||
BOOST_CHECK(
|
||||
alist.size() == alist1.size()
|
||||
&& std::equal(alist.begin(),alist.end(),alist1.begin(),ptr_equal_to<A *>())
|
||||
);
|
||||
// verify that first element is the same as the free pointer
|
||||
BOOST_CHECK((*alist1.begin()) == free_a_ptr1);
|
||||
}
|
||||
|
||||
std::for_each(
|
||||
alist.begin(),
|
||||
alist.end(),
|
||||
boost::checked_deleter<A>()
|
||||
);
|
||||
std::for_each(
|
||||
alist1.begin(),
|
||||
alist1.end(),
|
||||
boost::checked_deleter<A>()
|
||||
);
|
||||
std::remove(testfile);
|
||||
}
|
||||
|
||||
#ifdef BOOST_HAS_SLIST
|
||||
#include <boost/serialization/slist.hpp>
|
||||
void test_slist(){
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(NULL != testfile);
|
||||
|
||||
std::list<A *> aslist;
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
aslist.push_back(new A);
|
||||
aslist.push_back(new A);
|
||||
oa << boost::serialization::make_nvp("aslist", aslist);
|
||||
}
|
||||
std::list<A *> aslist1;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("aslist", aslist1);
|
||||
BOOST_CHECK(aslist.size() == aslist1.size() &&
|
||||
std::equal(aslist.begin(),aslist.end(),aslist1.begin(),ptr_equal_to<A *>())
|
||||
);
|
||||
}
|
||||
std::for_each(
|
||||
aslist.begin(),
|
||||
aslist.end(),
|
||||
boost::checked_deleter<A>()
|
||||
);
|
||||
std::for_each(
|
||||
aslist1.begin(),
|
||||
aslist1.end(),
|
||||
boost::checked_deleter<A>()
|
||||
);
|
||||
std::remove(testfile);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CXX11_HDR_FORWARD_LIST
|
||||
#include <boost/serialization/forward_list.hpp>
|
||||
void test_forward_list(){
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
@@ -146,7 +63,12 @@ void test_forward_list(){
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("aslist", aslist1);
|
||||
BOOST_CHECK(
|
||||
std::equal(aslist.begin(),aslist.end(),aslist1.begin(),ptr_equal_to<A *>())
|
||||
std::equal(
|
||||
aslist.begin(),
|
||||
aslist.end(),
|
||||
aslist1.begin(),
|
||||
ptr_equal_to<A *>()
|
||||
)
|
||||
);
|
||||
}
|
||||
std::for_each(
|
||||
@@ -161,19 +83,10 @@ void test_forward_list(){
|
||||
);
|
||||
std::remove(testfile);
|
||||
}
|
||||
#endif
|
||||
|
||||
int test_main( int /* argc */, char* /* argv */[] )
|
||||
{
|
||||
test_list();
|
||||
|
||||
#ifdef BOOST_HAS_SLIST
|
||||
test_slist();
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CXX11_HDR_FORWARD_LIST
|
||||
test_forward_list();
|
||||
#endif
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <boost/serialization/traits.hpp>
|
||||
#include <boost/serialization/type_info_implementation.hpp>
|
||||
#include <boost/serialization/version.hpp>
|
||||
#include <boost/serialization/singleton.hpp>
|
||||
|
||||
struct foo
|
||||
{
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// test_const.cpp
|
||||
|
||||
// (C) Copyright 2002 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)
|
||||
|
||||
#include <boost/archive/binary_iarchive.hpp>
|
||||
#include <boost/serialization/vector.hpp>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
void f()
|
||||
{
|
||||
std::stringstream iss;
|
||||
boost::archive::binary_iarchive ar(iss);
|
||||
std::vector<int> out;
|
||||
ar >> out;
|
||||
}
|
||||
|
||||
int
|
||||
main(int /*argc*/, char * /*argv*/[]){
|
||||
return 0;
|
||||
}
|
||||
@@ -29,7 +29,7 @@ namespace std{
|
||||
|
||||
struct test_dummy_out {
|
||||
template<class Archive>
|
||||
void save(Archive & ar, const unsigned int /*version*/) const {
|
||||
void save(Archive &, const unsigned int /*version*/) const {
|
||||
throw boost::archive::archive_exception(
|
||||
boost::archive::archive_exception::other_exception
|
||||
);
|
||||
@@ -77,10 +77,10 @@ int test_out(){
|
||||
|
||||
struct test_dummy_in {
|
||||
template<class Archive>
|
||||
void save(Archive & ar, const unsigned int /*version*/) const {
|
||||
void save(Archive & /* ar */, const unsigned int /*version*/) const {
|
||||
}
|
||||
template<class Archive>
|
||||
void load(Archive & ar, const unsigned int /*version*/){
|
||||
void load(Archive & /* ar */, const unsigned int /*version*/){
|
||||
throw boost::archive::archive_exception(
|
||||
boost::archive::archive_exception::other_exception
|
||||
);
|
||||
|
||||
@@ -49,36 +49,9 @@ void test_list(){
|
||||
std::remove(testfile);
|
||||
}
|
||||
|
||||
#ifdef BOOST_HAS_SLIST
|
||||
#include <boost/serialization/slist.hpp>
|
||||
void test_slist(){
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_STD_EXTENSION_NAMESPACE::slist<A> aslist;
|
||||
aslist.push_front(A());
|
||||
aslist.push_front(A());
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
oa << boost::serialization::make_nvp("aslist", aslist);
|
||||
}
|
||||
BOOST_STD_EXTENSION_NAMESPACE::slist<A> aslist1;{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("aslist", aslist1);
|
||||
}
|
||||
BOOST_CHECK(aslist == aslist1);
|
||||
std::remove(testfile);
|
||||
}
|
||||
#endif
|
||||
|
||||
int test_main( int /* argc */, char* /* argv */[] )
|
||||
{
|
||||
test_list();
|
||||
|
||||
#ifdef BOOST_HAS_SLIST
|
||||
test_slist();
|
||||
#endif
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,51 +89,9 @@ void test_list(){
|
||||
std::remove(testfile);
|
||||
}
|
||||
|
||||
#ifdef BOOST_HAS_SLIST
|
||||
#include <boost/serialization/slist.hpp>
|
||||
void test_slist(){
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(NULL != testfile);
|
||||
|
||||
std::list<A *> aslist;
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
aslist.push_back(new A);
|
||||
aslist.push_back(new A);
|
||||
oa << boost::serialization::make_nvp("aslist", aslist);
|
||||
}
|
||||
std::list<A *> aslist1;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("aslist", aslist1);
|
||||
BOOST_CHECK(aslist.size() == aslist1.size() &&
|
||||
std::equal(aslist.begin(),aslist.end(),aslist1.begin(),ptr_equal_to<A *>())
|
||||
);
|
||||
}
|
||||
std::for_each(
|
||||
aslist.begin(),
|
||||
aslist.end(),
|
||||
boost::checked_deleter<A>()
|
||||
);
|
||||
std::for_each(
|
||||
aslist1.begin(),
|
||||
aslist1.end(),
|
||||
boost::checked_deleter<A>()
|
||||
);
|
||||
std::remove(testfile);
|
||||
}
|
||||
#endif
|
||||
|
||||
int test_main( int /* argc */, char* /* argv */[] )
|
||||
{
|
||||
test_list();
|
||||
|
||||
#ifdef BOOST_HAS_SLIST
|
||||
test_slist();
|
||||
#endif
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -117,5 +117,8 @@ int test_main(int /* argc */, char * /* argv */[])
|
||||
// Try to save and load pointers to Bs, to an xml archive
|
||||
test_save_and_load<xml_oarchive, xml_iarchive>(b, b1);
|
||||
|
||||
delete a;
|
||||
delete b;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace std{
|
||||
#include "test_tools.hpp"
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
#include <boost/array.hpp>
|
||||
|
||||
#include "A.hpp"
|
||||
#include "A.ipp"
|
||||
|
||||
@@ -41,14 +41,6 @@ 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
|
||||
|
||||
+39
-2
@@ -24,9 +24,25 @@ namespace std{
|
||||
#include "test_tools.hpp"
|
||||
|
||||
#include <boost/serialization/optional.hpp>
|
||||
#include <boost/serialization/string.hpp>
|
||||
|
||||
#include "A.hpp"
|
||||
#include "A.ipp"
|
||||
struct A {
|
||||
int m_x;
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */){
|
||||
ar & boost::serialization::make_nvp("x", m_x);
|
||||
};
|
||||
bool operator==(const A & rhs) const {
|
||||
return m_x == rhs.m_x;
|
||||
}
|
||||
// note that default constructor is not trivial
|
||||
A() :
|
||||
m_x(0)
|
||||
{}
|
||||
A(int x) :
|
||||
m_x(x)
|
||||
{}
|
||||
};
|
||||
|
||||
int test_main( int /* argc */, char* /* argv */[] )
|
||||
{
|
||||
@@ -35,22 +51,43 @@ int test_main( int /* argc */, char* /* argv */[] )
|
||||
|
||||
const boost::optional<int> aoptional1;
|
||||
const boost::optional<int> aoptional2(123);
|
||||
const boost::optional<A> aoptional3;
|
||||
A a(1);
|
||||
const boost::optional<A> aoptional4(a);
|
||||
const boost::optional<A *> aoptional5;
|
||||
const boost::optional<A *> aoptional6(& a);
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
oa << boost::serialization::make_nvp("aoptional1",aoptional1);
|
||||
oa << boost::serialization::make_nvp("aoptional2",aoptional2);
|
||||
oa << boost::serialization::make_nvp("aoptional3",aoptional3);
|
||||
oa << boost::serialization::make_nvp("aoptional4",aoptional4);
|
||||
oa << boost::serialization::make_nvp("aoptional5",aoptional5);
|
||||
oa << boost::serialization::make_nvp("aoptional6",aoptional6);
|
||||
}
|
||||
boost::optional<int> aoptional1a(999);
|
||||
boost::optional<int> aoptional2a;
|
||||
boost::optional<A> aoptional3a;
|
||||
boost::optional<A> aoptional4a;
|
||||
boost::optional<A *> aoptional5a;
|
||||
boost::optional<A *> aoptional6a;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("aoptional1",aoptional1a);
|
||||
ia >> boost::serialization::make_nvp("aoptional2",aoptional2a);
|
||||
ia >> boost::serialization::make_nvp("aoptional3",aoptional3a);
|
||||
ia >> boost::serialization::make_nvp("aoptional4",aoptional4a);
|
||||
ia >> boost::serialization::make_nvp("aoptional5",aoptional5a);
|
||||
ia >> boost::serialization::make_nvp("aoptional6",aoptional6a);
|
||||
}
|
||||
BOOST_CHECK(aoptional1 == aoptional1a);
|
||||
BOOST_CHECK(aoptional2 == aoptional2a);
|
||||
BOOST_CHECK(aoptional3 == aoptional3a);
|
||||
BOOST_CHECK(aoptional4.get() == aoptional4a.get());
|
||||
BOOST_CHECK(aoptional5 == aoptional5a);
|
||||
BOOST_CHECK(*aoptional6.get() == *aoptional6a.get());
|
||||
|
||||
std::remove(testfile);
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
+19
-3
@@ -49,19 +49,27 @@ test_set(){
|
||||
std::set<A> aset;
|
||||
aset.insert(A());
|
||||
aset.insert(A());
|
||||
const A * a_ptr = & * aset.begin();
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
oa << boost::serialization::make_nvp("aset", aset);
|
||||
// serialize a pointer into the set
|
||||
oa << boost::serialization::make_nvp("a_ptr", a_ptr);
|
||||
}
|
||||
std::set<A> aset1;
|
||||
A * a_ptr1;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("aset", aset1);
|
||||
// deserialize a pointer into the set
|
||||
ia >> boost::serialization::make_nvp("a_ptr1", a_ptr1);
|
||||
}
|
||||
BOOST_CHECK(aset == aset1);
|
||||
std::remove(testfile);
|
||||
BOOST_CHECK_EQUAL(aset, aset1);
|
||||
BOOST_CHECK_EQUAL(*a_ptr1, * aset1.begin());
|
||||
BOOST_CHECK_EQUAL(a_ptr1, & * aset1.begin());
|
||||
std::remove(testfile);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -72,18 +80,26 @@ test_multiset(){
|
||||
std::multiset<A> amultiset;
|
||||
amultiset.insert(A());
|
||||
amultiset.insert(A());
|
||||
{
|
||||
const A * a_ptr = & * amultiset.begin();
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
oa << boost::serialization::make_nvp("amultiset", amultiset);
|
||||
// serialize a pointer into the set
|
||||
oa << boost::serialization::make_nvp("a_ptr", a_ptr);
|
||||
}
|
||||
std::multiset<A> amultiset1;
|
||||
A * a_ptr1;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("amultiset", amultiset1);
|
||||
// deserialize a pointer into the set
|
||||
ia >> boost::serialization::make_nvp("a_ptr1", a_ptr1);
|
||||
}
|
||||
BOOST_CHECK(amultiset == amultiset1);
|
||||
BOOST_CHECK_EQUAL(*a_ptr1, * amultiset1.begin());
|
||||
BOOST_CHECK_EQUAL(a_ptr1, & * amultiset1.begin());
|
||||
std::remove(testfile);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ int test_main( int /* argc */, char* /* argv */[] )
|
||||
}
|
||||
BOOST_CHECK(ta != ta1);
|
||||
BOOST_CHECK(*ta == *ta1);
|
||||
delete ta;
|
||||
std::remove(testfile);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
+62
-23
@@ -1,35 +1,74 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// test_singleton.cpp: test implementation of run-time casting of void pointers
|
||||
// test_singleton.cpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// (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)
|
||||
// <gennadiy.rozental@tfn.com>
|
||||
|
||||
#include "test_tools.hpp"
|
||||
// should pass compilation and execution
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/serialization/singleton.hpp>
|
||||
|
||||
class x {
|
||||
#include "test_tools.hpp"
|
||||
|
||||
static int i = 0;
|
||||
|
||||
struct A {
|
||||
int m_id;
|
||||
A() : m_id(++i) {}
|
||||
~A(){
|
||||
// verify that objects are destroyed in sequence reverse of construction
|
||||
if(i-- != m_id) std::terminate();
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
test1(const x & x1, const x & x2){
|
||||
BOOST_CHECK(& x1 == & x2);
|
||||
struct B {
|
||||
int m_id;
|
||||
B() : m_id(++i) {}
|
||||
~B(){
|
||||
// verify that objects are destroyed in sequence reverse of construction
|
||||
if(i-- != m_id) std::terminate();
|
||||
}
|
||||
};
|
||||
|
||||
struct C {
|
||||
int m_id;
|
||||
C() : m_id(++i) {}
|
||||
~C(){
|
||||
// verify that objects are destroyed in sequence reverse of construction
|
||||
if(i-- != m_id) std::terminate();
|
||||
}
|
||||
};
|
||||
|
||||
struct D {
|
||||
int m_id;
|
||||
D(){
|
||||
// verify that only one object is indeed created
|
||||
const C & c = boost::serialization::singleton<C>::get_const_instance();
|
||||
const C & c1 = boost::serialization::singleton<C>::get_const_instance();
|
||||
BOOST_CHECK_EQUAL(&c, &c1);
|
||||
|
||||
// verify that objects are created in sequence of definition
|
||||
BOOST_CHECK_EQUAL(c.m_id, 1);
|
||||
const B & b = boost::serialization::singleton<B>::get_const_instance();
|
||||
BOOST_CHECK_EQUAL(b.m_id, 2);
|
||||
const A & a = boost::serialization::singleton<A>::get_const_instance();
|
||||
BOOST_CHECK_EQUAL(a.m_id, 3);
|
||||
std::cout << a.m_id << b.m_id << c.m_id << '\n';
|
||||
|
||||
m_id = ++i;
|
||||
}
|
||||
~D(){
|
||||
// verify that objects are destroyed in sequence reverse of construction
|
||||
if(i-- != m_id) std::terminate();
|
||||
}
|
||||
};
|
||||
|
||||
int test_main(int, char *[]){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
test_main( int /* argc */, char* /* argv */[] )
|
||||
{
|
||||
const x & x1 = boost::serialization::singleton<x>::get_const_instance();
|
||||
const x & x2 = boost::serialization::singleton<x>::get_const_instance();
|
||||
|
||||
BOOST_CHECK(& x1 == & x2);
|
||||
|
||||
test1(
|
||||
boost::serialization::singleton<x>::get_const_instance(),
|
||||
boost::serialization::singleton<x>::get_const_instance()
|
||||
);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
// note: not a singleton
|
||||
D d;
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// test_list.cpp
|
||||
|
||||
// (C) Copyright 2002 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)
|
||||
|
||||
// should pass compilation and execution
|
||||
|
||||
#include <cstddef> // NULL
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <cstdio> // remove
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::remove;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
#include "test_tools.hpp"
|
||||
|
||||
#include "A.hpp"
|
||||
#include "A.ipp"
|
||||
|
||||
#include <boost/serialization/slist.hpp>
|
||||
void test_slist(){
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_STD_EXTENSION_NAMESPACE::slist<A> aslist;
|
||||
aslist.push_front(A());
|
||||
aslist.push_front(A());
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
oa << boost::serialization::make_nvp("aslist", aslist);
|
||||
}
|
||||
BOOST_STD_EXTENSION_NAMESPACE::slist<A> aslist1;{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("aslist", aslist1);
|
||||
}
|
||||
BOOST_CHECK(aslist == aslist1);
|
||||
std::remove(testfile);
|
||||
}
|
||||
|
||||
int test_main( int /* argc */, char* /* argv */[] )
|
||||
{
|
||||
test_slist();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// test_list.cpp
|
||||
|
||||
// (C) Copyright 2002 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)
|
||||
|
||||
// should pass compilation and execution
|
||||
|
||||
#include <cstddef>
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <cstdio> // remove
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::remove;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/checked_delete.hpp>
|
||||
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
#include "test_tools.hpp"
|
||||
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
|
||||
#include "A.hpp"
|
||||
#include "A.ipp"
|
||||
|
||||
template<class T>
|
||||
struct ptr_equal_to {
|
||||
BOOST_STATIC_ASSERT(::boost::is_pointer< T >::value);
|
||||
bool operator()(T const _Left, T const _Right) const
|
||||
{
|
||||
if(NULL == _Left && NULL == _Right)
|
||||
return true;
|
||||
if(typeid(*_Left) != typeid(*_Right))
|
||||
return false;
|
||||
return *_Left == *_Right;
|
||||
}
|
||||
};
|
||||
|
||||
#include <boost/serialization/slist.hpp>
|
||||
void test_slist(){
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(NULL != testfile);
|
||||
|
||||
BOOST_STD_EXTENSION_NAMESPACE::slist<A *> aslist;
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
aslist.push_front(new A);
|
||||
aslist.push_front(new A);
|
||||
oa << boost::serialization::make_nvp("aslist", aslist);
|
||||
}
|
||||
BOOST_STD_EXTENSION_NAMESPACE::slist<A *> aslist1;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("aslist", aslist1);
|
||||
BOOST_CHECK(aslist.size() == aslist1.size() &&
|
||||
std::equal(aslist.begin(),aslist.end(),aslist1.begin(),ptr_equal_to<A *>())
|
||||
);
|
||||
}
|
||||
std::for_each(
|
||||
aslist.begin(),
|
||||
aslist.end(),
|
||||
boost::checked_deleter<A>()
|
||||
);
|
||||
std::for_each(
|
||||
aslist1.begin(),
|
||||
aslist1.end(),
|
||||
boost::checked_deleter<A>()
|
||||
);
|
||||
std::remove(testfile);
|
||||
}
|
||||
|
||||
int test_main( int /* argc */, char* /* argv */[] )
|
||||
{
|
||||
test_slist();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
// EOF
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <cstddef> // size_t
|
||||
#include <boost/config.hpp>
|
||||
#ifndef BOOST_NO_EXCEPTION_STD_NAMESPACE
|
||||
#include <exception>
|
||||
@@ -77,14 +76,12 @@ namespace boost {
|
||||
namespace archive {
|
||||
const char * test_filename(const char * dir = NULL, char *fname = NULL){
|
||||
static char ibuffer [512];
|
||||
std::size_t i;
|
||||
ibuffer[0] = '\0';
|
||||
if(NULL == dir){
|
||||
dir = boost::archive::tmpdir();
|
||||
}
|
||||
STRCPY(ibuffer, dir);
|
||||
std::strcat(ibuffer, "/");
|
||||
i = std::strlen(ibuffer);
|
||||
if(NULL == fname){
|
||||
char old_dir[256];
|
||||
_getcwd(old_dir, sizeof(old_dir) - 1);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <cstddef> // NULL
|
||||
#include <cstdio> // remove
|
||||
#include <cstring> // strcmp
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
@@ -54,6 +55,22 @@ class polymorphic_derived2 : public polymorphic_base
|
||||
}
|
||||
};
|
||||
|
||||
struct type1 {
|
||||
template<typename Archive>
|
||||
void serialize(Archive&, unsigned int ver) {
|
||||
BOOST_CHECK(ver == 1);
|
||||
}
|
||||
};
|
||||
struct type2 {
|
||||
template<typename Archive>
|
||||
void serialize(Archive&, unsigned int ver) {
|
||||
BOOST_CHECK(ver == 2);
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_CLASS_VERSION(type1, 1);
|
||||
BOOST_CLASS_VERSION(type2, 2);
|
||||
|
||||
// save unregistered polymorphic classes
|
||||
void save_unregistered1(const char *testfile)
|
||||
{
|
||||
@@ -61,7 +78,7 @@ void save_unregistered1(const char *testfile)
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
|
||||
polymorphic_base *rb1 = new polymorphic_derived1;
|
||||
|
||||
|
||||
// registration IS necessary when serializing a polymorphic class
|
||||
// through pointer to the base class
|
||||
bool except = false;
|
||||
@@ -98,7 +115,7 @@ void load_unregistered1(const char *testfile)
|
||||
BOOST_CATCH(boost::archive::archive_exception aex){
|
||||
except = true;
|
||||
BOOST_CHECK_MESSAGE(
|
||||
NULL == rb1,
|
||||
NULL == rb1,
|
||||
"failed load resulted in a non-null pointer"
|
||||
);
|
||||
}
|
||||
@@ -227,6 +244,55 @@ void load_registered(const char *testfile)
|
||||
delete rb2;
|
||||
}
|
||||
|
||||
// store a pointer from slot0
|
||||
void save_unregistered_pointer(const char *testfile)
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
|
||||
oa.register_type(static_cast<type2 *>(NULL));
|
||||
|
||||
type1 instance1;
|
||||
type2 *pointer2 = new type2;
|
||||
|
||||
BOOST_TRY {
|
||||
oa & BOOST_SERIALIZATION_NVP(instance1) & BOOST_SERIALIZATION_NVP(pointer2);
|
||||
}
|
||||
BOOST_CATCH(...) {
|
||||
BOOST_CHECK_MESSAGE(false, "unexpected exception");
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
|
||||
delete pointer2;
|
||||
}
|
||||
|
||||
// load a pointer from slot0 which has no pointer serializer
|
||||
void load_unregistered_pointer(const char *testfile)
|
||||
{
|
||||
test_istream is(testfile);
|
||||
test_iarchive ia(is);
|
||||
|
||||
type1 instance1;
|
||||
type2 *pointer2(NULL);
|
||||
|
||||
bool except = false;
|
||||
BOOST_TRY {
|
||||
ia & BOOST_SERIALIZATION_NVP(instance1) & BOOST_SERIALIZATION_NVP(pointer2);
|
||||
}
|
||||
BOOST_CATCH(boost::archive::archive_exception aex){
|
||||
except = true;
|
||||
BOOST_CHECK_MESSAGE(
|
||||
std::strcmp(aex.what(), "unregistered class") == 0,
|
||||
"incorrect exception"
|
||||
);
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
BOOST_CHECK_MESSAGE(except, "lack of registration not detected !");
|
||||
BOOST_CHECK_MESSAGE(NULL == pointer2, "expected failed load");
|
||||
|
||||
delete pointer2;
|
||||
}
|
||||
|
||||
int
|
||||
test_main( int /* argc */, char* /* argv */[] )
|
||||
{
|
||||
@@ -238,6 +304,8 @@ test_main( int /* argc */, char* /* argv */[] )
|
||||
load_unregistered2(testfile);
|
||||
save_registered(testfile);
|
||||
load_registered(testfile);
|
||||
save_unregistered_pointer(testfile);
|
||||
load_unregistered_pointer(testfile);
|
||||
std::remove(testfile);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
+148
-18
@@ -19,7 +19,7 @@
|
||||
#include <cstdio> // remove
|
||||
#include <fstream>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/math/special_functions/next.hpp>
|
||||
#include <boost/math/special_functions/next.hpp> // float_distance
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::remove;
|
||||
@@ -145,25 +145,155 @@ void do_bad_read()
|
||||
#endif
|
||||
}
|
||||
|
||||
struct H {
|
||||
int i;
|
||||
};
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive &ar, H & h, const unsigned int /*file_version*/){
|
||||
ar & boost::serialization::make_nvp("h", h.i);
|
||||
}
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
inline bool operator==(H const & lhs, H const & rhs) {
|
||||
return lhs.i == rhs.i;
|
||||
}
|
||||
|
||||
inline bool operator!=(H const & lhs, H const & rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
inline bool operator<(H const & lhs, H const & rhs) {
|
||||
return lhs.i < rhs.i;
|
||||
}
|
||||
|
||||
inline std::size_t hash_value(H const & val) {
|
||||
return val.i;
|
||||
}
|
||||
|
||||
void test_pointer(){
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(testfile != NULL);
|
||||
typedef boost::variant<H, int> variant_t;
|
||||
H const h = {5};
|
||||
variant_t v(h);
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
oa << boost::serialization::make_nvp("written", v);
|
||||
const H * h_ptr = & boost::strict_get<H const &>(v);
|
||||
oa << boost::serialization::make_nvp("written", h_ptr);
|
||||
}
|
||||
variant_t v2;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("written", v2);
|
||||
H * h2_ptr;
|
||||
ia >> boost::serialization::make_nvp("written", h2_ptr);
|
||||
BOOST_CHECK_EQUAL(h, boost::strict_get<H const>(v2));
|
||||
BOOST_CHECK_EQUAL(h2_ptr, & boost::strict_get<H const &>(v2));
|
||||
}
|
||||
BOOST_CHECK_EQUAL(v, v2);
|
||||
}
|
||||
|
||||
#include <boost/serialization/map.hpp>
|
||||
#include <boost/serialization/set.hpp>
|
||||
|
||||
// test a pointer to an object contained into a variant that is an
|
||||
// element of a set
|
||||
void test_variant_set()
|
||||
{
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(testfile != NULL);
|
||||
typedef boost::variant<H, int> variant_t;
|
||||
typedef std::set<variant_t> uset_t;
|
||||
uset_t set;
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
H const h = {5};
|
||||
variant_t v(h);
|
||||
set.insert(v);
|
||||
oa << boost::serialization::make_nvp("written", set);
|
||||
H const * const h_ptr = boost::strict_get<H const>(&(*set.begin()));
|
||||
oa << boost::serialization::make_nvp("written", h_ptr);
|
||||
}
|
||||
uset_t set2;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("written", set2);
|
||||
H * h_ptr;
|
||||
ia >> boost::serialization::make_nvp("written", h_ptr);
|
||||
const H * h_ptr2 = & boost::strict_get<H const>(*set2.begin());
|
||||
BOOST_CHECK_EQUAL(h_ptr, h_ptr2);
|
||||
}
|
||||
BOOST_CHECK_EQUAL(set, set2);
|
||||
}
|
||||
|
||||
// test a pointer to an object contained into a variant that is an
|
||||
// element of a map
|
||||
void test_variant_map()
|
||||
{
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
BOOST_REQUIRE(testfile != NULL);
|
||||
typedef boost::variant<H, int> variant_t;
|
||||
typedef std::map<int, variant_t> map_t;
|
||||
map_t map;
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
H const h = {5};
|
||||
variant_t v(h);
|
||||
map[0] = v;
|
||||
BOOST_ASSERT(1 == map.size());
|
||||
oa << boost::serialization::make_nvp("written", map);
|
||||
H const * const h_ptr = boost::strict_get<H const>(&map[0]);
|
||||
BOOST_CHECK_EQUAL(h_ptr, boost::strict_get<H const>(&map[0]));
|
||||
oa << boost::serialization::make_nvp("written", h_ptr);
|
||||
}
|
||||
map_t map2;
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
ia >> boost::serialization::make_nvp("written", map2);
|
||||
BOOST_ASSERT(1 == map2.size());
|
||||
H * h_ptr;
|
||||
ia >> boost::serialization::make_nvp("written", h_ptr);
|
||||
H const * const h_ptr2 = boost::strict_get<H const>(&map2[0]);
|
||||
BOOST_CHECK_EQUAL(h_ptr, h_ptr2);
|
||||
}
|
||||
BOOST_CHECK_EQUAL(map, map2);
|
||||
}
|
||||
|
||||
int test_main( int /* argc */, char* /* argv */[] )
|
||||
{
|
||||
{
|
||||
boost::variant<bool, int, float, double, A, std::string> v;
|
||||
v = false;
|
||||
test_type(v);
|
||||
v = 1;
|
||||
test_type(v);
|
||||
v = (float) 2.3;
|
||||
test_type(v);
|
||||
v = (double) 6.4;
|
||||
test_type(v);
|
||||
v = std::string("we can't stop here, this is Bat Country");
|
||||
test_type(v);
|
||||
v = A();
|
||||
test_type(v);
|
||||
}
|
||||
do_bad_read();
|
||||
return EXIT_SUCCESS;
|
||||
{
|
||||
boost::variant<bool, int, float, double, A, std::string> v;
|
||||
v = false;
|
||||
test_type(v);
|
||||
v = 1;
|
||||
test_type(v);
|
||||
v = (float) 2.3;
|
||||
test_type(v);
|
||||
v = (double) 6.4;
|
||||
test_type(v);
|
||||
v = std::string("we can't stop here, this is Bat Country");
|
||||
test_type(v);
|
||||
v = A();
|
||||
test_type(v);
|
||||
}
|
||||
test_pointer();
|
||||
test_variant_set();
|
||||
test_variant_map();
|
||||
do_bad_read();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user