mirror of
https://github.com/boostorg/serialization.git
synced 2026-07-21 13:33:32 +00:00
Compare commits
71 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f01148e421 | |||
| cc2a996384 | |||
| 9e98df0a0d | |||
| feb53726e1 | |||
| b97bcdfeb3 | |||
| 723bd44abd | |||
| f297d80d6e | |||
| efcd46eb1b | |||
| 5778b99fd2 | |||
| c5549b2d6b | |||
| 237ff81ac6 | |||
| 65f05dc209 | |||
| 86996d0637 | |||
| 5c19264436 | |||
| af46ac2da3 | |||
| e1893dd28c | |||
| 28c333ce65 | |||
| 5edc5acf27 | |||
| c5120dfd11 | |||
| 87c50e75fa | |||
| 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 |
+78
-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,97 @@ 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 LINK=static,shared
|
||||
|
||||
- os: linux
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc LINK=static,shared
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc LINK=static,shared
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc LINK=static,shared
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang LINK=static,shared
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-libc++
|
||||
env: TOOLSET=clang LINK=static,shared
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang LINK=static,shared
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode10
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang LINK=static,shared
|
||||
|
||||
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
|
||||
- |-
|
||||
echo "using $TOOLSET : : $TRAVIS_COMPILER ;" > ~/user-config.jam
|
||||
- ./b2 -j 3 libs/serialization/test toolset=$TOOLSET link=${LINK:-shared}
|
||||
|
||||
notifications:
|
||||
email:
|
||||
|
||||
+91
-59
@@ -35,29 +35,12 @@ elseif( CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
|
||||
set(COMPILER_SUPPORTS_CXX11 TRUE)
|
||||
elseif( CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" )
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=300")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0" )
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3" )
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -dead_strip")
|
||||
set(COMPILER_SUPPORTS_CXX11 TRUE)
|
||||
endif()
|
||||
|
||||
#
|
||||
# IDE settings
|
||||
#
|
||||
|
||||
if( CMAKE_HOST_APPLE )
|
||||
# note: it seems that bjam builds both address models in any case
|
||||
# so we can defer this decision to the IDE just as we do for debug/release
|
||||
# so we'll not use this now
|
||||
# set(Boost_ADDRESS_MODEL 64 CACHE INTEGER "32/64 bits")
|
||||
set(Boost_USE_STATIC_LIBS ON CACHE BOOL "Link to Boost static libraries")
|
||||
set(Boost_USE_MULTITHREADED ON)
|
||||
else()
|
||||
set(Boost_ADDRESS_MODEL 64 CACHE INTEGER "32/64 bits")
|
||||
set(Boost_USE_STATIC_LIBS ON CACHE BOOL "Link to Boost static libraries")
|
||||
set(Boost_USE_MULTITHREADED ON)
|
||||
set(COMPILER_SUPPORTS_CXX11 FALSE)
|
||||
endif()
|
||||
|
||||
#
|
||||
@@ -107,46 +90,58 @@ endif()
|
||||
# end special note for Xcode
|
||||
############################
|
||||
|
||||
#
|
||||
# IDE settings
|
||||
#
|
||||
|
||||
set(Boost_DEBUG true)
|
||||
set(Boost_ADDRESS_MODEL 64 CACHE INTEGER "32/64 bits")
|
||||
set(Boost_USE_STATIC_LIBS TRUE CACHE BOOL "Use static libraries")
|
||||
set(Boost_USE_MULTITHREADED ON)
|
||||
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}")
|
||||
|
||||
if(Boost_FOUND)
|
||||
message(STATUS "Boost Found!")
|
||||
message(STATUS "Boost is ${BOOST_ROOT}")
|
||||
message(STATUS "Boost directories found at ${Boost_INCLUDE_DIRS}")
|
||||
message(STATUS "Boost libraries found at ${Boost_LIBRARY_DIRS}")
|
||||
message(STATUS "Boost libraries prefix is ${Boost_LIB_PREFIX}")
|
||||
message(STATUS "Boost component libraries to be linked are ${Boost_LIBRARIES}")
|
||||
message(STATUS "Boost version found is ${Boost_VERSION}")
|
||||
#include_directories("../include" "${Boost_INCLUDE_DIRS}")
|
||||
#link_directories("${Boost_LIBRARY_DIRS}")
|
||||
get_filename_component(BOOST_ROOT "../../.." ABSOLUTE)
|
||||
string(CONCAT boost_headers ${BOOST_ROOT} "/boost")
|
||||
if(NOT IS_DIRECTORY ${boost_headers})
|
||||
message(FATAL_ERROR "BOOST_ROOT not found")
|
||||
else()
|
||||
message(STATUS "Boost NOT Found!")
|
||||
message(STATUS "BOOST_ROOT is ${BOOST_ROOT}")
|
||||
endif()
|
||||
|
||||
if(Boost_USE_STATIC_LIBS)
|
||||
message(STATUS "Use static libraries")
|
||||
set(LINK_TYPE "STATIC")
|
||||
message(STATUS "Link to Boost static libraries")
|
||||
set(BUILD_SHARED_LIBS NO)
|
||||
string(CONCAT boost_stage ${BOOST_ROOT} "/stage/Debug/static")
|
||||
else()
|
||||
message(STATUS "Building shared libraries")
|
||||
set(LINK_TYPE "SHARED")
|
||||
message(STATUS "Link to Boost shared libraries")
|
||||
set(BUILD_SHARED_LIBS YES)
|
||||
add_definitions( "-DBOOST_ALL_DYN_LINK=1")
|
||||
add_definitions( "-DBOOST_ALL_NO_LIB=1")
|
||||
add_definitions( "-DBOOST_LIB_DIAGNOSTICS=1")
|
||||
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||
set(VISIBILITY_INLINES_HIDDEN)
|
||||
set(VISIBILITY_INLINES_HIDDEN YES)
|
||||
string(CONCAT boost_stage ${BOOST_ROOT} "/stage/Debug/shared")
|
||||
endif()
|
||||
|
||||
include(CheckIncludeFileCXX)
|
||||
|
||||
message(STATUS "Boost directories found at ${boost_headers}")
|
||||
message(STATUS "Boost libraries found at ${boost_stage}")
|
||||
set(CMAKE_LIBRARY_PATH ${boost_stage})
|
||||
|
||||
# list of archive names for which tests should be generated
|
||||
#set(archive_list text_archive text_warchive binary_archive xml_archive xml_warchive)
|
||||
set(archive_list text_archive)
|
||||
|
||||
# list of tests generated by each function call
|
||||
set(test_list)
|
||||
|
||||
include_directories(BEFORE ${BOOST_ROOT})
|
||||
|
||||
###########################
|
||||
# library builds
|
||||
|
||||
add_library(serialization ${LINK_TYPE}
|
||||
add_library(serialization
|
||||
../src/archive_exception.cpp
|
||||
../src/basic_archive.cpp
|
||||
../src/basic_iarchive.cpp
|
||||
@@ -166,7 +161,8 @@ add_library(serialization ${LINK_TYPE}
|
||||
../src/extended_type_info.cpp
|
||||
../src/polymorphic_iarchive.cpp
|
||||
../src/polymorphic_oarchive.cpp
|
||||
../src/singleton.cpp
|
||||
../src/polymorphic_text_iarchive.cpp
|
||||
../src/polymorphic_text_oarchive.cpp
|
||||
../src/stl_port.cpp
|
||||
../src/text_iarchive.cpp
|
||||
../src/text_oarchive.cpp
|
||||
@@ -179,7 +175,7 @@ add_library(serialization ${LINK_TYPE}
|
||||
../src/basic_xml_grammar.ipp # doesn't show up in "Source Files" in Xcode"'
|
||||
)
|
||||
|
||||
add_library(wserialization ${LINK_TYPE}
|
||||
add_library(wserialization
|
||||
../src/codecvt_null.cpp
|
||||
../src/basic_text_wiprimitive.cpp
|
||||
../src/basic_text_woprimitive.cpp
|
||||
@@ -191,9 +187,18 @@ add_library(wserialization ${LINK_TYPE}
|
||||
../src/basic_xml_grammar.ipp # doesn't show up in "Source Files" in Xcode"'
|
||||
)
|
||||
|
||||
set_property(TARGET wserialization PROPERTY LINK_LIBRARIES serialization)
|
||||
|
||||
# end library build
|
||||
###########################
|
||||
|
||||
add_library(filesystem SHARED IMPORTED GLOBAL ) # or STATIC instead of SHARED
|
||||
set_target_properties(filesystem PROPERTIES
|
||||
IMPORTED_LOCATION "${CMAKE_LIBRARY_PATH}/libboost_filesystem-clang-darwin-mt-d-x64-1_69.dylib"
|
||||
)
|
||||
get_property(loc TARGET filesystem PROPERTY LOCATION)
|
||||
message(STATUS "filesystem library located at:${loc}")
|
||||
|
||||
###########################
|
||||
# test targets
|
||||
|
||||
@@ -204,56 +209,73 @@ function( serialization_test test_name)
|
||||
endforeach()
|
||||
message(STATUS ${test_name})
|
||||
add_executable( ${test_name} ../test/${test_name}.cpp ${arglist} )
|
||||
target_link_libraries(${test_name} serialization wserialization ${Boost_LIBRARIES})
|
||||
target_link_libraries(${test_name} serialization wserialization filesystem)
|
||||
add_test( ${test_name} ${test_name} )
|
||||
endfunction(serialization_test)
|
||||
|
||||
function(archive_test test_name)
|
||||
set(test_list)
|
||||
set(arglist)
|
||||
foreach(a IN ITEMS ${ARGN} )
|
||||
set(arglist ${arglist} ../test/${a}.cpp)
|
||||
endforeach()
|
||||
foreach(
|
||||
archive-name
|
||||
IN ITEMS text_archive text_warchive binary_archive xml_archive xml_warchive
|
||||
IN ITEMS ${archive_list}
|
||||
)
|
||||
set(amended_test_name ${test_name}_${archive-name})
|
||||
message(STATUS ${amended_test_name})
|
||||
add_executable(${amended_test_name} ../test/${test_name}.cpp ${arglist})
|
||||
set_property(
|
||||
TARGET ${amended_test_name}
|
||||
PROPERTY COMPILE_DEFINITIONS BOOST_ARCHIVE_TEST=${archive-name}.hpp
|
||||
)
|
||||
target_link_libraries(${amended_test_name} serialization wserialization ${Boost_LIBRARIES})
|
||||
message(STATUS ${amended_test_name} " " ${arglist} " " ${archive-name})
|
||||
target_link_libraries(${amended_test_name} serialization wserialization filesystem)
|
||||
add_test(${amended_test_name} ${amended_test_name})
|
||||
set(test_list ${test_list} ${amended_test_name} PARENT_SCOPE)
|
||||
endforeach()
|
||||
endfunction(archive_test)
|
||||
|
||||
function(polymorphic_archive_test test_name)
|
||||
set(test_list)
|
||||
set(arglist)
|
||||
foreach(a IN ITEMS ${ARGN} )
|
||||
set(arglist ${arglist} ../test/${a}.cpp)
|
||||
endforeach()
|
||||
foreach(
|
||||
archive-name
|
||||
IN ITEMS text_archive text_warchive binary_archive xml_archive xml_warchive
|
||||
IN ITEMS ${archive_list}
|
||||
)
|
||||
set(amended_test_name ${test_name}_polymorphic_${archive-name})
|
||||
message(STATUS ${amended_test_name})
|
||||
set(amended_archive_name polymorphic_${archive-name})
|
||||
set(amended_test_name ${test_name}_${amended_archive_name})
|
||||
add_executable(${amended_test_name} ../test/${test_name}.cpp ${arglist})
|
||||
set_property(
|
||||
TARGET ${amended_test_name}
|
||||
PROPERTY COMPILE_DEFINITIONS BOOST_ARCHIVE_TEST=polymorphic_${archive-name}.hpp
|
||||
PROPERTY COMPILE_DEFINITIONS BOOST_ARCHIVE_TEST=${amended_archive_name}.hpp
|
||||
)
|
||||
target_link_libraries(${amended_test_name} serialization wserialization ${Boost_LIBRARIES})
|
||||
message(STATUS ${amended_test_name} " " ${arglist} " " ${amended_archive_name})
|
||||
target_link_libraries(${amended_test_name} serialization wserialization filesystem)
|
||||
add_test(${amended_test_name} ${amended_test_name})
|
||||
set(test_list ${test_list} ${amended_test_name} PARENT_SCOPE)
|
||||
endforeach()
|
||||
endfunction(polymorphic_archive_test)
|
||||
|
||||
enable_testing()
|
||||
|
||||
# serialization(test_dll_exported dll_polymorphic_derived2_lib)
|
||||
# serialization(test_dll_simple dll_a_lib)
|
||||
message(STATUS dll_a)
|
||||
add_library(dll_a SHARED ../test/dll_a.cpp)
|
||||
target_link_libraries(dll_a serialization)
|
||||
serialization_test(test_dll_simple)
|
||||
target_link_libraries(test_dll_simple dll_a serialization)
|
||||
|
||||
message(STATUS dll_polymorphic_base)
|
||||
add_library(dll_polymorphic_base SHARED ../test/polymorphic_base.cpp)
|
||||
target_link_libraries(dll_polymorphic_base serialization)
|
||||
|
||||
message(STATUS dll_polymorphic_derived2)
|
||||
add_library(dll_polymorphic_derived2 SHARED ../test/polymorphic_derived2.cpp)
|
||||
target_link_libraries(dll_polymorphic_derived2 dll_polymorphic_base serialization)
|
||||
|
||||
# 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
|
||||
@@ -266,9 +288,13 @@ 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)
|
||||
serialization_test(test_singleton)
|
||||
serialization_test(test_singleton_inherited)
|
||||
serialization_test(test_singleton_plain)
|
||||
|
||||
archive_test(test_native_array A)
|
||||
archive_test(test_boost_array A)
|
||||
@@ -288,7 +314,6 @@ archive_test(test_derived)
|
||||
archive_test(test_derived_class A)
|
||||
archive_test(test_diamond)
|
||||
archive_test(test_diamond_complex)
|
||||
archive_test(test_exported polymorphic_base)
|
||||
archive_test(test_forward_list A)
|
||||
archive_test(test_forward_list_ptrs A)
|
||||
archive_test(test_helper_support)
|
||||
@@ -300,7 +325,6 @@ archive_test(test_map_boost_unordered A)
|
||||
archive_test(test_mi)
|
||||
archive_test(test_multiple_ptrs A)
|
||||
archive_test(test_multiple_inheritance)
|
||||
archive_test(test_no_rtti polymorphic_base polymorphic_derived1)
|
||||
archive_test(test_new_operator A)
|
||||
archive_test(test_non_intrusive)
|
||||
archive_test(test_non_default_ctor)
|
||||
@@ -356,6 +380,14 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
polymorphic_archive_test(test_dll_exported polymorphic_derived1)
|
||||
foreach(test_name IN ITEMS ${test_list} )
|
||||
target_link_libraries(${test_name} dll_polymorphic_derived2 dll_polymorphic_base)
|
||||
message(STATUS " " target_link_libraries " " dll_polymorphic_derived2 " " dll_polymorphic_base)
|
||||
endforeach()
|
||||
|
||||
polymorphic_archive_test(test_no_rtti polymorphic_base polymorphic_derived1 polymorphic_derived2)
|
||||
polymorphic_archive_test(test_exported polymorphic_base polymorphic_derived1 polymorphic_derived2)
|
||||
polymorphic_archive_test(test_polymorphic test_polymorphic_A A)
|
||||
polymorphic_archive_test(test_polymorphic2 test_polymorphic2imp)
|
||||
polymorphic_archive_test(test_polymorphic_helper)
|
||||
@@ -366,7 +398,7 @@ polymorphic_archive_test(test_polymorphic_helper)
|
||||
####################
|
||||
# add headers in IDE
|
||||
|
||||
# for serialisation
|
||||
# for serialization
|
||||
|
||||
file(GLOB x
|
||||
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
|
||||
+14
-1
@@ -12,6 +12,17 @@ branches:
|
||||
- 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
|
||||
@@ -24,6 +35,7 @@ install:
|
||||
- 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
|
||||
@@ -53,6 +65,7 @@ install:
|
||||
- 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
|
||||
@@ -64,4 +77,4 @@ build: off
|
||||
|
||||
test_script:
|
||||
- cd libs/serialization/test
|
||||
- b2 toolset=gcc link=static,shared
|
||||
- b2 -j2 toolset=%BUILD_TOOLSET% link=%BUILD_LINK%
|
||||
|
||||
+11
-2
@@ -74,6 +74,12 @@ SOURCES =
|
||||
stl_port
|
||||
text_iarchive
|
||||
text_oarchive
|
||||
polymorphic_text_iarchive
|
||||
polymorphic_text_oarchive
|
||||
polymorphic_binary_iarchive
|
||||
polymorphic_binary_oarchive
|
||||
polymorphic_xml_iarchive
|
||||
polymorphic_xml_oarchive
|
||||
void_cast
|
||||
archive_exception
|
||||
xml_grammar
|
||||
@@ -82,17 +88,20 @@ SOURCES =
|
||||
xml_archive_exception
|
||||
codecvt_null
|
||||
utf8_codecvt_facet
|
||||
singleton
|
||||
;
|
||||
;
|
||||
|
||||
WSOURCES =
|
||||
basic_text_wiprimitive
|
||||
basic_text_woprimitive
|
||||
text_wiarchive
|
||||
text_woarchive
|
||||
polymorphic_text_wiarchive
|
||||
polymorphic_text_woarchive
|
||||
xml_wgrammar
|
||||
xml_wiarchive
|
||||
xml_woarchive
|
||||
polymorphic_xml_wiarchive
|
||||
polymorphic_xml_woarchive
|
||||
;
|
||||
|
||||
lib boost_serialization
|
||||
|
||||
@@ -267,7 +267,7 @@ EXCEPT for one special case.
|
||||
To make this work, the following should be included after the archive
|
||||
class definition.
|
||||
<pre><code>
|
||||
#define BOOST_SERIALIZATION_REGISTER_ARCHIVE(Archive)
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(Archive)
|
||||
</code></pre>
|
||||
Failure to do this will not inhibit the program from compiling, linking
|
||||
and executing properly - except in one case. If an instance of a derived
|
||||
|
||||
@@ -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_) :
|
||||
|
||||
@@ -102,17 +102,29 @@ protected:
|
||||
}
|
||||
void load_override(class_id_type & t){
|
||||
library_version_type lvt = this->get_library_version();
|
||||
/*
|
||||
* library versions:
|
||||
* boost 1.39 -> 5
|
||||
* boost 1.43 -> 7
|
||||
* boost 1.47 -> 9
|
||||
*
|
||||
*
|
||||
* 1) in boost 1.43 and inferior, class_id_type is always a 16bit value, with no check on the library version
|
||||
* --> this means all archives with version v <= 7 are written with a 16bit class_id_type
|
||||
* 2) in boost 1.44 this load_override has disappeared (and thus boost 1.44 is not backward compatible at all !!)
|
||||
* 3) recent boosts reintroduced load_override with a test on the version :
|
||||
* - v > 7 : this->detail_common_iarchive::load_override(t, version)
|
||||
* - v > 6 : 16bit
|
||||
* - other : 32bit
|
||||
* --> which is obviously incorrect, see point 1
|
||||
*
|
||||
* the fix here decodes class_id_type on 16bit for all v <= 7, which seems to be the correct behaviour ...
|
||||
*/
|
||||
if(boost::archive::library_version_type(7) < lvt){
|
||||
this->detail_common_iarchive::load_override(t);
|
||||
}
|
||||
else
|
||||
if(boost::archive::library_version_type(6) < lvt){
|
||||
int_least16_t x=0;
|
||||
* this->This() >> x;
|
||||
t = boost::archive::class_id_type(x);
|
||||
}
|
||||
else{
|
||||
int x=0;
|
||||
int_least16_t x=0;
|
||||
* this->This() >> x;
|
||||
t = boost::archive::class_id_type(x);
|
||||
}
|
||||
|
||||
@@ -63,10 +63,10 @@ public:
|
||||
};
|
||||
|
||||
template<>
|
||||
class BOOST_SYMBOL_VISIBLE codecvt_null<wchar_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,
|
||||
@@ -76,7 +76,7 @@ class BOOST_SYMBOL_VISIBLE codecvt_null<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,
|
||||
@@ -96,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>
|
||||
|
||||
#if BOOST_WORKAROUND(__IBMCPP__, < 1210) \
|
||||
|| ( \
|
||||
defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x590) \
|
||||
)
|
||||
#define DONT_USE_HAS_NEW_OPERATOR 1
|
||||
#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
|
||||
@@ -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 {
|
||||
@@ -122,8 +123,7 @@ private:
|
||||
virtual void destroy(/*const*/ void *address) const {
|
||||
boost::serialization::access::destroy(static_cast<T *>(address));
|
||||
}
|
||||
protected:
|
||||
// protected constructor since it's always created by singleton
|
||||
public:
|
||||
explicit iserializer() :
|
||||
basic_iserializer(
|
||||
boost::serialization::singleton<
|
||||
@@ -132,7 +132,6 @@ protected:
|
||||
>::get_const_instance()
|
||||
)
|
||||
{}
|
||||
public:
|
||||
virtual BOOST_DLLEXPORT void load_object_data(
|
||||
basic_iarchive & ar,
|
||||
void *x,
|
||||
@@ -234,7 +233,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 +242,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() {
|
||||
@@ -306,7 +305,7 @@ private:
|
||||
void * x,
|
||||
const unsigned int file_version
|
||||
) const BOOST_USED;
|
||||
protected:
|
||||
public:
|
||||
// this should alway be a singleton so make the constructor protected
|
||||
pointer_iserializer();
|
||||
~pointer_iserializer();
|
||||
@@ -406,7 +405,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 +483,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 +522,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 +536,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
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <cstddef> // NULL
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
@@ -68,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 {
|
||||
@@ -253,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()
|
||||
@@ -261,6 +264,8 @@ struct save_non_pointer_type {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// adds class information to the archive. This includes
|
||||
// serialization level and class version
|
||||
struct save_conditional {
|
||||
|
||||
@@ -13,27 +13,17 @@
|
||||
#error "wide char i/o not supported on this platform"
|
||||
#endif
|
||||
|
||||
// std::codecvt_utf8 doesn't seem to work for any versions of msvc
|
||||
// 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 }}}
|
||||
|
||||
#if defined(_MSC_VER) || defined(BOOST_NO_CXX11_HDR_CODECVT)
|
||||
// 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
|
||||
#else
|
||||
// use the standard vendor supplied facet
|
||||
#include <codecvt>
|
||||
namespace boost { namespace archive { namespace detail {
|
||||
typedef std::codecvt_utf8<wchar_t> utf8_codecvt_facet;
|
||||
} } }
|
||||
#endif
|
||||
#undef BOOST_UTF8_END_NAMESPACE
|
||||
#undef BOOST_UTF8_DECL
|
||||
#undef BOOST_UTF8_BEGIN_NAMESPACE
|
||||
|
||||
#endif // BOOST_ARCHIVE_DETAIL_UTF8_CODECVT_FACET_HPP
|
||||
|
||||
@@ -47,10 +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()
|
||||
);
|
||||
// note: previously this conditional was a runtime assertion with
|
||||
// BOOST_ASSERT. We've changed it because we've discovered that at
|
||||
// least one platform is not guaranteed to destroy singletons in
|
||||
// reverse order of distruction.
|
||||
if(boost::serialization::singleton<
|
||||
extra_detail::map<Archive>
|
||||
>::is_destroyed())
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace archive {
|
||||
// XML grammar parsing
|
||||
|
||||
template<class CharType>
|
||||
class basic_xml_grammar {
|
||||
class BOOST_SYMBOL_VISIBLE basic_xml_grammar {
|
||||
public:
|
||||
// The following is not necessary according to DR45, but at least
|
||||
// one compiler (Compaq C++ 6.5 in strict_ansi mode) chokes otherwise.
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -103,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),
|
||||
@@ -126,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();
|
||||
@@ -143,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>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
class polymorphic_binary_iarchive :
|
||||
class BOOST_SYMBOL_VISIBLE polymorphic_binary_iarchive :
|
||||
public detail::polymorphic_iarchive_route<binary_iarchive>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -23,13 +23,15 @@
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
typedef detail::polymorphic_oarchive_route<
|
||||
binary_oarchive_impl<
|
||||
binary_oarchive,
|
||||
std::ostream::char_type,
|
||||
std::ostream::traits_type
|
||||
>
|
||||
> polymorphic_binary_oarchive;
|
||||
class BOOST_SYMBOL_VISIBLE polymorphic_binary_oarchive :
|
||||
public detail::polymorphic_oarchive_route<binary_oarchive>
|
||||
{
|
||||
public:
|
||||
polymorphic_binary_oarchive(std::ostream & os, unsigned int flags = 0) :
|
||||
detail::polymorphic_oarchive_route<binary_oarchive>(os, flags)
|
||||
{}
|
||||
~polymorphic_binary_oarchive(){}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
class polymorphic_text_iarchive :
|
||||
class BOOST_SYMBOL_VISIBLE polymorphic_text_iarchive :
|
||||
public detail::polymorphic_iarchive_route<text_iarchive>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -23,9 +23,15 @@
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
typedef detail::polymorphic_oarchive_route<
|
||||
text_oarchive_impl<text_oarchive>
|
||||
> polymorphic_text_oarchive;
|
||||
class BOOST_SYMBOL_VISIBLE polymorphic_text_oarchive :
|
||||
public detail::polymorphic_oarchive_route<text_oarchive>
|
||||
{
|
||||
public:
|
||||
polymorphic_text_oarchive(std::ostream & os, unsigned int flags = 0) :
|
||||
detail::polymorphic_oarchive_route<text_oarchive>(os, flags)
|
||||
{}
|
||||
~polymorphic_text_oarchive(){}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
class polymorphic_text_wiarchive :
|
||||
class BOOST_SYMBOL_VISIBLE polymorphic_text_wiarchive :
|
||||
public detail::polymorphic_iarchive_route<text_wiarchive>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -27,9 +27,15 @@
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
typedef detail::polymorphic_oarchive_route<
|
||||
text_woarchive_impl<text_woarchive>
|
||||
> polymorphic_text_woarchive;
|
||||
class BOOST_SYMBOL_VISIBLE polymorphic_text_woarchive :
|
||||
public detail::polymorphic_oarchive_route<text_woarchive>
|
||||
{
|
||||
public:
|
||||
polymorphic_text_woarchive(std::wostream & os, unsigned int flags = 0) :
|
||||
detail::polymorphic_oarchive_route<text_woarchive>(os, flags)
|
||||
{}
|
||||
~polymorphic_text_woarchive(){}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
class polymorphic_xml_iarchive :
|
||||
class BOOST_SYMBOL_VISIBLE polymorphic_xml_iarchive :
|
||||
public detail::polymorphic_iarchive_route<xml_iarchive>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -23,10 +23,15 @@
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
typedef detail::polymorphic_oarchive_route<
|
||||
xml_oarchive_impl<xml_oarchive>
|
||||
> polymorphic_xml_oarchive;
|
||||
|
||||
class BOOST_SYMBOL_VISIBLE polymorphic_xml_oarchive :
|
||||
public detail::polymorphic_oarchive_route<xml_oarchive>
|
||||
{
|
||||
public:
|
||||
polymorphic_xml_oarchive(std::ostream & os, unsigned int flags = 0) :
|
||||
detail::polymorphic_oarchive_route<xml_oarchive>(os, flags)
|
||||
{}
|
||||
~polymorphic_xml_oarchive(){}
|
||||
};
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
class polymorphic_xml_wiarchive :
|
||||
class BOOST_SYMBOL_VISIBLE polymorphic_xml_wiarchive :
|
||||
public detail::polymorphic_iarchive_route<xml_wiarchive>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// polymorphic_xml_oarchive.hpp
|
||||
// polymorphic_xml_woarchive.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
@@ -27,9 +27,15 @@
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
typedef detail::polymorphic_oarchive_route<
|
||||
xml_woarchive_impl<xml_woarchive>
|
||||
> polymorphic_xml_woarchive;
|
||||
class BOOST_SYMBOL_VISIBLE polymorphic_xml_woarchive :
|
||||
public detail::polymorphic_oarchive_route<xml_woarchive>
|
||||
{
|
||||
public:
|
||||
polymorphic_xml_woarchive(std::wostream & os, unsigned int flags = 0) :
|
||||
detail::polymorphic_oarchive_route<xml_woarchive>(os, flags)
|
||||
{}
|
||||
~polymorphic_xml_woarchive(){}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef BOOST_SERIALIZATION_ARRAY_HPP
|
||||
#define BOOST_SERIALIZATION_ARRAY_HPP
|
||||
#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
|
||||
@@ -30,4 +30,4 @@ void serialize(Archive& ar, boost::array<T,N>& a, const unsigned int /* version
|
||||
} } // end namespace boost::serialization
|
||||
|
||||
|
||||
#endif //BOOST_SERIALIZATION_ARRAY_HPP
|
||||
#endif //BOOST_SERIALIZATION_BOOST_ARRAY_HPP
|
||||
|
||||
@@ -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++);
|
||||
|
||||
@@ -42,8 +42,6 @@
|
||||
|
||||
#include <boost/archive/detail/register_archive.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
namespace detail {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
// Copyright Robert Ramey 2007. Changes made to permit
|
||||
// application throughout the serialization library.
|
||||
//
|
||||
// Copyright Alexander Grund 2018. Corrections to singleton lifetime
|
||||
//
|
||||
// Distributed under 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)
|
||||
@@ -32,15 +34,15 @@
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/serialization/force_include.hpp>
|
||||
#include <boost/serialization/config.hpp>
|
||||
|
||||
#include <boost/archive/detail/auto_link_archive.hpp>
|
||||
#include <boost/serialization/config.hpp>
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
@@ -48,8 +50,8 @@
|
||||
# pragma warning(disable : 4511 4512)
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Provides a dynamically-initialized (singleton) instance of T in a
|
||||
@@ -58,7 +60,7 @@ namespace serialization {
|
||||
// details.
|
||||
//
|
||||
|
||||
// singletons created by this code are guarenteed to be unique
|
||||
// Singletons created by this code are guaranteed to be unique
|
||||
// within the executable or shared library which creates them.
|
||||
// This is sufficient and in fact ideal for the serialization library.
|
||||
// The singleton is created when the module is loaded and destroyed
|
||||
@@ -74,14 +76,22 @@ namespace serialization {
|
||||
// Second, it provides a mechanism to detect when a non-const function
|
||||
// is called after initialization.
|
||||
|
||||
// make a singleton to lock/unlock all singletons for alteration.
|
||||
// Make a singleton to lock/unlock all singletons for alteration.
|
||||
// The intent is that all singletons created/used by this code
|
||||
// are to be initialized before main is called. A test program
|
||||
// can lock all the singletons when main is entereed. This any
|
||||
// attempt to retieve a mutable instances while locked will
|
||||
// generate a assertion if compiled for debug.
|
||||
// can lock all the singletons when main is entered. Thus any
|
||||
// attempt to retrieve a mutable instance while locked will
|
||||
// generate an assertion if compiled for debug.
|
||||
|
||||
// note usage of BOOST_DLLEXPORT. These functions are in danger of
|
||||
// The singleton template can be used in 2 ways:
|
||||
// 1 (Recommended): Publicly inherit your type T from singleton<T>,
|
||||
// make its ctor protected and access it via T::get_const_instance()
|
||||
// 2: Simply access singleton<T> without changing T. Note that this only
|
||||
// provides a global instance accesible by singleton<T>::get_const_instance()
|
||||
// or singleton<T>::get_mutable_instance() to prevent using multiple instances
|
||||
// of T make its ctor protected
|
||||
|
||||
// Note on 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.
|
||||
@@ -91,68 +101,110 @@ class BOOST_SYMBOL_VISIBLE singleton_module :
|
||||
public boost::noncopyable
|
||||
{
|
||||
private:
|
||||
BOOST_DLLEXPORT static bool & get_lock() BOOST_USED;
|
||||
BOOST_DLLEXPORT bool & get_lock() BOOST_USED {
|
||||
static bool lock = false;
|
||||
return lock;
|
||||
}
|
||||
|
||||
public:
|
||||
BOOST_DLLEXPORT static void lock(){
|
||||
BOOST_DLLEXPORT void lock(){
|
||||
get_lock() = true;
|
||||
}
|
||||
BOOST_DLLEXPORT static void unlock(){
|
||||
BOOST_DLLEXPORT void unlock(){
|
||||
get_lock() = false;
|
||||
}
|
||||
BOOST_DLLEXPORT static bool is_locked(){
|
||||
BOOST_DLLEXPORT bool is_locked(){
|
||||
return get_lock();
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class singleton : public singleton_module
|
||||
static inline singleton_module & get_singleton_module(){
|
||||
static singleton_module m;
|
||||
return m;
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
// This is the class actually instantiated and hence the real singleton.
|
||||
// So there will only be one instance of this class. This does not hold
|
||||
// for singleton<T> as a class derived from singleton<T> could be
|
||||
// instantiated multiple times.
|
||||
// It also provides a flag `is_destroyed` which returns true, when the
|
||||
// class was destructed. It is static and hence accesible even after
|
||||
// destruction. This can be used to check, if the singleton is still
|
||||
// accesible e.g. in destructors of other singletons.
|
||||
template<class T>
|
||||
class singleton_wrapper : public T
|
||||
{
|
||||
private:
|
||||
static T & m_instance;
|
||||
// include this to provoke instantiation at pre-execution time
|
||||
static void use(T const *) {}
|
||||
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)
|
||||
static bool & get_is_destroyed(){
|
||||
// Prefer a static function member to avoid LNK1179.
|
||||
// Note: As this is for a singleton (1 instance only) it must be set
|
||||
// never be reset (to false)!
|
||||
static bool is_destroyed_flag = false;
|
||||
return is_destroyed_flag;
|
||||
}
|
||||
public:
|
||||
singleton_wrapper(){
|
||||
BOOST_ASSERT(! is_destroyed());
|
||||
}
|
||||
~singleton_wrapper(){
|
||||
get_is_destroyed() = true;
|
||||
}
|
||||
static bool is_destroyed(){
|
||||
return get_is_destroyed();
|
||||
}
|
||||
};
|
||||
|
||||
} // detail
|
||||
|
||||
template <class T>
|
||||
class singleton {
|
||||
private:
|
||||
static T * m_instance;
|
||||
// include this to provoke instantiation at pre-execution time
|
||||
static void use(T const &) {}
|
||||
static T & get_instance() {
|
||||
BOOST_ASSERT(! is_destroyed());
|
||||
|
||||
// use a wrapper so that types T with protected constructors can be used
|
||||
// Using a static function member avoids LNK1179
|
||||
static detail::singleton_wrapper< T > t;
|
||||
|
||||
// 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);
|
||||
// the sequence of object initialization.
|
||||
// Unfortunately, this triggers detectors of undefine behavior
|
||||
// and reports an error. But I've been unable to find a different
|
||||
// of guarenteeing that the the singleton is created at pre-main time.
|
||||
use(* m_instance);
|
||||
|
||||
return static_cast<T &>(t);
|
||||
}
|
||||
static bool & get_is_destroyed(){
|
||||
static bool is_destroyed;
|
||||
return is_destroyed;
|
||||
}
|
||||
protected:
|
||||
// Do not allow instantiation of a singleton<T>. But we want to allow
|
||||
// `class T: public singleton<T>` so we can't delete this ctor
|
||||
BOOST_DLLEXPORT singleton(){}
|
||||
|
||||
public:
|
||||
BOOST_DLLEXPORT static T & get_mutable_instance(){
|
||||
BOOST_ASSERT(! is_locked());
|
||||
BOOST_ASSERT(! get_singleton_module().is_locked());
|
||||
return get_instance();
|
||||
}
|
||||
BOOST_DLLEXPORT static const T & get_const_instance(){
|
||||
return get_instance();
|
||||
}
|
||||
BOOST_DLLEXPORT static bool is_destroyed(){
|
||||
return get_is_destroyed();
|
||||
}
|
||||
BOOST_DLLEXPORT singleton(){
|
||||
get_is_destroyed() = false;
|
||||
}
|
||||
BOOST_DLLEXPORT ~singleton() {
|
||||
get_is_destroyed() = true;
|
||||
return detail::singleton_wrapper< T >::is_destroyed();
|
||||
}
|
||||
};
|
||||
|
||||
// Assigning the instance reference to a static member forces initialization
|
||||
// at startup time as described in
|
||||
// https://groups.google.com/forum/#!topic/microsoft.public.vc.language/kDVNLnIsfZk
|
||||
template<class T>
|
||||
T & singleton< T >::m_instance = singleton< T >::get_instance();
|
||||
T * singleton< T >::m_instance = & singleton< T >::get_instance();
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#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>
|
||||
@@ -47,7 +48,7 @@ void save( Archive & ar, const STD::valarray<U> &t, const unsigned int /*file_ve
|
||||
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
|
||||
);
|
||||
}
|
||||
@@ -62,7 +63,7 @@ void load( Archive & ar, STD::valarray<U> &t, const unsigned int /*file_version
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
@@ -188,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,7 +125,10 @@ BOOST_SERIALIZATION_DECL void
|
||||
extended_type_info::key_unregister() const{
|
||||
if(NULL == get_key())
|
||||
return;
|
||||
BOOST_ASSERT(! singleton<detail::ktmap>::is_destroyed());
|
||||
// note: it's been discovered that at least one platform is not guaranteed
|
||||
// to destroy singletons reverse order of construction. So we can't
|
||||
// use a runtime assert here. Leave this in a reminder not to do this!
|
||||
// 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,20 +95,22 @@ BOOST_SERIALIZATION_DECL void
|
||||
extended_type_info_typeid_0::type_unregister()
|
||||
{
|
||||
if(NULL != m_ti){
|
||||
BOOST_ASSERT(! singleton<tkmap>::is_destroyed());
|
||||
// note: previously this conditional was a runtime assertion with
|
||||
// BOOST_ASSERT. We've changed it because we've discovered that at
|
||||
// least one platform is not guaranteed to destroy singletons in
|
||||
// reverse order of distruction.
|
||||
// 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;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// polymorphic_binary_iarchive.cpp:
|
||||
|
||||
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#if (defined _MSC_VER) && (_MSC_VER == 1200)
|
||||
# pragma warning (disable : 4786) // too long name, harmless warning
|
||||
#endif
|
||||
|
||||
#define BOOST_ARCHIVE_SOURCE
|
||||
#include <boost/serialization/config.hpp>
|
||||
#include <boost/archive/polymorphic_binary_iarchive.hpp>
|
||||
|
||||
// explicitly instantiate for this type of text stream
|
||||
#include <boost/archive/impl/archive_serializer_map.ipp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
namespace detail {
|
||||
|
||||
template class archive_serializer_map<polymorphic_binary_iarchive>;
|
||||
|
||||
} // detail
|
||||
} // archive
|
||||
} // boost
|
||||
@@ -0,0 +1,30 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// polymorphic_binary_oarchive.cpp:
|
||||
|
||||
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#if (defined _MSC_VER) && (_MSC_VER == 1200)
|
||||
# pragma warning (disable : 4786) // too long name, harmless warning
|
||||
#endif
|
||||
|
||||
#define BOOST_ARCHIVE_SOURCE
|
||||
#include <boost/serialization/config.hpp>
|
||||
#include <boost/archive/polymorphic_binary_oarchive.hpp>
|
||||
|
||||
// explicitly instantiate for this type of text stream
|
||||
#include <boost/archive/impl/archive_serializer_map.ipp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
namespace detail {
|
||||
|
||||
template class detail::archive_serializer_map<polymorphic_binary_oarchive>;
|
||||
|
||||
} // detail
|
||||
} // archive
|
||||
} // boost
|
||||
@@ -0,0 +1,30 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// polymorphic_text_iarchive.cpp:
|
||||
|
||||
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#if (defined _MSC_VER) && (_MSC_VER == 1200)
|
||||
# pragma warning (disable : 4786) // too long name, harmless warning
|
||||
#endif
|
||||
|
||||
#define BOOST_ARCHIVE_SOURCE
|
||||
#include <boost/serialization/config.hpp>
|
||||
#include <boost/archive/polymorphic_text_iarchive.hpp>
|
||||
|
||||
// explicitly instantiate for this type of text stream
|
||||
#include <boost/archive/impl/archive_serializer_map.ipp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
namespace detail {
|
||||
|
||||
template class archive_serializer_map<polymorphic_text_iarchive>;
|
||||
|
||||
} // detail
|
||||
} // archive
|
||||
} // boost
|
||||
@@ -0,0 +1,30 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// polymorphic_text_oarchive.cpp:
|
||||
|
||||
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#if (defined _MSC_VER) && (_MSC_VER == 1200)
|
||||
# pragma warning (disable : 4786) // too long name, harmless warning
|
||||
#endif
|
||||
|
||||
#define BOOST_ARCHIVE_SOURCE
|
||||
#include <boost/serialization/config.hpp>
|
||||
#include <boost/archive/polymorphic_text_oarchive.hpp>
|
||||
|
||||
// explicitly instantiate for this type of text stream
|
||||
#include <boost/archive/impl/archive_serializer_map.ipp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
namespace detail {
|
||||
|
||||
template class detail::archive_serializer_map<polymorphic_text_oarchive>;
|
||||
|
||||
} // detail
|
||||
} // archive
|
||||
} // boost
|
||||
@@ -0,0 +1,30 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// polymorphic_text_wiarchive.cpp:
|
||||
|
||||
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#if (defined _MSC_VER) && (_MSC_VER == 1200)
|
||||
# pragma warning (disable : 4786) // too long name, harmless warning
|
||||
#endif
|
||||
|
||||
#define BOOST_ARCHIVE_SOURCE
|
||||
#include <boost/serialization/config.hpp>
|
||||
#include <boost/archive/polymorphic_text_wiarchive.hpp>
|
||||
|
||||
// explicitly instantiate for this type of text stream
|
||||
#include <boost/archive/impl/archive_serializer_map.ipp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
namespace detail {
|
||||
|
||||
template class archive_serializer_map<polymorphic_text_wiarchive>;
|
||||
|
||||
} // detail
|
||||
} // archive
|
||||
} // boost
|
||||
@@ -0,0 +1,30 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// polymorphic_text_woarchive.cpp:
|
||||
|
||||
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#if (defined _MSC_VER) && (_MSC_VER == 1200)
|
||||
# pragma warning (disable : 4786) // too long name, harmless warning
|
||||
#endif
|
||||
|
||||
#define BOOST_ARCHIVE_SOURCE
|
||||
#include <boost/serialization/config.hpp>
|
||||
#include <boost/archive/polymorphic_text_woarchive.hpp>
|
||||
|
||||
// explicitly instantiate for this type of text stream
|
||||
#include <boost/archive/impl/archive_serializer_map.ipp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
namespace detail {
|
||||
|
||||
template class detail::archive_serializer_map<polymorphic_text_woarchive>;
|
||||
|
||||
} // detail
|
||||
} // archive
|
||||
} // boost
|
||||
@@ -0,0 +1,30 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// polymorphic_xml_iarchive.cpp:
|
||||
|
||||
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#if (defined _MSC_VER) && (_MSC_VER == 1200)
|
||||
# pragma warning (disable : 4786) // too long name, harmless warning
|
||||
#endif
|
||||
|
||||
#define BOOST_ARCHIVE_SOURCE
|
||||
#include <boost/serialization/config.hpp>
|
||||
#include <boost/archive/polymorphic_xml_iarchive.hpp>
|
||||
|
||||
// explicitly instantiate for this type of text stream
|
||||
#include <boost/archive/impl/archive_serializer_map.ipp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
namespace detail {
|
||||
|
||||
template class archive_serializer_map<polymorphic_xml_iarchive>;
|
||||
|
||||
} // detail
|
||||
} // archive
|
||||
} // boost
|
||||
@@ -0,0 +1,30 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// polymorphic_xml_oarchive.cpp:
|
||||
|
||||
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#if (defined _MSC_VER) && (_MSC_VER == 1200)
|
||||
# pragma warning (disable : 4786) // too long name, harmless warning
|
||||
#endif
|
||||
|
||||
#define BOOST_ARCHIVE_SOURCE
|
||||
#include <boost/serialization/config.hpp>
|
||||
#include <boost/archive/polymorphic_xml_oarchive.hpp>
|
||||
|
||||
// explicitly instantiate for this type of text stream
|
||||
#include <boost/archive/impl/archive_serializer_map.ipp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
namespace detail {
|
||||
|
||||
template class detail::archive_serializer_map<polymorphic_xml_oarchive>;
|
||||
|
||||
} // detail
|
||||
} // archive
|
||||
} // boost
|
||||
@@ -0,0 +1,30 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// polymorphic_xml_wiarchive.cpp:
|
||||
|
||||
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#if (defined _MSC_VER) && (_MSC_VER == 1200)
|
||||
# pragma warning (disable : 4786) // too long name, harmless warning
|
||||
#endif
|
||||
|
||||
#define BOOST_ARCHIVE_SOURCE
|
||||
#include <boost/serialization/config.hpp>
|
||||
#include <boost/archive/polymorphic_xml_wiarchive.hpp>
|
||||
|
||||
// explicitly instantiate for this type of text stream
|
||||
#include <boost/archive/impl/archive_serializer_map.ipp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
namespace detail {
|
||||
|
||||
template class archive_serializer_map<polymorphic_xml_wiarchive>;
|
||||
|
||||
} // detail
|
||||
} // archive
|
||||
} // boost
|
||||
@@ -0,0 +1,30 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// polymorphic_xml_woarchive.cpp:
|
||||
|
||||
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#if (defined _MSC_VER) && (_MSC_VER == 1200)
|
||||
# pragma warning (disable : 4786) // too long name, harmless warning
|
||||
#endif
|
||||
|
||||
#define BOOST_ARCHIVE_SOURCE
|
||||
#include <boost/serialization/config.hpp>
|
||||
#include <boost/archive/polymorphic_xml_woarchive.hpp>
|
||||
|
||||
// explicitly instantiate for this type of text stream
|
||||
#include <boost/archive/impl/archive_serializer_map.ipp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
namespace detail {
|
||||
|
||||
template class detail::archive_serializer_map<polymorphic_xml_woarchive>;
|
||||
|
||||
} // detail
|
||||
} // archive
|
||||
} // boost
|
||||
@@ -1,26 +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 {
|
||||
|
||||
BOOST_SERIALIZATION_DECL bool & singleton_module::get_lock(){
|
||||
static bool lock = false;
|
||||
return lock;
|
||||
}
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
+11
-15
@@ -9,18 +9,14 @@
|
||||
#error "wide char i/o not supported on this platform"
|
||||
#endif
|
||||
|
||||
// std::codecvt_utf8 doesn't seem to work for any versions of msvc
|
||||
#if defined(_MSC_VER) \
|
||||
|| defined( BOOST_NO_CXX11_HDR_CODECVT )
|
||||
// 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
|
||||
#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
|
||||
|
||||
+4
-1
@@ -276,7 +276,10 @@ 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());
|
||||
// note: it's been discovered that at least one platform is not guaranteed
|
||||
// to destroy singletons reverse order of construction. So we can't
|
||||
// use a runtime assert here. Leave this in a reminder not to do this!
|
||||
// BOOST_ASSERT(! void_caster_registry::is_destroyed());
|
||||
if(void_caster_registry::is_destroyed())
|
||||
return;
|
||||
|
||||
|
||||
+10
-9
@@ -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);
|
||||
@@ -78,11 +78,12 @@ A::operator std::size_t () const {
|
||||
#pragma warning(disable : 4244) // Disable possible loss of data warning
|
||||
#endif
|
||||
|
||||
A_DLL_DECL
|
||||
A::A() :
|
||||
b(true),
|
||||
#ifndef BOOST_NO_INT64_T
|
||||
f(std::rand() * std::rand()),
|
||||
g(std::rand() * std::rand()),
|
||||
f(static_cast<boost::int64_t>(std::rand()) * static_cast<boost::int64_t>(std::rand())),
|
||||
g(static_cast<boost::uint64_t>(std::rand()) * static_cast<boost::uint64_t>(std::rand())),
|
||||
#endif
|
||||
l(static_cast<enum h>(std::rand() % 3)),
|
||||
m(std::rand()),
|
||||
@@ -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
|
||||
|
||||
+11
-7
@@ -32,13 +32,17 @@ namespace std{
|
||||
#include <boost/serialization/access.hpp>
|
||||
#include <boost/serialization/string.hpp>
|
||||
|
||||
#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")
|
||||
#else
|
||||
#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
|
||||
|
||||
#ifndef A_DLL_DECL
|
||||
#define A_DLL_DECL
|
||||
#endif
|
||||
|
||||
|
||||
+42
-40
@@ -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
|
||||
@@ -24,38 +24,33 @@ import ../util/test :
|
||||
test-bsl-run
|
||||
test-bsl-run_archive
|
||||
test-bsl-run_files
|
||||
test-bsl-run_polymorphic_archive
|
||||
test-bsl-run_polymorphic_files
|
||||
;
|
||||
|
||||
BOOST_ARCHIVE_LIST = [ modules.peek : BOOST_ARCHIVE_LIST ] ;
|
||||
|
||||
lib dll_a_lib
|
||||
|
||||
lib dll_a
|
||||
:
|
||||
dll_a.cpp
|
||||
../build//boost_serialization
|
||||
:
|
||||
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
|
||||
;
|
||||
lib dll_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 dll_polymorphic_derived2
|
||||
:
|
||||
dll_derived2.cpp
|
||||
dll_base_lib
|
||||
../build//boost_serialization
|
||||
:
|
||||
;
|
||||
|
||||
lib dll_polymorphic_derived2_lib
|
||||
:
|
||||
polymorphic_derived2.cpp
|
||||
polymorphic_derived2.cpp
|
||||
dll_polymorphic_base
|
||||
../build//boost_serialization
|
||||
:
|
||||
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
|
||||
;
|
||||
|
||||
test-suite "serialization" :
|
||||
@@ -76,7 +71,6 @@ test-suite "serialization" :
|
||||
[ test-bsl-run_files test_derived_class_ptr : A ]
|
||||
[ test-bsl-run_files test_diamond ]
|
||||
[ test-bsl-run_files test_diamond_complex ]
|
||||
[ test-bsl-run_files test_exported : polymorphic_base ]
|
||||
[ test-bsl-run_files test_forward_list : A : : [ requires cxx11_hdr_forward_list ] ] # BOOST_NO_CXX11_HDR_FORWARD_LIST
|
||||
[ test-bsl-run_files test_forward_list_ptrs : A : : [ requires cxx11_hdr_forward_list ] ] # BOOST_NO_CXX11_HDR_FORWARD_LIST
|
||||
[ test-bsl-run_files test_helper_support ]
|
||||
@@ -90,7 +84,6 @@ test-suite "serialization" :
|
||||
[ test-bsl-run_files test_mi ]
|
||||
[ test-bsl-run_files test_multiple_ptrs : A ]
|
||||
[ test-bsl-run_files test_multiple_inheritance ]
|
||||
[ test-bsl-run_files test_no_rtti : polymorphic_base polymorphic_derived1 ]
|
||||
[ test-bsl-run_files test_non_intrusive ]
|
||||
[ test-bsl-run_files test_non_default_ctor ]
|
||||
[ test-bsl-run_files test_non_default_ctor2 ]
|
||||
@@ -123,9 +116,13 @@ test-suite "serialization" :
|
||||
[ test-bsl-run_files test_shared_ptr ]
|
||||
[ test-bsl-run_files test_shared_ptr_multi_base ]
|
||||
[ test-bsl-run_files test_shared_ptr_132 : : : [ requires auto_ptr ] ] # BOOST_NO_AUTO_PTR
|
||||
[ test-bsl-run_polymorphic_archive test_polymorphic : test_polymorphic_A A ]
|
||||
[ test-bsl-run_polymorphic_archive test_polymorphic2 : test_polymorphic2imp ]
|
||||
[ test-bsl-run_polymorphic_archive test_polymorphic_helper ]
|
||||
|
||||
[ test-bsl-run_polymorphic_files test_dll_exported : polymorphic_derived1 : dll_polymorphic_base dll_polymorphic_derived2 ]
|
||||
[ test-bsl-run_polymorphic_files test_no_rtti : polymorphic_base polymorphic_derived1 polymorphic_derived2 ]
|
||||
[ test-bsl-run_polymorphic_files test_exported : polymorphic_base polymorphic_derived1 polymorphic_derived2 ]
|
||||
[ test-bsl-run_polymorphic_files test_polymorphic : test_polymorphic_A A ]
|
||||
[ test-bsl-run_polymorphic_files test_polymorphic2 : test_polymorphic2imp ]
|
||||
[ test-bsl-run_polymorphic_files test_polymorphic_helper ]
|
||||
|
||||
# should compile
|
||||
[ compile test_strong_typedef.cpp ]
|
||||
@@ -133,13 +130,17 @@ 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_simple : : dll_a : ]
|
||||
# [ test-bsl-run test_dll_plugin : : dll_derived2 : <link>static:<build>no <target-os>linux:<linkflags>-ldl ]
|
||||
|
||||
[ test-bsl-run test_private_ctor ]
|
||||
[ test-bsl-run test_reset_object_address : A ]
|
||||
[ test-bsl-run test_void_cast ]
|
||||
@@ -147,13 +148,12 @@ 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_singleton_inherited ]
|
||||
[ test-bsl-run test_singleton_plain ]
|
||||
|
||||
# [ test-bsl-run test_z ]
|
||||
|
||||
# should fail compilation
|
||||
[ compile-fail test_not_serializable.cpp ]
|
||||
@@ -171,6 +171,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 ]
|
||||
@@ -181,3 +182,4 @@ if ! $(BOOST_ARCHIVE_LIST) {
|
||||
[ compile test_const_pass.cpp ]
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
+5
-8
@@ -26,8 +26,7 @@ A_DLL_DECL void A::serialize(
|
||||
const unsigned int /* file_version */
|
||||
);
|
||||
template
|
||||
A_DLL_DECL
|
||||
void A::serialize(
|
||||
A_DLL_DECL void A::serialize(
|
||||
boost::archive::text_iarchive &ar,
|
||||
const unsigned int /* file_version */
|
||||
);
|
||||
@@ -38,15 +37,13 @@ void A::serialize(
|
||||
#include <boost/archive/polymorphic_iarchive.hpp>
|
||||
|
||||
template
|
||||
A_DLL_DECL
|
||||
void A::serialize(
|
||||
boost::archive::polymorphic_oarchive &ar,
|
||||
A_DLL_DECL void A::serialize(
|
||||
boost::archive::polymorphic_oarchive &,
|
||||
const unsigned int /* file_version */
|
||||
);
|
||||
template
|
||||
A_DLL_DECL
|
||||
void A::serialize(
|
||||
boost::archive::polymorphic_iarchive &ar,
|
||||
A_DLL_DECL void A::serialize(
|
||||
boost::archive::polymorphic_iarchive &,
|
||||
const unsigned int /* file_version */
|
||||
);
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// test_multi_shared_lib.cpp: test that implementation of extented_type_info
|
||||
// works when using multiple shared libraries
|
||||
|
||||
// (C) Copyright 2018 Alexander Grund
|
||||
// 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/text_oarchive.hpp>
|
||||
#include <iostream>
|
||||
|
||||
struct X1{
|
||||
template<class Archive>
|
||||
void serialize(Archive &, const unsigned int){}
|
||||
};
|
||||
|
||||
BOOST_CLASS_IMPLEMENTATION(X1, boost::serialization::object_class_info)
|
||||
|
||||
BOOST_SYMBOL_EXPORT bool f(){
|
||||
boost::archive::text_oarchive(std::cout) & X1();
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// multi_shared2.cpp: library simply using extended_type_info_typeid
|
||||
|
||||
// (C) Copyright 2018 Alexander Grund
|
||||
// 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/text_oarchive.hpp>
|
||||
#include <iostream>
|
||||
|
||||
struct X2{
|
||||
template<class Archive>
|
||||
void serialize(Archive &, const unsigned int){}
|
||||
};
|
||||
|
||||
BOOST_CLASS_IMPLEMENTATION(X2, boost::serialization::object_class_info)
|
||||
|
||||
BOOST_SYMBOL_EXPORT bool g(){
|
||||
boost::archive::text_oarchive(std::cout) & X2();
|
||||
return true;
|
||||
}
|
||||
@@ -10,6 +10,30 @@
|
||||
|
||||
#include <boost/serialization/export.hpp>
|
||||
|
||||
#define POLYMORPHIC_BASE_EXPORT
|
||||
#include "polymorphic_base.hpp"
|
||||
|
||||
template<class Archive>
|
||||
POLYMORPHIC_BASE_DLL_DECL void polymorphic_base::serialize(
|
||||
Archive &ar,
|
||||
const unsigned int /* file_version */
|
||||
){}
|
||||
|
||||
POLYMORPHIC_BASE_DLL_DECL
|
||||
polymorphic_base::polymorphic_base(){}
|
||||
POLYMORPHIC_BASE_DLL_DECL
|
||||
polymorphic_base::~polymorphic_base(){}
|
||||
|
||||
#include <boost/archive/polymorphic_oarchive.hpp>
|
||||
#include <boost/archive/polymorphic_iarchive.hpp>
|
||||
|
||||
template
|
||||
POLYMORPHIC_BASE_DLL_DECL void polymorphic_base::serialize(
|
||||
boost::archive::polymorphic_oarchive &,
|
||||
const unsigned int /* file_version */
|
||||
);
|
||||
template POLYMORPHIC_BASE_DLL_DECL void polymorphic_base::serialize(
|
||||
boost::archive::polymorphic_iarchive &,
|
||||
const unsigned int
|
||||
);
|
||||
BOOST_CLASS_EXPORT_IMPLEMENT(polymorphic_base)
|
||||
|
||||
@@ -24,20 +24,35 @@
|
||||
#include <boost/serialization/type_info_implementation.hpp>
|
||||
#include <boost/serialization/extended_type_info_no_rtti.hpp>
|
||||
|
||||
#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
|
||||
|
||||
#ifndef POLYMORPHIC_BASE_DLL_DECL
|
||||
#define POLYMORPHIC_BASE_DLL_DECL
|
||||
#endif
|
||||
|
||||
class BOOST_SYMBOL_VISIBLE polymorphic_base
|
||||
{
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
void serialize(
|
||||
POLYMORPHIC_BASE_DLL_DECL void serialize(
|
||||
Archive & /* ar */,
|
||||
const unsigned int /* file_version */
|
||||
){}
|
||||
);
|
||||
public:
|
||||
// note that since this class uses the "no_rtti"
|
||||
// extended_type_info implementation, it MUST
|
||||
// implement this function
|
||||
virtual const char * get_key() const = 0;
|
||||
virtual ~polymorphic_base(){};
|
||||
POLYMORPHIC_BASE_DLL_DECL polymorphic_base();
|
||||
POLYMORPHIC_BASE_DLL_DECL virtual ~polymorphic_base();
|
||||
};
|
||||
|
||||
BOOST_SERIALIZATION_ASSUME_ABSTRACT(polymorphic_base)
|
||||
@@ -47,7 +62,7 @@ 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
|
||||
|
||||
@@ -20,4 +20,18 @@ const char * polymorphic_derived1::get_key() const {
|
||||
>::type::get_const_instance().get_key();
|
||||
}
|
||||
|
||||
#include <boost/archive/polymorphic_oarchive.hpp>
|
||||
#include <boost/archive/polymorphic_iarchive.hpp>
|
||||
|
||||
template
|
||||
void polymorphic_derived1::serialize(
|
||||
boost::archive::polymorphic_oarchive &,
|
||||
const unsigned int /* file_version */
|
||||
);
|
||||
template
|
||||
void polymorphic_derived1::serialize(
|
||||
boost::archive::polymorphic_iarchive &,
|
||||
const unsigned int
|
||||
);
|
||||
|
||||
BOOST_CLASS_EXPORT_IMPLEMENT(polymorphic_derived1)
|
||||
|
||||
@@ -12,49 +12,40 @@
|
||||
#include <boost/serialization/extended_type_info_no_rtti.hpp>
|
||||
#include <boost/serialization/export.hpp>
|
||||
|
||||
#define POLYMORPHIC_BASE_IMPORT
|
||||
#include "polymorphic_base.hpp"
|
||||
|
||||
#define POLYMORPHIC_DERIVED2_EXPORT
|
||||
#include "polymorphic_derived2.hpp"
|
||||
|
||||
template<class Archive>
|
||||
void polymorphic_derived2::serialize(
|
||||
Archive &ar,
|
||||
POLYMORPHIC_DERIVED2_DLL_DECL 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
|
||||
const char * polymorphic_derived2::get_key() const {
|
||||
return "polymorphic_derived2";
|
||||
}
|
||||
POLYMORPHIC_DERIVED2_DLL_DECL
|
||||
void polymorphic_derived2::serialize(
|
||||
boost::archive::text_oarchive & ar,
|
||||
const unsigned int version
|
||||
);
|
||||
template
|
||||
polymorphic_derived2::polymorphic_derived2(){}
|
||||
POLYMORPHIC_DERIVED2_DLL_DECL
|
||||
void polymorphic_derived2::serialize(
|
||||
boost::archive::text_iarchive & ar,
|
||||
const unsigned int version
|
||||
);
|
||||
polymorphic_derived2::~polymorphic_derived2(){}
|
||||
|
||||
// instantiate code for polymorphic archives
|
||||
#include <boost/archive/polymorphic_iarchive.hpp>
|
||||
#include <boost/archive/polymorphic_oarchive.hpp>
|
||||
#include <boost/archive/polymorphic_iarchive.hpp>
|
||||
|
||||
template
|
||||
POLYMORPHIC_DERIVED2_DLL_DECL
|
||||
void polymorphic_derived2::serialize(
|
||||
boost::archive::polymorphic_oarchive & ar,
|
||||
const unsigned int version
|
||||
POLYMORPHIC_DERIVED2_DLL_DECL void polymorphic_derived2::serialize(
|
||||
boost::archive::polymorphic_oarchive &,
|
||||
const unsigned int /* file_version */
|
||||
);
|
||||
template
|
||||
POLYMORPHIC_DERIVED2_DLL_DECL
|
||||
void polymorphic_derived2::serialize(
|
||||
boost::archive::polymorphic_iarchive & ar,
|
||||
const unsigned int version
|
||||
POLYMORPHIC_DERIVED2_DLL_DECL void polymorphic_derived2::serialize(
|
||||
boost::archive::polymorphic_iarchive &,
|
||||
const unsigned int
|
||||
);
|
||||
|
||||
// MWerks users can do this to make their code work
|
||||
@@ -62,13 +53,3 @@ BOOST_SERIALIZATION_MWERKS_BASE_AND_DERIVED(polymorphic_base, polymorphic_derive
|
||||
|
||||
// note: export has to be AFTER #includes for all archive classes
|
||||
BOOST_CLASS_EXPORT_IMPLEMENT(polymorphic_derived2)
|
||||
|
||||
#if 0
|
||||
#include <boost/serialization/factory.hpp>
|
||||
BOOST_SERIALIZATION_FACTORY_0(polymorphic_derived2)
|
||||
|
||||
template
|
||||
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,30 +24,36 @@
|
||||
#include <boost/serialization/type_info_implementation.hpp>
|
||||
#include <boost/serialization/extended_type_info_typeid.hpp>
|
||||
|
||||
#include "polymorphic_base.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
|
||||
|
||||
#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")
|
||||
#else
|
||||
#ifndef POLYMORPHIC_DERIVED2_DLL_DECL
|
||||
#define POLYMORPHIC_DERIVED2_DLL_DECL
|
||||
#endif
|
||||
|
||||
class POLYMORPHIC_DERIVED2_DLL_DECL polymorphic_derived2 :
|
||||
#define POLYMORPHIC_BASE_IMPORT
|
||||
#include "polymorphic_base.hpp"
|
||||
|
||||
class BOOST_SYMBOL_VISIBLE polymorphic_derived2 :
|
||||
public polymorphic_base
|
||||
{
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
void serialize(
|
||||
Archive &ar,
|
||||
POLYMORPHIC_DERIVED2_DLL_DECL void serialize(
|
||||
Archive &ar,
|
||||
const unsigned int /* file_version */
|
||||
);
|
||||
virtual const char * get_key() const {
|
||||
return "polymorphic_derived2";
|
||||
}
|
||||
POLYMORPHIC_DERIVED2_DLL_DECL const char * get_key() const;
|
||||
public:
|
||||
POLYMORPHIC_DERIVED2_DLL_DECL polymorphic_derived2();
|
||||
POLYMORPHIC_DERIVED2_DLL_DECL ~polymorphic_derived2();
|
||||
};
|
||||
|
||||
// we use this because we want to assign a key to this type
|
||||
@@ -63,5 +69,5 @@ BOOST_CLASS_TYPE_INFO(
|
||||
boost::serialization::extended_type_info_typeid<polymorphic_derived2>
|
||||
)
|
||||
|
||||
#endif // POLYMORPHIC_DERIVED2_HPP
|
||||
#endif // BOOST_SERIALIZATION_TEST_POLYMORPHIC_DERIVED2_HPP
|
||||
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ int test_std_array(){
|
||||
BOOST_TRY {
|
||||
ia >> boost::serialization::make_nvp("a_array", a_array1);
|
||||
}
|
||||
BOOST_CATCH (boost::archive::archive_exception ae){
|
||||
BOOST_CATCH (boost::archive::archive_exception const& ae){
|
||||
BOOST_CHECK(
|
||||
boost::archive::archive_exception::array_size_too_short
|
||||
== ae.code
|
||||
|
||||
@@ -59,7 +59,7 @@ int test_boost_array(){
|
||||
BOOST_TRY {
|
||||
ia >> boost::serialization::make_nvp("a_array", a_array1);
|
||||
}
|
||||
BOOST_CATCH (boost::archive::archive_exception ae){
|
||||
BOOST_CATCH (boost::archive::archive_exception const& ae){
|
||||
BOOST_CHECK(
|
||||
boost::archive::archive_exception::array_size_too_short
|
||||
== ae.code
|
||||
|
||||
@@ -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;
|
||||
@@ -162,7 +163,7 @@ int test3(){
|
||||
BOOST_TRY {
|
||||
oa << BOOST_SERIALIZATION_NVP(k);
|
||||
}
|
||||
BOOST_CATCH (boost::archive::archive_exception ae){
|
||||
BOOST_CATCH (boost::archive::archive_exception const& ae){
|
||||
exception = ae;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
@@ -181,7 +182,7 @@ int test3(){
|
||||
BOOST_TRY {
|
||||
ia >> BOOST_SERIALIZATION_NVP(k);
|
||||
}
|
||||
BOOST_CATCH (boost::archive::archive_exception ae){
|
||||
BOOST_CATCH (boost::archive::archive_exception const& ae){
|
||||
exception = ae;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
|
||||
@@ -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;
|
||||
|
||||
+22
-32
@@ -35,36 +35,23 @@ namespace std{
|
||||
}
|
||||
#endif
|
||||
|
||||
// for now, only test with simple text archive
|
||||
#define BOOST_ARCHIVE_TEST text_archive.hpp
|
||||
#include <boost/archive/polymorphic_oarchive.hpp>
|
||||
#include <boost/archive/polymorphic_iarchive.hpp>
|
||||
|
||||
#include "test_tools.hpp"
|
||||
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
#include <boost/archive/polymorphic_oarchive.hpp>
|
||||
#include <boost/archive/polymorphic_iarchive.hpp>
|
||||
|
||||
#include <boost/serialization/base_object.hpp>
|
||||
#include <boost/serialization/export.hpp>
|
||||
#include <boost/serialization/access.hpp>
|
||||
|
||||
#define POLYMORPHIC_BASE_IMPORT
|
||||
#include "polymorphic_base.hpp"
|
||||
|
||||
class polymorphic_derived1 : public polymorphic_base
|
||||
{
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
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_derived1";
|
||||
}
|
||||
public:
|
||||
virtual ~polymorphic_derived1(){}
|
||||
};
|
||||
|
||||
BOOST_CLASS_EXPORT(polymorphic_derived1)
|
||||
|
||||
// MWerks users can do this to make their code work
|
||||
BOOST_SERIALIZATION_MWERKS_BASE_AND_DERIVED(polymorphic_base, polymorphic_derived1)
|
||||
#define POLYMORPHIC_DERIVED1_IMPORT
|
||||
#include "polymorphic_derived1.hpp"
|
||||
|
||||
#define POLYMORPHIC_DERIVED2_IMPORT
|
||||
#include "polymorphic_derived2.hpp"
|
||||
@@ -73,7 +60,8 @@ BOOST_SERIALIZATION_MWERKS_BASE_AND_DERIVED(polymorphic_base, polymorphic_derive
|
||||
void save_exported(const char *testfile)
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
test_oarchive oa_implementation(os, TEST_ARCHIVE_FLAGS);
|
||||
boost::archive::polymorphic_oarchive & oa_interface = oa_implementation;
|
||||
|
||||
polymorphic_base *rb1 = new polymorphic_derived1;
|
||||
polymorphic_base *rb2 = new polymorphic_derived2;
|
||||
@@ -81,19 +69,21 @@ void save_exported(const char *testfile)
|
||||
|
||||
// export will permit correct serialization
|
||||
// through a pointer to a base class
|
||||
oa << BOOST_SERIALIZATION_NVP(rb1);
|
||||
oa << BOOST_SERIALIZATION_NVP(rb2);
|
||||
oa << BOOST_SERIALIZATION_NVP(rd21);
|
||||
oa_interface << BOOST_SERIALIZATION_NVP(rb1);
|
||||
oa_interface << BOOST_SERIALIZATION_NVP(rb2);
|
||||
oa_interface << BOOST_SERIALIZATION_NVP(rd21);
|
||||
|
||||
delete rb1;
|
||||
delete rd21;
|
||||
delete rb2;
|
||||
delete rb1;
|
||||
}
|
||||
|
||||
// save exported polymorphic class
|
||||
void load_exported(const char *testfile)
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
test_iarchive ia_implementation(is, TEST_ARCHIVE_FLAGS);
|
||||
boost::archive::polymorphic_iarchive & ia_interface = ia_implementation;
|
||||
|
||||
polymorphic_base *rb1 = NULL;
|
||||
polymorphic_base *rb2 = NULL;
|
||||
@@ -101,7 +91,7 @@ void load_exported(const char *testfile)
|
||||
|
||||
// export will permit correct serialization
|
||||
// through a pointer to a base class
|
||||
ia >> BOOST_SERIALIZATION_NVP(rb1);
|
||||
ia_interface >> BOOST_SERIALIZATION_NVP(rb1);
|
||||
BOOST_CHECK_MESSAGE(
|
||||
boost::serialization::type_info_implementation<polymorphic_derived1>
|
||||
::type::get_const_instance()
|
||||
@@ -110,7 +100,7 @@ void load_exported(const char *testfile)
|
||||
::type::get_const_instance().get_derived_extended_type_info(*rb1),
|
||||
"restored pointer b1 not of correct type"
|
||||
);
|
||||
ia >> BOOST_SERIALIZATION_NVP(rb2);
|
||||
ia_interface >> BOOST_SERIALIZATION_NVP(rb2);
|
||||
BOOST_CHECK_MESSAGE(
|
||||
boost::serialization::type_info_implementation<polymorphic_derived2>
|
||||
::type::get_const_instance()
|
||||
@@ -119,7 +109,7 @@ void load_exported(const char *testfile)
|
||||
::type::get_const_instance().get_derived_extended_type_info(*rb2),
|
||||
"restored pointer b2 not of correct type"
|
||||
);
|
||||
ia >> BOOST_SERIALIZATION_NVP(rd21);
|
||||
ia_interface >> BOOST_SERIALIZATION_NVP(rd21);
|
||||
BOOST_CHECK_MESSAGE(
|
||||
boost::serialization::type_info_implementation<polymorphic_derived2>
|
||||
::type::get_const_instance()
|
||||
@@ -128,9 +118,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;
|
||||
|
||||
|
||||
+21
-54
@@ -19,75 +19,41 @@ namespace std{
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <boost/serialization/type_info_implementation.hpp>
|
||||
#include <boost/serialization/export.hpp>
|
||||
#include <boost/serialization/base_object.hpp>
|
||||
#include <boost/serialization/type_info_implementation.hpp>
|
||||
#include <boost/serialization/extended_type_info_typeid.hpp>
|
||||
|
||||
#include <boost/serialization/force_include.hpp>
|
||||
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
#include "test_tools.hpp"
|
||||
|
||||
#include <boost/archive/polymorphic_oarchive.hpp>
|
||||
#include <boost/archive/polymorphic_iarchive.hpp>
|
||||
|
||||
#define POLYMORPHIC_BASE_IMPORT
|
||||
#include "polymorphic_base.hpp"
|
||||
|
||||
class polymorphic_derived1 :
|
||||
public polymorphic_base
|
||||
{
|
||||
friend class boost::serialization::access;
|
||||
template<class Archive>
|
||||
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_derived1";
|
||||
}
|
||||
public:
|
||||
~polymorphic_derived1(){}
|
||||
};
|
||||
|
||||
BOOST_CLASS_EXPORT(polymorphic_derived1)
|
||||
|
||||
// MWerks users can do this to make their code work
|
||||
BOOST_SERIALIZATION_MWERKS_BASE_AND_DERIVED(polymorphic_base, polymorphic_derived1)
|
||||
#define POLYMORPHIC_DERIVED1_IMPORT
|
||||
#include "polymorphic_derived1.hpp"
|
||||
|
||||
#define POLYMORPHIC_DERIVED2_IMPORT
|
||||
#include "polymorphic_derived2.hpp"
|
||||
|
||||
// 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(
|
||||
test_oarchive & ar,
|
||||
const unsigned int version
|
||||
);
|
||||
template BOOST_SYMBOL_EXPORT void polymorphic_derived2::serialize(
|
||||
test_iarchive & ar,
|
||||
const unsigned int version
|
||||
);
|
||||
|
||||
// save exported polymorphic class
|
||||
void save_exported(const char *testfile)
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
|
||||
test_oarchive oa_implementation(os, TEST_ARCHIVE_FLAGS);
|
||||
boost::archive::polymorphic_oarchive & oa_interface = oa_implementation;
|
||||
|
||||
polymorphic_base *rb1 = new polymorphic_derived1;
|
||||
polymorphic_base *rb2 = new polymorphic_derived2;
|
||||
const polymorphic_base *rb1 = new polymorphic_derived1;
|
||||
const polymorphic_base *rb2 = new polymorphic_derived2;
|
||||
|
||||
// export will permit correct serialization
|
||||
// through a pointer to a base class
|
||||
oa << BOOST_SERIALIZATION_NVP(rb1);
|
||||
oa << BOOST_SERIALIZATION_NVP(rb2);
|
||||
std::cout << "saving polymorphic_derived1 (no_rtti)\n";
|
||||
oa_interface << BOOST_SERIALIZATION_NVP(rb1);
|
||||
|
||||
std::cout << "saving polymorphic_derived2\n";
|
||||
oa_interface << BOOST_SERIALIZATION_NVP(rb2);
|
||||
|
||||
delete rb1;
|
||||
delete rb2;
|
||||
@@ -97,14 +63,15 @@ void save_exported(const char *testfile)
|
||||
void load_exported(const char *testfile)
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
|
||||
test_iarchive ia_implementation(is, TEST_ARCHIVE_FLAGS);
|
||||
boost::archive::polymorphic_iarchive & ia_interface = ia_implementation;
|
||||
|
||||
polymorphic_base *rb1 = NULL;
|
||||
polymorphic_base *rb2 = NULL;
|
||||
|
||||
// export will permit correct serialization
|
||||
// through a pointer to a base class
|
||||
ia >> BOOST_SERIALIZATION_NVP(rb1);
|
||||
ia_interface >> BOOST_SERIALIZATION_NVP(rb1);
|
||||
BOOST_CHECK_MESSAGE(
|
||||
boost::serialization::type_info_implementation<polymorphic_derived1>
|
||||
::type::get_const_instance()
|
||||
@@ -114,7 +81,7 @@ void load_exported(const char *testfile)
|
||||
"restored pointer b1 not of correct type"
|
||||
);
|
||||
|
||||
ia >> BOOST_SERIALIZATION_NVP(rb2);
|
||||
ia_interface >> BOOST_SERIALIZATION_NVP(rb2);
|
||||
BOOST_CHECK_MESSAGE(
|
||||
boost::serialization::type_info_implementation<polymorphic_derived2>
|
||||
::type::get_const_instance()
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ int test_out(){
|
||||
BOOST_TRY {
|
||||
oa << BOOST_SERIALIZATION_NVP(t);
|
||||
}
|
||||
BOOST_CATCH (boost::archive::archive_exception ae){
|
||||
BOOST_CATCH (boost::archive::archive_exception const& ae){
|
||||
BOOST_CHECK(
|
||||
boost::archive::archive_exception::other_exception
|
||||
== ae.code
|
||||
@@ -66,7 +66,7 @@ int test_out(){
|
||||
BOOST_CATCH_END
|
||||
BOOST_CHECK(exception_invoked);
|
||||
}
|
||||
BOOST_CATCH (boost::archive::archive_exception ae){}
|
||||
BOOST_CATCH (boost::archive::archive_exception const& ae){}
|
||||
BOOST_CATCH_END
|
||||
}
|
||||
os.close();
|
||||
@@ -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
|
||||
);
|
||||
@@ -113,7 +113,7 @@ int test_in(){
|
||||
BOOST_TRY {
|
||||
ia >> BOOST_SERIALIZATION_NVP(t1);
|
||||
}
|
||||
BOOST_CATCH (boost::archive::archive_exception ae){
|
||||
BOOST_CATCH (boost::archive::archive_exception const& ae){
|
||||
BOOST_CHECK(
|
||||
boost::archive::archive_exception::other_exception
|
||||
== ae.code
|
||||
@@ -123,7 +123,7 @@ int test_in(){
|
||||
BOOST_CATCH_END
|
||||
BOOST_CHECK(exception_invoked);
|
||||
}
|
||||
BOOST_CATCH (boost::archive::archive_exception ae){}
|
||||
BOOST_CATCH (boost::archive::archive_exception const& ae){}
|
||||
BOOST_CATCH_END
|
||||
}
|
||||
is.close();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// test_multi_shared_lib.cpp: test that implementation of extented_type_info
|
||||
// works when using multiple shared libraries
|
||||
//
|
||||
// This reproduces a crash that occurred when multiple shared libraries were
|
||||
// using Boost.Serialization built statically. That causes core singletons to be
|
||||
// instantiated in each shared library separately. Due to some destruction order
|
||||
// mixup in the context of shared libraries on linux it is possible, that
|
||||
// singletons accessed in destructors of other singletons are already destructed.
|
||||
// Accessing them will then lead to a crash or memory corruption.
|
||||
// For this we need 2 shared libraries, linked against static boost. They need to
|
||||
// instantiate extended_type_info_typeid with different types, either by serializing
|
||||
// 2 types (which will do that internally) or by accessing the singletons directly.
|
||||
|
||||
// (C) Copyright 2018 Alexander Grund
|
||||
// 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/serialization/config.hpp>
|
||||
|
||||
// Both shall instantiate different(!) singletons and return true
|
||||
BOOST_SYMBOL_IMPORT bool f();
|
||||
BOOST_SYMBOL_IMPORT bool g();
|
||||
|
||||
int main(int argc, char**){
|
||||
if(f() && g())
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ int test_native_array(){
|
||||
ia >> boost::serialization::make_nvp("a_array", a_array1);
|
||||
ia >> boost::serialization::make_nvp("b_array", b_array1);
|
||||
}
|
||||
BOOST_CATCH (boost::archive::archive_exception ae){
|
||||
BOOST_CATCH (boost::archive::archive_exception const& ae){
|
||||
BOOST_CHECK(
|
||||
boost::archive::archive_exception::array_size_too_short
|
||||
== ae.code
|
||||
|
||||
+21
-36
@@ -26,59 +26,45 @@ namespace std{
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
|
||||
#include <boost/serialization/type_info_implementation.hpp>
|
||||
#include <boost/serialization/extended_type_info_no_rtti.hpp>
|
||||
#include <boost/serialization/export.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
|
||||
#include "test_tools.hpp"
|
||||
#include <boost/preprocessor/stringize.hpp>
|
||||
#include BOOST_PP_STRINGIZE(BOOST_ARCHIVE_TEST)
|
||||
|
||||
#include <boost/archive/polymorphic_oarchive.hpp>
|
||||
#include <boost/archive/polymorphic_iarchive.hpp>
|
||||
|
||||
#define POLYMORPHIC_BASE_IMPORT
|
||||
#include "polymorphic_base.hpp"
|
||||
|
||||
#include "polymorphic_derived1.hpp"
|
||||
|
||||
#define POLYMORPHIC_DERIVED2_IMPORT
|
||||
#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
|
||||
);
|
||||
template void polymorphic_derived2::serialize(
|
||||
test_iarchive & ar,
|
||||
const unsigned int version
|
||||
);
|
||||
|
||||
// save derived polymorphic class
|
||||
void save_derived(const char *testfile)
|
||||
{
|
||||
test_ostream os(testfile, TEST_STREAM_FLAGS);
|
||||
test_oarchive oa(os);
|
||||
test_oarchive oa_implementation(os, TEST_ARCHIVE_FLAGS);
|
||||
boost::archive::polymorphic_oarchive & oa_interface = oa_implementation;
|
||||
|
||||
polymorphic_derived1 *rd1 = new polymorphic_derived1;
|
||||
polymorphic_derived2 *rd2 = new polymorphic_derived2;
|
||||
|
||||
std::cout << "saving polymorphic_derived1 (no_rtti)\n";
|
||||
oa << BOOST_SERIALIZATION_NVP(rd1);
|
||||
oa_interface << BOOST_SERIALIZATION_NVP(rd1);
|
||||
|
||||
std::cout << "saving polymorphic_derived2\n";
|
||||
oa << BOOST_SERIALIZATION_NVP(rd2);
|
||||
oa_interface << BOOST_SERIALIZATION_NVP(rd2);
|
||||
|
||||
const polymorphic_base *rb1 = rd1;
|
||||
polymorphic_base *rb2 = rd2;
|
||||
std::cout << "saving polymorphic_derived1 (no_rtti) through base (no_rtti)\n";
|
||||
oa << BOOST_SERIALIZATION_NVP(rb1);
|
||||
polymorphic_base *rb2 = rd2;
|
||||
std::cout << "saving polymorphic_derived1 (no_rtti) through base (rtti)\n";
|
||||
oa_interface << BOOST_SERIALIZATION_NVP(rb1);
|
||||
std::cout << "saving polymorphic_derived2 through base\n";
|
||||
oa << BOOST_SERIALIZATION_NVP(rb2);
|
||||
oa_interface << BOOST_SERIALIZATION_NVP(rb2);
|
||||
|
||||
delete rd1;
|
||||
delete rd2;
|
||||
@@ -87,13 +73,14 @@ void save_derived(const char *testfile)
|
||||
void load_derived(const char *testfile)
|
||||
{
|
||||
test_istream is(testfile, TEST_STREAM_FLAGS);
|
||||
test_iarchive ia(is);
|
||||
test_iarchive ia_implementation(is, TEST_ARCHIVE_FLAGS);
|
||||
boost::archive::polymorphic_iarchive & ia_interface = ia_implementation;
|
||||
|
||||
polymorphic_derived1 *rd1 = NULL;
|
||||
polymorphic_derived2 *rd2 = NULL;
|
||||
|
||||
std::cout << "loading polymorphic_derived1 (no_rtti)\n";
|
||||
ia >> BOOST_SERIALIZATION_NVP(rd1);
|
||||
ia_interface >> BOOST_SERIALIZATION_NVP(rd1);
|
||||
BOOST_CHECK_MESSAGE(
|
||||
boost::serialization::type_info_implementation<
|
||||
polymorphic_derived1
|
||||
@@ -107,7 +94,7 @@ void load_derived(const char *testfile)
|
||||
);
|
||||
|
||||
std::cout << "loading polymorphic_derived2\n";
|
||||
ia >> BOOST_SERIALIZATION_NVP(rd2);
|
||||
ia_interface >> BOOST_SERIALIZATION_NVP(rd2);
|
||||
BOOST_CHECK_MESSAGE(
|
||||
boost::serialization::type_info_implementation<
|
||||
polymorphic_derived2
|
||||
@@ -126,7 +113,7 @@ void load_derived(const char *testfile)
|
||||
// effect. Hence, instances can now be correctly serialized through
|
||||
// a base class pointer.
|
||||
std::cout << "loading polymorphic_derived1 (no_rtti) through base (no_rtti)\n";
|
||||
ia >> BOOST_SERIALIZATION_NVP(rb1);
|
||||
ia_interface >> BOOST_SERIALIZATION_NVP(rb1);
|
||||
|
||||
BOOST_CHECK_MESSAGE(
|
||||
rb1 == dynamic_cast<polymorphic_base *>(rd1),
|
||||
@@ -145,7 +132,7 @@ void load_derived(const char *testfile)
|
||||
"restored pointer b1 not of correct type"
|
||||
);
|
||||
std::cout << "loading polymorphic_derived2 through base (no_rtti)\n";
|
||||
ia >> BOOST_SERIALIZATION_NVP(rb2);
|
||||
ia_interface >> BOOST_SERIALIZATION_NVP(rb2);
|
||||
|
||||
BOOST_CHECK_MESSAGE(
|
||||
rb2 == dynamic_cast<polymorphic_base *>(rd2),
|
||||
@@ -170,12 +157,10 @@ int
|
||||
test_main( int /* argc */, char* /* argv */[] )
|
||||
{
|
||||
const char * testfile = boost::archive::tmpnam(NULL);
|
||||
|
||||
BOOST_REQUIRE(NULL != testfile);
|
||||
|
||||
save_derived(testfile);
|
||||
load_derived(testfile);
|
||||
|
||||
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,81 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// test_singleton_inherited.cpp:
|
||||
// Test the singleton class for a "inherited" singleton (used as Foo:public singleton<Foo>)
|
||||
// This can be uses as singleton<Foo>::get_const_instance() OR Foo::get_const_instance()
|
||||
//
|
||||
// - is_destroyed returns false when singleton is active or uninitialized
|
||||
// - is_destroyed returns true when singleton is destructed
|
||||
// - the singleton is eventually destructed (no memory leak)
|
||||
|
||||
// (C) Copyright 2018 Alexander Grund
|
||||
// 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 "test_tools.hpp"
|
||||
#include <boost/serialization/singleton.hpp>
|
||||
#include <boost/preprocessor/stringize.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
// Can't use BOOST_TEST because:
|
||||
// a) destructors are called after program exit
|
||||
// b) This is intended to be used by shared libraries too which would then need their own report_errors call
|
||||
// We halso have to disable the Wterminate warning as we call this from dtors
|
||||
// C++ will terminate the program in such cases which is OK here
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wterminate"
|
||||
#define THROW_ON_FALSE(cond) if(!(cond)) throw std::runtime_error(__FILE__ "(" BOOST_PP_STRINGIZE(__LINE__) ") Assertion failed: " #cond)
|
||||
|
||||
// Enum to designate the state of the singletonized instances
|
||||
enum ConstructionState{CS_UNINIT, CS_INIT, CS_DESTROYED};
|
||||
|
||||
// We need another singleton to check for the destruction of the singletons at program exit
|
||||
// We don't need all the magic for shared library anti-optimization and can keep it very simple
|
||||
struct controller{
|
||||
static controller& getInstance(){
|
||||
static controller instance;
|
||||
return instance;
|
||||
}
|
||||
ConstructionState state;
|
||||
private:
|
||||
controller() {
|
||||
state = CS_UNINIT;
|
||||
}
|
||||
~controller();
|
||||
};
|
||||
|
||||
// A simple class that sets its construction state in the controller singleton
|
||||
struct Foo: boost::serialization::singleton<Foo>{
|
||||
Foo(): i(42) {
|
||||
// access controller singleton. Therefore controller will be constructed before this
|
||||
THROW_ON_FALSE(controller::getInstance().state == CS_UNINIT);
|
||||
controller::getInstance().state = CS_INIT;
|
||||
}
|
||||
~Foo() {
|
||||
// Because controller is constructed before this, it will be destructed AFTER this. Hence controller is still valid
|
||||
THROW_ON_FALSE(controller::getInstance().state == CS_INIT);
|
||||
controller::getInstance().state = CS_DESTROYED;
|
||||
}
|
||||
// Volatile to prevent compiler optimization from removing this
|
||||
volatile int i;
|
||||
};
|
||||
|
||||
controller::~controller() {
|
||||
// If this fails, the singletons were not freed and memory is leaked
|
||||
THROW_ON_FALSE(state == CS_DESTROYED);
|
||||
// If this fails, then the destroyed flag is not set and one may use a deleted instance if relying on this flag
|
||||
THROW_ON_FALSE(boost::serialization::singleton<Foo>::is_destroyed());
|
||||
THROW_ON_FALSE(Foo::is_destroyed());
|
||||
}
|
||||
|
||||
int
|
||||
test_main( int /* argc */, char* /* argv */[] )
|
||||
{
|
||||
// Check if the singleton is alive and use it
|
||||
BOOST_CHECK(!boost::serialization::singleton<Foo>::is_destroyed());
|
||||
BOOST_CHECK(!Foo::is_destroyed());
|
||||
|
||||
BOOST_CHECK(boost::serialization::singleton<Foo>::get_const_instance().i == 42);
|
||||
BOOST_CHECK(Foo::get_const_instance().i == 42);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// test_singleton_plain.cpp:
|
||||
// Test the singleton class for a "plain" singleton (used as singleton<Foo>)
|
||||
//
|
||||
// - is_destroyed returns false when singleton is active or uninitialized
|
||||
// - is_destroyed returns true when singleton is destructed
|
||||
// - the singleton is eventually destructed (no memory leak)
|
||||
|
||||
// (C) Copyright 2018 Alexander Grund
|
||||
// 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 "test_tools.hpp"
|
||||
#include <boost/serialization/singleton.hpp>
|
||||
#include <boost/preprocessor/stringize.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
// Can't use BOOST_TEST because:
|
||||
// a) destructors are called after program exit
|
||||
// b) This is intended to be used by shared libraries too which would then need their own report_errors call
|
||||
// We halso have to disable the Wterminate warning as we call this from dtors
|
||||
// C++ will terminate the program in such cases which is OK here
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wterminate"
|
||||
#define THROW_ON_FALSE(cond) if(!(cond)) throw std::runtime_error(__FILE__ "(" BOOST_PP_STRINGIZE(__LINE__) ") Assertion failed: " #cond)
|
||||
|
||||
// Enum to designate the state of the singletonized instances
|
||||
enum ConstructionState{CS_UNINIT, CS_INIT, CS_DESTROYED};
|
||||
|
||||
// We need another singleton to check for the destruction of the singletons at program exit
|
||||
// We don't need all the magic for shared library anti-optimization and can keep it very simple
|
||||
struct controller{
|
||||
static controller& getInstance(){
|
||||
static controller instance;
|
||||
return instance;
|
||||
}
|
||||
ConstructionState state;
|
||||
private:
|
||||
controller() {
|
||||
state = CS_UNINIT;
|
||||
}
|
||||
~controller();
|
||||
};
|
||||
|
||||
// A simple class that sets its construction state in the controller singleton
|
||||
struct Foo{
|
||||
Foo(): i(42) {
|
||||
// access controller singleton. Therefore controller will be constructed before this
|
||||
THROW_ON_FALSE(controller::getInstance().state == CS_UNINIT);
|
||||
controller::getInstance().state = CS_INIT;
|
||||
}
|
||||
~Foo() {
|
||||
// Because controller is constructed before this, it will be destructed AFTER this. Hence controller is still valid
|
||||
THROW_ON_FALSE(controller::getInstance().state == CS_INIT);
|
||||
controller::getInstance().state = CS_DESTROYED;
|
||||
}
|
||||
// Volatile to prevent compiler optimization from removing this
|
||||
volatile int i;
|
||||
};
|
||||
|
||||
controller::~controller() {
|
||||
// If this fails, the singletons were not freed and memory is leaked
|
||||
THROW_ON_FALSE(state == CS_DESTROYED);
|
||||
// If this fails, then the destroyed flag is not set and one may use a deleted instance if relying on this flag
|
||||
THROW_ON_FALSE(boost::serialization::singleton<Foo>::is_destroyed());
|
||||
}
|
||||
|
||||
int
|
||||
test_main( int /* argc */, char* /* argv */[] )
|
||||
{
|
||||
// Check if the singleton is alive and use it
|
||||
BOOST_CHECK(!boost::serialization::singleton<Foo>::is_destroyed());
|
||||
|
||||
BOOST_CHECK(boost::serialization::singleton<Foo>::get_const_instance().i == 42);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+8
-2
@@ -193,7 +193,7 @@ int test_main(int argc, char * argv[]);
|
||||
|
||||
int
|
||||
main(int argc, char * argv[]){
|
||||
boost::serialization::singleton_module::lock();
|
||||
boost::serialization::get_singleton_module().lock();
|
||||
|
||||
int retval = 1;
|
||||
BOOST_TRY{
|
||||
@@ -209,7 +209,7 @@ main(int argc, char * argv[]){
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
|
||||
boost::serialization::singleton_module::unlock();
|
||||
boost::serialization::get_singleton_module().unlock();
|
||||
|
||||
int error_count = boost::report_errors();
|
||||
if(error_count > 0)
|
||||
@@ -225,6 +225,12 @@ main(int argc, char * argv[]){
|
||||
#include "binary_archive.hpp"
|
||||
#include "xml_archive.hpp"
|
||||
#include "xml_warchive.hpp"
|
||||
|
||||
#include "polymorphic_text_archive.hpp"
|
||||
#include "polymorphic_text_warchive.hpp"
|
||||
#include "polymorphic_binary_archive.hpp"
|
||||
#include "polymorphic_xml_archive.hpp"
|
||||
#include "polymorphic_xml_warchive.hpp"
|
||||
*/
|
||||
|
||||
/////////////////////////////////////////////
|
||||
|
||||
@@ -85,7 +85,7 @@ void save_unregistered1(const char *testfile)
|
||||
BOOST_TRY {
|
||||
oa << BOOST_SERIALIZATION_NVP(rb1);
|
||||
}
|
||||
BOOST_CATCH(boost::archive::archive_exception aex){
|
||||
BOOST_CATCH(boost::archive::archive_exception const& aex){
|
||||
except = true;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
@@ -112,7 +112,7 @@ void load_unregistered1(const char *testfile)
|
||||
BOOST_TRY {
|
||||
ia >> BOOST_SERIALIZATION_NVP(rb1);
|
||||
}
|
||||
BOOST_CATCH(boost::archive::archive_exception aex){
|
||||
BOOST_CATCH(boost::archive::archive_exception const& aex){
|
||||
except = true;
|
||||
BOOST_CHECK_MESSAGE(
|
||||
NULL == rb1,
|
||||
@@ -140,7 +140,7 @@ void save_unregistered2(const char *testfile)
|
||||
BOOST_TRY {
|
||||
oa << BOOST_SERIALIZATION_NVP(rd1);
|
||||
}
|
||||
BOOST_CATCH(boost::archive::archive_exception aex){
|
||||
BOOST_CATCH(boost::archive::archive_exception const& aex){
|
||||
except = true;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
@@ -166,7 +166,7 @@ void load_unregistered2(const char *testfile)
|
||||
BOOST_TRY {
|
||||
ia >> BOOST_SERIALIZATION_NVP(rd1);
|
||||
}
|
||||
BOOST_CATCH(boost::archive::archive_exception aex){
|
||||
BOOST_CATCH(boost::archive::archive_exception const& aex){
|
||||
except = true;
|
||||
BOOST_CHECK_MESSAGE(
|
||||
NULL == rd1,
|
||||
@@ -279,7 +279,7 @@ void load_unregistered_pointer(const char *testfile)
|
||||
BOOST_TRY {
|
||||
ia & BOOST_SERIALIZATION_NVP(instance1) & BOOST_SERIALIZATION_NVP(pointer2);
|
||||
}
|
||||
BOOST_CATCH(boost::archive::archive_exception aex){
|
||||
BOOST_CATCH(boost::archive::archive_exception const& aex){
|
||||
except = true;
|
||||
BOOST_CHECK_MESSAGE(
|
||||
std::strcmp(aex.what(), "unregistered class") == 0,
|
||||
|
||||
+149
-19
@@ -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;
|
||||
@@ -135,7 +135,7 @@ void do_bad_read()
|
||||
bool exception_invoked = false;
|
||||
BOOST_TRY {
|
||||
ia >> BOOST_SERIALIZATION_NVP(little_variant);
|
||||
} BOOST_CATCH (boost::archive::archive_exception e) {
|
||||
} BOOST_CATCH (boost::archive::archive_exception const& e) {
|
||||
BOOST_CHECK(boost::archive::archive_exception::unsupported_version == e.code);
|
||||
exception_invoked = true;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
+105
-1
@@ -555,7 +555,8 @@ int main()
|
||||
assert(base64 == output);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
#elif 0
|
||||
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
|
||||
@@ -597,4 +598,107 @@ int main()
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif 0
|
||||
#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;
|
||||
}
|
||||
|
||||
#include <boost/archive/xml_oarchive.hpp>
|
||||
#include <boost/archive/xml_iarchive.hpp>
|
||||
#include <boost/archive/detail/archive_serializer_map.hpp>
|
||||
#include <boost/archive/impl/archive_serializer_map.ipp>
|
||||
#include <boost/archive/impl/basic_xml_iarchive.ipp>
|
||||
#include <boost/archive/impl/xml_iarchive_impl.ipp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <limits>
|
||||
#include <fstream>
|
||||
|
||||
class xml_iarchive_nan :
|
||||
public boost::archive::xml_iarchive_impl<xml_iarchive_nan>
|
||||
{
|
||||
protected:
|
||||
friend class boost::archive::detail::interface_iarchive<xml_iarchive_nan>;
|
||||
friend class boost::archive::detail::common_iarchive<xml_iarchive_nan>;
|
||||
friend class boost::archive::basic_xml_iarchive<xml_iarchive_nan>;
|
||||
friend class boost::archive::load_access;
|
||||
|
||||
using boost::archive::xml_iarchive_impl<xml_iarchive_nan>::load;
|
||||
void load(double & t)
|
||||
{
|
||||
char c='0';
|
||||
if(!is.fail())
|
||||
{
|
||||
c=is.peek();
|
||||
if(c!='n')
|
||||
{
|
||||
boost::archive::xml_iarchive_impl<xml_iarchive_nan>::load(t);
|
||||
}
|
||||
else
|
||||
{
|
||||
char c1='0',c2='0';
|
||||
is.get(c).get(c1).get(c2);
|
||||
if(is.fail()||(!((c=='n')&&(c1=='a')&&(c2=='n'))))
|
||||
boost::serialization::throw_exception(
|
||||
boost::archive::archive_exception(
|
||||
boost::archive::archive_exception::input_stream_error));
|
||||
else
|
||||
t=std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
}
|
||||
else
|
||||
boost::serialization::throw_exception(
|
||||
boost::archive::archive_exception(boost::archive::archive_exception::input_stream_error));
|
||||
}
|
||||
|
||||
public:
|
||||
xml_iarchive_nan(std::istream & is, unsigned int flags = 0) :
|
||||
boost::archive::xml_iarchive_impl<xml_iarchive_nan>(is, flags)
|
||||
{}
|
||||
~xml_iarchive_nan(){};
|
||||
};
|
||||
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(xml_iarchive_nan)
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace archive
|
||||
{
|
||||
template class detail::archive_serializer_map<xml_iarchive_nan>;
|
||||
template class detail::interface_iarchive<xml_iarchive_nan>;
|
||||
template class detail::common_iarchive<xml_iarchive_nan>;
|
||||
template class basic_xml_iarchive<xml_iarchive_nan>;
|
||||
template class xml_iarchive_impl<xml_iarchive_nan>;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
double value=0.0;
|
||||
std::ifstream ifile("./somefile.xml");
|
||||
xml_iarchive_nan ia(ifile);
|
||||
ia>>BOOST_SERIALIZATION_NVP(value);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+30
-18
@@ -10,6 +10,9 @@
|
||||
# boost test, as well as the performance test and comprehensive
|
||||
# tests.
|
||||
|
||||
# import rules for testing conditional on config file variables
|
||||
import ../../config/checks/config : requires ;
|
||||
|
||||
BOOST_ARCHIVE_LIST = [ modules.peek : BOOST_ARCHIVE_LIST ] ;
|
||||
|
||||
# these are used to shorten testing while in development. It permits
|
||||
@@ -26,12 +29,13 @@ if ! $(BOOST_ARCHIVE_LIST) {
|
||||
BOOST_SERIALIZATION_TEST = true ;
|
||||
}
|
||||
|
||||
rule run-template ( test-name : sources * : requirements * ) {
|
||||
rule run-template ( test-name : sources * : files * : requirements * ) {
|
||||
return [
|
||||
run
|
||||
$(sources)
|
||||
: # command
|
||||
: # input files
|
||||
: #input files
|
||||
$(files)
|
||||
: # requirements
|
||||
# toolset warnings
|
||||
<toolset>borland:<cxxflags>"-w-8080 -w-8071 -w-8057 -w-8062 -w-8008 -w-0018 -w-8066"
|
||||
@@ -49,7 +53,6 @@ rule run-template ( test-name : sources * : requirements * ) {
|
||||
<toolset>clang:<variant>debug:<cxxflags>"-fsanitize=memory"
|
||||
# toolset optimizations
|
||||
<toolset>gcc:<cxxflags>"-ftemplate-depth-255"
|
||||
<toolset>qcc:<cxxflags>"-ftemplate-depth-255"
|
||||
<toolset>clang:<cxxflags>"-ftemplate-depth-255"
|
||||
<toolset>darwin:<cxxflags>"-ftemplate-depth-255"
|
||||
<toolset>msvc:<cxxflags>"-Gy"
|
||||
@@ -74,7 +77,7 @@ rule dependency-save-test ( test )
|
||||
}
|
||||
|
||||
# each of the following tests is run with each type of archive
|
||||
rule run-invoke ( test-name : sources * : requirements * )
|
||||
rule run-invoke ( test-name : sources * : files * : requirements * )
|
||||
{
|
||||
local save-test = [ dependency-save-test $(test-name) ] ;
|
||||
|
||||
@@ -84,6 +87,7 @@ rule run-invoke ( test-name : sources * : requirements * )
|
||||
: # sources
|
||||
$(sources)
|
||||
../build//boost_serialization
|
||||
: # input files
|
||||
: # requirements
|
||||
$(requirements)
|
||||
<define>BOOST_LIB_DIAGNOSTIC=1
|
||||
@@ -93,7 +97,7 @@ rule run-invoke ( test-name : sources * : requirements * )
|
||||
}
|
||||
|
||||
# each of the following tests is run with each type of archive
|
||||
rule run-winvoke ( test-name : sources * : requirements * )
|
||||
rule run-winvoke ( test-name : sources * : files * : requirements * )
|
||||
{
|
||||
local save-test = [ dependency-save-test $(test-name) ] ;
|
||||
|
||||
@@ -104,13 +108,14 @@ rule run-winvoke ( test-name : sources * : requirements * )
|
||||
$(sources)
|
||||
../build//boost_serialization
|
||||
../build//boost_wserialization
|
||||
: # input files
|
||||
: # requirements
|
||||
$(requirements)
|
||||
<define>BOOST_LIB_DIAGNOSTIC=1
|
||||
# both stlport and msvc6 define iswspace
|
||||
<toolset>msvc,<stdlib>stlport:<linkflags>"-force:multiple"
|
||||
<dependency>$(save-test)
|
||||
<dependency>../../config/test/all//BOOST_NO_STD_WSTREAMBUF
|
||||
[ requires std_wstreambuf ]
|
||||
] ;
|
||||
return $(tests) ;
|
||||
}
|
||||
@@ -123,7 +128,8 @@ rule test-bsl-run-no-lib ( test-name : sources * : requirements * )
|
||||
run-template $(test-name)
|
||||
: # sources
|
||||
$(test-name).cpp $(sources).cpp
|
||||
:
|
||||
: # input files
|
||||
: # requirements
|
||||
$(requirements)
|
||||
] ;
|
||||
return $(tests) ;
|
||||
@@ -137,7 +143,8 @@ rule test-bsl-run ( test-name : sources * : libs * : requirements * )
|
||||
run-invoke $(test-name)
|
||||
: # sources
|
||||
$(test-name).cpp $(sources).cpp $(libs)
|
||||
:
|
||||
: # input files
|
||||
: # requirements
|
||||
$(requirements)
|
||||
] ;
|
||||
return $(tests) ;
|
||||
@@ -149,18 +156,20 @@ rule test-bsl-run_archive ( test-name : archive-name : sources * : libs * : requ
|
||||
case "*_warchive" :
|
||||
tests += [
|
||||
run-winvoke $(test-name)_$(archive-name)
|
||||
:
|
||||
: # sources
|
||||
$(sources).cpp $(libs)
|
||||
:
|
||||
: # input files
|
||||
: # requirements
|
||||
<define>BOOST_ARCHIVE_TEST=$(archive-name).hpp
|
||||
$(requirements)
|
||||
] ;
|
||||
case "*" :
|
||||
tests += [
|
||||
run-invoke $(test-name)_$(archive-name)
|
||||
:
|
||||
: # sources
|
||||
$(sources).cpp $(libs)
|
||||
:
|
||||
: # input files
|
||||
: # requirements
|
||||
<define>BOOST_ARCHIVE_TEST=$(archive-name).hpp
|
||||
$(requirements)
|
||||
] ;
|
||||
@@ -175,20 +184,23 @@ rule test-bsl-run_files ( test-name : sources * : libs * : requirements * ) {
|
||||
test-bsl-run_archive $(test-name)
|
||||
: $(defn:LB)
|
||||
: $(test-name) $(sources)
|
||||
: $(libs)
|
||||
: $(requirements)
|
||||
: $(libs)
|
||||
: $(requirements)
|
||||
] ;
|
||||
}
|
||||
return $(tests) ;
|
||||
}
|
||||
|
||||
rule test-bsl-run_polymorphic_archive ( test-name : sources * : requirements * ) {
|
||||
rule test-bsl-run_polymorphic_files ( test-name : sources * : libs * : requirements * ) {
|
||||
local tests ;
|
||||
for local defn in $(BOOST_ARCHIVE_LIST) {
|
||||
ECHO polymorphic_$(defn:LB) ;
|
||||
tests += [
|
||||
test-bsl-run_archive $(test-name)
|
||||
: polymorphic_$(defn:LB)
|
||||
: $(test-name) $(sources) $(requirements)
|
||||
test-bsl-run_archive $(test-name)
|
||||
: polymorphic_$(defn:LB)
|
||||
: $(test-name) $(sources)
|
||||
: $(libs)
|
||||
: $(requirements)
|
||||
] ;
|
||||
}
|
||||
return $(tests) ;
|
||||
|
||||
Reference in New Issue
Block a user