Compare commits

...

151 Commits

Author SHA1 Message Date
Peter Dimov 9bfcdb2106 Remove explicit check for <forward_list> 2016-11-10 14:44:08 +02:00
Peter Dimov 06fe1b7154 Enumerate dependencies explicitly in .travis.yml 2016-11-09 04:17:42 +02:00
Peter Dimov e653bfe110 Add .travis.yml 2016-11-08 23:03:20 +02:00
Robert Ramey 682c371e11 corrections to forward_list 2016-11-07 12:03:11 -08:00
Robert Ramey 5b47212c01 improve collection serialization with boost::move 2016-11-06 17:22:35 -08:00
Robert Ramey f09c9b197e correction to optional<T> serialization 2016-11-06 15:01:33 -08:00
Robert Ramey 3bc713367e eliminated binary_function from tests to conform to C++17 2016-11-05 15:18:29 -07:00
Robert Ramey 7f801c3d85 remove auto linking from shared_ptr_132 2016-11-05 11:01:30 -07:00
Robert Ramey 3e0f302eee fix error in forward_list serialization 2016-11-04 12:43:00 -07:00
Robert Ramey 19e2ef234b fixed serialization of optional.hpp to prevent it from calling load_construct ... 2016-11-04 12:28:03 -07:00
Robert Ramey a1ffe9b19b Removed emplace in array serialization. I concluded that it didn't do what I hoped it would and couldn't do so without changing the library API which I was reluctant to so. Changing this use more traditional reference copying functions should have no impact on performance but should improve portability to other compilers such as Intel. 2016-11-02 15:32:10 -07:00
Robert Ramey c90e97eb1e adjustment in array serialization hoping to pass intel tests 2016-11-02 14:32:37 -07:00
Robert Ramey fe8b390588 adjustments to tests of <forward_list> 2016-11-02 11:03:20 -07:00
Robert Ramey 8e26bc59db fixed GCC seg fault problem 2016-10-30 20:56:03 -07:00
Robert Ramey 9a2c1f11ab blackout making serialization source dependent on archive source 2016-07-23 14:00:04 -07:00
Robert Ramey df38b48016 after carefully checking with the master - making changes to address compilation on gcc 2016-07-05 11:02:40 -07:00
Robert Ramey 7c97ddd99e update jam files 2016-07-03 11:28:32 -07:00
Robert Ramey d1b5c47e16 another attempt to make visibility work 2016-06-25 14:06:17 -07:00
Robert Ramey 3765166f4b altered visibility attributes 2016-06-25 08:21:02 -07:00
Robert Ramey 03865e70cb correct test_strong_type
back out breaking change for gcc i/o
2016-06-03 22:28:50 -07:00
Robert Ramey 0458a89fc3 adjustments to strong type test 2016-05-29 13:33:49 -07:00
Robert Ramey 49f84d7d7a Merge commit '1bfecdfc82b9491b370c2157af4f5afcb05a44dc' into develop
# Conflicts:
#	include/boost/serialization/strong_typedef.hpp
2016-05-29 10:44:57 -07:00
Robert Ramey 5203ecdd65 strong typedef changes 2016-05-29 10:42:20 -07:00
Robert Ramey 1bfecdfc82 Merge pull request #40 from praetorian20/noexcept_strong_typedef
`noexcept` specifications for `BOOST_STRONG_TYPEDEF`
2016-05-29 10:26:27 -07:00
Robert Ramey e9ed873275 reverse commit suspected of breaking all gcc tests on develop branch 2016-05-07 18:50:49 -07:00
Ashish Sadanandan e32c5c5e28 noexcept specifications for BOOST_STRONG_TYPEDEF
`BOOST_STRONG_TYPEDEF` now detects whether the type being wrapped is
nothrow default/copy constructible and nothrow assignable. The wrapped
type is given its own `noexcept` specifications accordingly.
2016-05-04 00:12:51 -06:00
Robert Ramey e15ca7257f attempt to remove test_utf8_codecvt
updated jam files accordingly
2016-05-02 10:30:50 -07:00
Robert Ramey 8f7b3be1d2 made headers stand alone 2016-04-24 22:25:12 -07:00
Robert Ramey c545c1fa60 test moved to boost/detail 2016-04-24 17:26:03 -07:00
Robert Ramey 3eb2bda80b correction in trailer of xml archives 2016-04-21 12:32:14 -07:00
Robert Ramey 42b5b6859b added missing header 2016-04-18 21:40:00 -07:00
Robert Ramey fc9d311df9 changes to address some test failures 2016-04-15 12:53:16 -07:00
Robert Ramey 69ecae6919 cleaned up commented out code related to new operators 2016-03-29 18:38:34 -07:00
Robert Ramey b65e29cb5f upload newly created test files for forward_list 2016-03-29 18:37:43 -07:00
Robert Ramey 9e2541b030 a) suppress warnings in some tests
b) break out test_forward_list
c) fixe test operator new for mdvc
2016-03-28 14:41:53 -07:00
Robert Ramey 73ec60764a use std::codecvt facet if available 2016-03-21 00:04:22 -07:00
Robert Ramey e40ae62ced tweak visitoiity to eliminate linker warnings 2016-03-21 00:02:06 -07:00
Robert Ramey d25475da16 correction to visibility attribute highlighted by minnow tests 2016-03-20 22:26:34 -07:00
Robert Ramey 1a65a19c20 blackout changes to istream iterator 2016-03-15 14:51:57 -07:00
Robert Ramey e629008d55 changes to test_iterators and others to pass tests 2016-03-11 18:26:34 -08:00
Robert Ramey 5988a816f9 correct dereference of iterator incremented past end() 2016-03-08 12:34:51 -08:00
Robert Ramey c0f17d6934 corrected iterator test. 2016-03-07 09:53:53 -08:00
Robert Ramey 5fe6471b6f tweaked visibility in a test 2016-03-04 12:52:07 -08:00
Robert Ramey 00459350f0 use explicit namespace in the hope of fixing test failure for intel 2016-03-03 22:37:45 -08:00
Robert Ramey ec0c2a2ba1 adjustment to auto link for utf8_codecvt_facit.hpp
minor improvements in map.hp
adjustment to auto link for polymorphic tests
2016-03-03 13:46:50 -08:00
Robert Ramey 6128dfce37 adjustment in auto linking of utf8 codecvt facet 2016-02-28 10:21:53 -08:00
Robert Ramey 1dcca5b67b make sure utf8 works with wide char archives 2016-02-27 21:05:21 -08:00
Robert Ramey 150b7e8a5f various adjustments to
a) correct error in loading set / map for C++11+
b) more refinements of visibility
2016-02-14 21:22:35 -08:00
Robert Ramey d9ad787f70 replace insert with emplace where appropriate
remove workarounds for mdvc 7.1
2016-02-13 10:42:07 -08:00
Robert Ramey 7ae4087c05 fix visibility error for at least mdvc 2016-02-12 12:01:29 -08:00
Robert Ramey 72ef8bf59a correction of visibility setup 2016-01-23 22:29:04 -08:00
Robert Ramey 0040321a7c another attempt to fix codecvt facet 2016-01-20 22:58:29 -08:00
Robert Ramey 00ede57216 fixing visibility for utf8_codecvt 2016-01-19 22:58:45 -08:00
Robert Ramey d330deb82c return utf8 back to state of 22 ocober 2016-01-18 11:41:22 -08:00
Robert Ramey 2006c1633b fix compile errors in tests related to export 2016-01-17 10:33:06 -08:00
Robert Ramey c5c233d857 correct placement of header 2016-01-17 10:05:40 -08:00
Robert Ramey ccdb32bfe5 attempted to eliminate visibility warnings when building as a static library with clang
fixed compile error on polymorphic_derived2
2016-01-17 09:06:11 -08:00
Robert Ramey 6facb61510 fixed a couple of trac items 2016-01-15 09:49:34 -08:00
Robert Ramey eb6faaf428 minor adjustments to fix errors with gcc 6.0 2016-01-14 22:18:51 -08:00
Robert Ramey 587b081d1d backing out dependence on boost locale.
revert to boost/detail/utf8_codecvt
2016-01-14 13:48:16 -08:00
Robert Ramey 67b16f8a9d explicitly initialized m_mbs (std::mbstate_t) in utf8 transform iterators.
adjusted tests to be sure that wchar arrays/strings are null terminated.
2015-11-24 10:48:03 -08:00
Robert Ramey 9bb75492ff added back in test_utf8_codecvt 2015-11-22 16:55:58 -08:00
Robert Ramey 533dba12d7 corrections in visibility specs for tests 2015-11-15 13:30:25 -08:00
Robert Ramey 2783e07993 adjustments for mdvc visibility 2015-11-14 22:59:42 -08:00
Robert Ramey 4083f81e3c Corrections to visibility for MSVC 2015-11-04 08:00:01 -08:00
Robert Ramey ead783cfe8 added missing test files 2015-11-03 11:00:36 -08:00
Robert Ramey e4b18d9379 corrections to visibility issues which breaks tests on mdvc 2015-11-01 14:10:52 -08:00
Robert Ramey e3b67eb299 changes to correct errors in usage of codecvt for utf8
Key change is to change utf8 codecvt facet to use Boost.Locale rather than boost/detail.  This fixed an issue with gcc.
2015-10-30 16:26:11 -07:00
Robert Ramey 41fd59b77b fixed erroneous visibility attribute 2015-10-27 09:26:28 -07:00
Robert Ramey 194ff67a05 attempt to make codecvt_null table visible 2015-10-26 12:37:01 -07:00
Robert Ramey a76a511c95 adjustments for clang visibility 2015-10-25 21:02:44 -07:00
Robert Ramey 494fa31e1c make singleton module lock/unlock work across mainline and all DLL code
fix warnings in binary primitives
fixup bjam test
make sure all codecvt facets are are serialization DLL
2015-10-24 23:49:00 -07:00
Robert Ramey edf1dffd70 fixing codecvt for libstc++ broke things for libc++
This should work for everything
2015-10-24 22:14:27 -07:00
Robert Ramey ae4c2321af Finally? found error in recovery of codecvt facet? 2015-10-24 21:42:34 -07:00
Robert Ramey 160a3369db made improvements in codecvt handling.
Fails two tests on gcc
2015-10-24 13:28:02 -07:00
Robert Ramey a64bf6e4d5 isolated one problem with codecvt facets 2015-10-22 04:42:22 -07:00
Robert Ramey 53a0388fec adjust to account for the fact that utf8 codecvt facet is used by users of serialization.dll 2015-10-20 09:57:32 -07:00
Robert Ramey c05c59ca88 explicitly set stack depth for compilers 2015-10-20 07:48:35 -07:00
Robert Ramey 13f794d953 corrected changes 2015-10-19 21:42:47 -07:00
Robert Ramey e4219b35eb Merge pull request #31 from jzmaddock/msvc-linkage
Changes to get things linking correctly with msvc:
2015-10-18 10:46:26 -06:00
jzmaddock d53d3159b4 Changes to get things linking correctly with msvc:
1) Move the two facets utf8_codecvt_facet and codecvt_null into
the main serialization archive as they get referenced from xml_oarchive.obj.
2) Add DLL-interface to utf8_codecvt_facet.
3) Change codecvt_null to use narrow character DLL interface macros.
2015-10-18 11:51:26 +01:00
Robert Ramey 72530c408d re-installed streambuf_saver so that "imbue" is reversed when the archive is destroyed 2015-10-17 23:09:34 -07:00
Robert Ramey 62c975820d fixed conversion of string -> wasting and vice versa
made data flow iterator which uses codecvt facet - need to generalize this.
expanded test of this
looks like fixed visibility issues - except for one test.
2015-10-16 22:20:44 -07:00
Robert Ramey d1d6a4a100 Update examples and verify that the work 2015-10-11 12:36:32 -07:00
Robert Ramey 5e6f0bd271 simplification of codecvt facets.
This fixed bug of unknown origin in test_array_xml_archive
2015-10-07 12:09:13 -07:00
Robert Ramey 348a916a81 simplification of codecvt facets.
This fixed bug of unknown origin in test_array_xml_archive
2015-10-07 10:57:35 -07:00
Robert Ramey 54a68ca9de adding test case 2015-10-05 21:00:18 -07:00
Robert Ramey 42512bc128 fixted https://svn.boost.org/trac/boost/ticket/11520 2015-10-05 09:11:01 -07:00
Robert Ramey 88a4156aaa Corrections in C++03 support and update of build files 2015-10-04 10:47:11 -07:00
Robert Ramey 619f30aa8d added messing files from unordered collections refactor 2015-10-03 23:51:17 -07:00
Robert Ramey 153e7e635c added serialization of Boost/unordered_set and boost/unordered_map and create new tests 2015-10-03 23:48:52 -07:00
Robert Ramey 40f6cfcc84 Fixed problems with new wchar/mbchar conversion
bumped archive version number
2015-10-02 15:03:02 -07:00
Robert Ramey 4d9fccbee5 Merge pull request #22 from NuxiNL/develop
Don't use thread unsafe wide character processing functions.
2015-10-02 13:29:48 -06:00
Robert Ramey 763f204e80 resolution of issue related to private base classes 2015-10-02 08:22:03 -07:00
Robert Ramey d8c26789e0 fixed leaking definition of STD 2015-09-30 08:37:17 -07:00
Robert Ramey e0b4403d61 more tweaks to fix visibility errors and avoid warnings 2015-09-29 13:55:23 -07:00
Robert Ramey 45610e25e4 changes to support visibility - by Edward Diener 2015-09-29 12:32:23 -07:00
Robert Ramey ae22245b28 Merge pull request #17 from jhunold/virtual
classes with virtual function must have virtual destructors.
2015-09-29 00:56:45 -06:00
Robert Ramey 4f83fc163a Miscellaneous fixes 2015-09-28 23:52:47 -07:00
Robert Ramey e3129464dc Merge branch 'master' into develop 2015-09-28 15:05:31 -07:00
Robert Ramey 9542a9f78e modify comment
eliminate regenerated files
2015-09-28 14:59:06 -07:00
Robert Ramey f6f040a7eb added separate tests for hashed and unordered 2015-09-27 21:35:15 -07:00
Robert Ramey 2d09112b24 separated tests for map and set for C++ 11 and C++ 03 2015-09-27 21:34:21 -07:00
Ed Schouten 599c53c5d0 Don't use thread unsafe wide character processing functions.
The mbtowc(), wctomb() and mblen() functions are not supposed to be
thread-safe, as they have to keep parsing state in a global variable.
The mbrtowc(), wcrtomb() and mbrlen() functions should be used instead.

This change also simplifies how wchar_from_mb<Base>::drain() works.
There is no need to first iterate over the input using mblen().
mbrtowc() can store the partially parsed multibyte character in its
mbstate_t.
2015-08-27 16:08:53 +02:00
Jürgen Hunold 6795c81995 classes with virtual function must have virtual destructors.
The warning is not "bogus" and not only gcc warns.
clang will warn too, but defines __GNUC__ for gcc compatibility.
msvc issues "warning C4265: 'boost::serialization::<foo>' :
class has virtual functions, but destructor is not virtual"
The msvc warning could be suppressed, but it is much cleaner to simply
make the destructors virtual as they are with gcc and clang.
2015-06-15 10:38:57 +02:00
Robert Ramey d779a5d127 Merge develop to master 2015-05-23 11:51:06 -07:00
Robert Ramey 45752f1207 replace test_z with a vestigial program which will always compile and run and pass.
This "empty" program is used for experiments.
2015-05-23 08:53:46 -07:00
Robert Ramey bee3377881 Improved loading of collections
fixed problems with loading types with private constructors
diminished need for reset object address
2015-05-22 08:59:11 -07:00
Robert Ramey f527700804 more compile time errors for mdvc 2015-05-09 18:17:33 -07:00
Robert Ramey 1fb23d124d correction to support visibility for MSVC 2015-05-09 08:24:46 -07:00
Robert Ramey 18992fb13d fixed warnin 2015-04-27 21:40:15 -07:00
Robert Ramey 794c19b2a5 remove comment no longer relevant 2015-04-27 17:14:36 -07:00
Robert Ramey 2e2fac9291 Revert "removed dead code from vector.hpp"
This reverts commit 423c6d8076.
2015-04-27 17:12:31 -07:00
Robert Ramey 423c6d8076 removed dead code from vector.hpp 2015-04-27 16:58:51 -07:00
Robert Ramey b3a02cf2b1 eliminated dead code in vector.hp
changed spelling from constructable to constructible in test_z.cpp
2015-04-27 16:56:21 -07:00
Robert Ramey e25f595656 changed to use custom implementation of is_default_constructible 2015-04-27 16:44:36 -07:00
Robert Ramey 4a80b0f089 passing vector test 2015-04-27 16:32:45 -07:00
Robert Ramey 751155614c fix visibility errors 2015-04-27 16:29:21 -07:00
Robert Ramey d76884319c make constructor public rather than protected in order to address MSVC/32 13 quirk 2015-04-27 16:28:35 -07:00
Robert Ramey 73d2494dde updated vector test to test for types without default constructor which are handled differently 2015-04-25 09:37:12 -07:00
Robert Ramey ae41d09039 correct error in export macro for wide types 2015-04-25 08:09:31 -07:00
Robert Ramey f90de55927 leave test_z blank - it's used to paste tests into the IDE 2015-04-24 16:59:49 -07:00
Robert Ramey 50d59842c2 fixed error in loading of non empty instances of vector.hp 2015-04-24 16:44:38 -07:00
Robert Ramey 2d898f7db8 replace std::min with (std::min) in order to avoid problems with compilers which use min macros 2015-04-24 15:28:46 -07:00
Robert Ramey 50ecbd1f28 Remove last of support for compilers which don't support function template ordering 2015-04-24 15:24:30 -07:00
Robert Ramey 0100558166 correction in shared_ptr_helper
permit pass values by const & to output interface
2015-04-24 15:12:22 -07:00
Robert Ramey 83c1373a4d fixed warning in clang smart_cast.hp 2015-04-24 13:49:56 -07:00
Robert Ramey 1f94b5276b minor adjustments to visibility 2015-04-24 13:28:24 -07:00
Robert Ramey 70206bf4ef Revert "enhancement to support gcc visibility."
This reverts commit 23b012ef66.
2015-04-24 13:12:10 -07:00
Robert Ramey 23b012ef66 enhancement to support gcc visibility.
These changes are meant to support gcc visibility on mingw platforms - which is basically gcc with windows attributes.
2015-04-22 22:02:56 -07:00
Robert Ramey 7565de4008 transitory changes attempting to resolve visibility for minnow 2015-04-22 09:32:58 -07:00
Robert Ramey 750080c20e added polymorphic helper tests
removed obsolete information from documentation
2015-04-11 10:14:37 -07:00
Robert Ramey a32549c25f fixed problem with helper on polymorphic archives
added test_polymorphic_helper
2015-04-10 14:24:33 -07:00
Robert Ramey 0d9dd64a66 Marcel s changes to fix import/export on MSVC 2015-04-05 13:53:55 -07:00
Robert Ramey bb6f23bd92 Merge pull request #12 from MarcelRaad/fix_msvc
Fix DLL compilation on MSVC
2015-04-05 11:00:33 -07:00
Robert Ramey 38a69e729b Adjustments trying to get correct MSVC compilation for dll 2015-04-05 09:30:15 -07:00
Marcel Raad e66f38a702 Fix DLL compilation on MSVC 2015-04-05 16:47:56 +02:00
Robert Ramey 49f34b5810 Trying to get archive exception to compile 2015-04-04 15:49:27 -07:00
Robert Ramey 831a6e26b4 minor changes to clean up some warnings and to try and get the library to build on MSVC compilers 2015-04-04 12:57:50 -07:00
Robert Ramey aedbb5da8e tweak to address compilation error on MSVC 2015-04-03 08:26:29 -07:00
Robert Ramey 61b81fad46 many small adjustments to get visibility working correctly on GCC and Clang.
Tested pretty extensively in release/debug shared/linked.
I don't have MSVC on me - so I'll have to upload without testing this.
One pending issue is that test_utf8_codecvt fails.  I'm guessing that the copy in detail needs to be tweaked.
I'll get this fixed up separately.
2015-04-02 13:02:33 -07:00
Robert Ramey e16e3ed0dc corrected visibility for MSVC compilers 2015-03-31 16:52:41 -07:00
Robert Ramey 92e104060d enabled visibility=hidden for gcc compiler to diminish symbols in executable 2015-03-29 22:15:24 -07:00
Robert Ramey c3fbfb3cad made adjustments to suppress bogus warnings with MSVC so we could see error messages in test matrix 2015-03-29 21:34:46 -07:00
Robert Ramey 434b7c3a6d make changes to see if I can get MSVC platforms to compile/link 2015-03-27 14:43:59 -07:00
Robert Ramey 94d2e495ca corrected pfto in polymorphic_?archive.hpp
fixed visibility for singleton
corrected error in test_utf8_codecvt
2015-03-24 18:02:06 -07:00
Robert Ramey 8dd74ab095 bumped archive version in case I break something 2015-03-23 15:38:53 -07:00
Robert Ramey 5a94e5e4eb removed pfto 2015-03-23 15:29:57 -07:00
Robert Ramey 5c7e17b715 removed support for borland compilers 2015-03-23 13:43:59 -07:00
Robert Ramey 7067bdb263 simplifing visibility/autolink 2015-03-23 13:20:05 -07:00
Robert Ramey 1baeb11a7f cleanup visibiliy / auto link macros throughout project - still more to be done 2015-03-23 12:46:02 -07:00
256 changed files with 4895 additions and 4006 deletions
+72
View File
@@ -0,0 +1,72 @@
# Copyright 2016 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)
language: cpp
sudo: false
os:
- linux
- osx
branches:
only:
- master
- develop
install:
- cd ..
- git clone -b $TRAVIS_BRANCH --depth 1 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
- cp -r $TRAVIS_BUILD_DIR/* libs/serialization
- ./bootstrap.sh
- ./b2 headers
script:
- TOOLSET=gcc,clang
- if [ $TRAVIS_OS_NAME == osx ]; then TOOLSET=clang; fi
- ./b2 libs/serialization/test toolset=$TOOLSET
notifications:
email:
on_success: always
+65 -22
View File
@@ -2,6 +2,13 @@
cmake_minimum_required(VERSION 3.0)
if (POLICY CMP0054)
cmake_policy (SET CMP0054 NEW)
endif (POLICY CMP0054)
if (POLICY CMP0063)
cmake_policy (SET CMP0063 NEW)
endif (POLICY CMP0063)
if(Boost_USE_STATIC_LIBS)
project("Serialization-Static")
@@ -14,15 +21,18 @@ endif()
#
message(STATUS "compiler is ${CMAKE_CXX_COMPILER_ID}" )
add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
add_definitions( -ftemplate-depth=300 )
# we use gcc to test for C++03 compatibility
add_definitions( std=c++03 )
message(STATUS "compiler is g++ c++03")
set(COMPILER_SUPPORTS_CXX11 FALSE)
elseif( CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
add_definitions( /wd4996 )
message(STATUS "compiler is 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")
@@ -30,6 +40,7 @@ elseif( CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" )
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()
#
@@ -96,30 +107,45 @@ endif()
# end special note for Xcode
############################
set(Boost_DEBUG true)
set(Boost_DETAILED_FAILURE_MSG true)
set(Boost_FOUND true)
find_package(Boost REQUIRED COMPONENTS system filesystem)
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}")
elseif()
message("Boost NOT Found!")
#include_directories("../include" "${Boost_INCLUDE_DIRS}")
#link_directories("${Boost_LIBRARY_DIRS}")
else()
message(STATUS "Boost NOT Found!")
endif()
if(Boost_USE_STATIC_LIBS)
set(BUILD_SHARED_LIBRARIES OFF)
message(STATUS "Use static libraries")
set(LINK_TYPE "STATIC")
else()
set(BUILD_SHARED_LIBRARIES ON)
message(STATUS "Building shared libraries")
set(LINK_TYPE "SHARED")
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)
endif()
###########################
# library builds
add_library(serialization
add_library(serialization ${LINK_TYPE}
../src/archive_exception.cpp
../src/basic_archive.cpp
../src/basic_iarchive.cpp
@@ -134,36 +160,34 @@ add_library(serialization
../src/basic_xml_archive.cpp
../src/binary_iarchive.cpp
../src/binary_oarchive.cpp
../src/codecvt_null.cpp
../src/extended_type_info_no_rtti.cpp
../src/extended_type_info_typeid.cpp
../src/extended_type_info.cpp
../src/polymorphic_iarchive.cpp
../src/polymorphic_oarchive.cpp
../src/singleton.cpp
../src/stl_port.cpp
../src/text_iarchive.cpp
../src/text_oarchive.cpp
../src/text_wiarchive.cpp
../src/text_woarchive.cpp
../src/utf8_codecvt_facet.cpp
../src/void_cast.cpp
../src/xml_archive_exception.cpp
../src/xml_iarchive.cpp
../src/xml_oarchive.cpp
../src/xml_grammar.cpp
# ../src/basic_xml_grammar.ipp # doesn't show up in "Source Files" in Xcode"'
../src/utf8_codecvt_facet.cpp
../src/basic_xml_grammar.ipp # doesn't show up in "Source Files" in Xcode"'
)
add_library(wserialization
add_library(wserialization ${LINK_TYPE}
../src/codecvt_null.cpp
../src/basic_text_wiprimitive.cpp
../src/basic_text_woprimitive.cpp
../src/text_wiarchive.cpp
../src/text_woarchive.cpp
../src/utf8_codecvt_facet.cpp
../src/xml_wiarchive.cpp
../src/xml_woarchive.cpp
../src/codecvt_null.cpp
../src/xml_wgrammar.cpp
../src/basic_xml_grammar.ipp # doesn't show up in "Source Files" in Xcode"'
)
# end library build
@@ -242,10 +266,14 @@ serialization_test(test_iterators)
serialization_test(test_iterators_base64)
serialization_test(test_inclusion)
serialization_test(test_smart_cast)
serialization_test(test_utf8_codecvt ../src/utf8_codecvt_facet)
serialization_test(test_codecvt_null ../src/codecvt_null)
serialization_test(test_strong_typedef)
archive_test(test_array A)
archive_test(test_native_array A)
archive_test(test_boost_array A)
if(COMPILER_SUPPORTS_CXX11)
archive_test(test_array A)
endif()
archive_test(test_binary)
archive_test(test_bitset)
archive_test(test_class_info_save)
@@ -260,11 +288,14 @@ 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)
archive_test(test_interrupts)
archive_test(test_list A)
archive_test(test_list_ptrs A)
archive_test(test_map A)
archive_test(test_map_boost_unordered A)
archive_test(test_mi)
archive_test(test_multiple_ptrs A)
archive_test(test_multiple_inheritance)
@@ -279,11 +310,11 @@ archive_test(test_object)
archive_test(test_optional)
archive_test(test_primitive)
archive_test(test_priority_queue A)
# archive_test(test_private_base)
archive_test(test_private_base)
archive_test(test_private_base2)
archive_test(test_queue A)
archive_test(test_recursion A)
archive_test(test_registered)
archive_test(test_set A)
archive_test(test_shared_ptr)
archive_test(test_shared_ptr_multi_base)
archive_test(test_shared_ptr_132)
@@ -297,9 +328,22 @@ archive_test(test_unique_ptr)
archive_test(test_valarray)
archive_test(test_variant A)
archive_test(test_vector A)
archive_test(test_set A)
archive_test(test_set_boost_unordered A)
if(COMPILER_SUPPORTS_CXX11)
archive_test(test_set_unordered A)
else()
archive_test(test_set_hashed A)
endif()
if(COMPILER_SUPPORTS_CXX11)
archive_test(test_map_unordered A)
else()
archive_test(test_map_hashed A)
endif()
polymorphic_archive_test(test_polymorphic test_polymorphic_A A )
polymorphic_archive_test(test_polymorphic test_polymorphic_A A)
polymorphic_archive_test(test_polymorphic2 test_polymorphic2imp)
polymorphic_archive_test(test_polymorphic_helper)
# end test targets
####################
@@ -357,8 +401,7 @@ file(GLOB x
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/archive/*_w*.hpp"
)
add_custom_target(wserialization_headers SOURCES ${x} "${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/archive/codecvt_null.hpp")
add_custom_target(wserialization_headers SOURCES ${x})
set_property(TARGET wserialization_headers PROPERTY FOLDER "wserialization")
# end headers in IDE
+19 -5
View File
@@ -80,6 +80,9 @@ SOURCES =
xml_iarchive
xml_oarchive
xml_archive_exception
codecvt_null
utf8_codecvt_facet
singleton
;
WSOURCES =
@@ -87,19 +90,22 @@ WSOURCES =
basic_text_woprimitive
text_wiarchive
text_woarchive
utf8_codecvt_facet
xml_wgrammar
xml_wiarchive
xml_woarchive
codecvt_null
;
lib boost_serialization
: $(SOURCES).cpp
:
<toolset>msvc:<cxxflags>/Gy
#<toolset>gcc:<cxxflags>"-fvisibility=hidden"
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
<toolset>clang:<cxxflags>"-fvisibility=hidden -fvisibility-inlines-hidden"
<toolset>gcc:<cxxflags>"-fvisibility=hidden -fvisibility-inlines-hidden"
<toolset>darwin:<cxxflags>"-fvisibility=hidden -fvisibility-inlines-hidden"
<toolset>gcc:<cxxflags>"-ftemplate-depth-255"
<toolset>clang:<cxxflags>"-ftemplate-depth-255"
<toolset>darwin:<cxxflags>"-ftemplate-depth-255"
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
;
@@ -107,7 +113,15 @@ lib boost_wserialization
: $(WSOURCES).cpp boost_serialization
:
<toolset>msvc:<cxxflags>/Gy
#<toolset>gcc:<cxxflags>"-fvisibility=hidden"
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
<toolset>clang:<cxxflags>"-fvisibility=hidden -fvisibility-inlines-hidden"
<toolset>gcc:<cxxflags>"-fvisibility=hidden -fvisibility-inlines-hidden"
<toolset>darwin:<cxxflags>"-fvisibility=hidden -fvisibility-inlines-hidden"
<toolset>gcc:<cxxflags>"-ftemplate-depth-255"
<toolset>clang:<cxxflags>"-ftemplate-depth-255"
<toolset>darwin:<cxxflags>"-ftemplate-depth-255"
# note: both serialization and wserialization are conditioned on the this
# switch - don't change it to BOOST_WSERIALIZATION_DYN_LINK
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
;
+2 -1
View File
@@ -253,7 +253,7 @@ function initialize() {
<dd><div id="userincludes_detail"><dl class="page-index">
<dt><img style="display:none" src="dot.gif"><a target="detail" href="headers.html#archiveimplementations">Archive Implementations</a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="headers.html#serializationdeclarations">Serialization Declarations</a>
<dt><img style="display:none" 'rc="dot.gif"><a target="detail" href="headers.html#serializationimplementations">Serialization Implementations</a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="headers.html#serializationimplementations">Serialization Implementations</a>
</dl></div>
<dt><img style="display:none" src="plus.gif" id="libraryimplementation"><a target="detail" href="headers.html#libraryimplementation">Files Which Implement the Library</a>
<dd><div id="libraryimplementation_detail"><dl class="page-index">
@@ -269,6 +269,7 @@ function initialize() {
<dt><img style="display:none" src="dot.gif"><a target="detail" href="shared_ptr.html">Template serialization - <code>shared_ptr&lt;class T&gt;</code></a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="shared_ptr2.html"><code>shared_ptr&lt;class T&gt;</code>Revisited</a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="pimpl.html">PIMPL</a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="private_base.html">Private Base Classes</a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="simple_log.html">A Simple Logging Archive Class</a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="derivation.html">Derivation from an Existing Archive Class</a>
</dl></div></dd>
+3 -190
View File
@@ -26,20 +26,13 @@ http://www.boost.org/LICENSE_1_0.txt)
</table>
<hr>
<dl class="page-index">
<dt><a href="#functiontemplateordering">Partial Function Template Ordering</a>
<dt><a href="#charencoding">Character Encoding</a>
<dt><a href="#tempatesyntax">Template Invocation syntax</a>
<dt><a href="#partialtemplatespecialization">Partial Template Specialization</a>
<dt><a href="#othercompilerissues">Specific Compiler/Library Issues</a>
<dl class="page-index">
<dt><a href="#gcc3x">GCC 3.X, 4.X</a>
<dt><a href="#gcc295">GCC 2.95</a>
<dt><a href="#gcc4x">44.X</a>
<dt><a href="#intel80">Intel 8.0</a>
<dt><a href="#vc80">Visual C++ 8.0</a>
<dt><a href="#vc71">Visual C++ 7.1</a>
<dt><a href="#vc70">Visual C++ 7.0</a>
<dt><a href="#vc6">Visual C++ 6.0</a>
<dt><a href="#borland">Borland 5.64 and 5.51</a>
<dt><a href="#comeau">Comeau 4.3.3</a>
<dt><a href="#codewarrior9">Code Warrior 9.x</a>
<dt><a href="#codewarrior">Code Warrior 8.3</a>
@@ -49,81 +42,6 @@ http://www.boost.org/LICENSE_1_0.txt)
</dl>
</dl>
<h3><a name="functiontemplateordering">Partial Function Template Ordering</a></h3>
Not all C++ compilers correctly support partial function template ordering (PFTO).
For these compilers, the following code will fail to compile:
<pre><code>
template&lt;class Archive, class T&gt;
void serialize(
Archive & ar,
T & t,
const unsigned int file_version
){
...
}
template&lt;class Archive, class T&gt;
void serialize(
Archive & ar,
my_template&lt;T&gt & t,
const unsigned int file_version
){
...
}
</pre></code>
The serialization library works around this issue by using a different
default definition of the first template:
<pre><code>
template&lt;class Archive, class T&gt;
void serialize(
Archive & ar,
T & t,
const unsigned long int file_version // Note: change to long
){
...
}
</pre></code>
Now, the second template is not matched with the first one so there
is no PFTO and no compile error. When the serialization library invokes
<pre><code>
serialize(ar, t, 0);
</pre></code>
the function declaration is first matched against templates with
an integer for the third argument. If there is a match, the matching
template is instantiated and later invoked. If there is no match,
an attempt is made to match other templates by converting arguments to other types.
In this case the third argument can be converted to long to match
the first template - which is the default. So in this case, the first
template will be instantiated and later invoked. We have managed to
use function overloading to achieve the same effect as PFTO
were it correctly implemented.
<p>
This depends upon undefined behavior of a compiler already
determined to be non-conforming. In other words, there is no
guarantee that this will work on all compilers. If a compiler does not
correctly support PFTO and this method cannot be used to workaround
it, non-intrusive serialization cannot be supported for that compiler.
As of this writing, such a compiler has not been encountered.
<p>
It turns out that using this "trick" can create problems with
compilers that DO correctly support PFTO. For this reason we
define a macro <code style="white-space: normal">BOOST_PTFO</code> which
is defined to be <code style="white-space: normal">long</code>
for non-conforming compilers and nothing for conforming ones. So
the default definition is really:
The serialization library works around this issue by using a different
default definition of the first template:
<pre><code>
template&lt;class Archive, class T&gt;
void serialize(
Archive & ar,
T & t,
const unsigned BOOST_PFTO int file_version // Note: change to BOOST_PFTO
){
...
}
</pre></code>
<h3><a name="charencoding">Character Encoding</a></h3>
The whole question of character encoding combined with wide characters
is much more complicated than it would seem to be. The current library
@@ -175,31 +93,8 @@ do the following.
<li>Create the archive with the flag <code style="white-space: normal">no_codecvt</code>.
</ul>
Naturally, the input process has to be symmetrical.
<h3><a name="partialtemplatespecialization">Partial Template Specialization</a></h3>
Compilers which fail to support partial template specialization will fail to compile
the following code. To make this compile, the <code style="white-space: normal">const</code> has to be removed.
<pre><code>
void f(A const* a, text_oarchive& oa)
{
oa << a;
}
</code></pre>
<h3><a name="tempatesyntax">Template Invocation syntax</a></h3>
Some compilers may not recognize the syntax:
<pre><code>
ar.template register_type&lt;T&gt;();
</code></pre>
for "registering" derived pointers of polymorphic classes. The actual
function prototype is:
<pre><code>
template&lt;T&gt;
void register_type(T * t = NULL);
</code></pre>
so that one may write <code style="white-space: normal">ar.register_type(static_cast&lt;T *&gt;(NULL))</code> instead of
the syntax described above.
</ul>
<h3><a name="othercompilerissues">Specific Compiler/Library Issues</a></h3>
<h4><a name="gcc3x">GCC 3.X, 4.X</a></h4>
<h4><a name="gcc4x">GCC 4.X</a></h4>
<ul>
<li>GCC versions for Cygwin and MinGW fail to support wide character I/O.
So all tests using wide char I/O fail. Note that if wide character I/O support
@@ -219,17 +114,6 @@ the syntax described above.
-Wno-ctor-dtor-privacy
</code></pre>
</ul>
<h4><a name="gcc295">GCC 2.95</a></h4>
All of the above plus:<br>
<ul>
<li>The serialization library depends on the templated stream
implementation to function properly.
So STLPort must be used to build the library.
<li>Polymorphic archive tests fail.
<li>XML serialization only works with version 1.6x of spirit. In order to build
and use this library with this compiler, one must use version 1.6x rather than the
latest version shipped with boost. See <a href="release.html">Release Notes</a>.
</ul>
<h4><a name="intel80">Intel C++ 8.0</a></h4>
No known issues. All tests compile and run in debug and release modes.
@@ -311,77 +195,6 @@ decide to use these configurations.
in sync with those included here.
</ul>
<h4><a name="vc70">Visual C++ 7.0</a></h4>
<ul>
<li>The "pimpl" demo fails to link. Cause and workaround for this is unknown
<li>XML serialization only works with version 1.6x of spirit. In order to build and use this
library with this compiler, one must use version 1.6x rather than the latest version
shipped with boost. See <a href="release.html">Release Notes</a>.
<li>This compiler does not support partial template specialization.
The implementation of the new <code>shared_ptr</code> serialization depends upon
compiler support for partial template specialization. This compiler doesn't implement this
feature. In order to serialize <code style="white-space: normal">shared_ptr&lt;A&gt;</code>,
invoke the macro <code style="white-space: normal">BOOST_SERIALIZATION_SHARED_PTR(A)</code>
in the header code.
<li>Lack of support for partial template specialization also creates problems for
serialization of <code style="white-space: normal">std::map</code>. In order to serialize
instances of this type include the invocation of BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION
for the key type of the map.
</ul>
<h4><a name="vc6">Visual C++ 6.5</a></h4>
all the above issues for Visual C++ 7.0 plus:
<ul>
<li>Out of line template definitions are not recognized and fail with a confusing
error message. To function save/load/serialize member function templates must be defined
within the class definition. This feature is essential to <code style="white-space: normal">demo_pimpl</code>. Hence,
this program will fail to compile. In this case the problem can't be worked around and
still demonstrate this facility.
<li>This compiler does not support <code style="white-space: normal">wchar_t</code> as a separate type. It defines
<code style="white-space: normal">wchar_t</code> as an alias for <code style="white-space: normal">short int</code>. In general things will still
function. However certain customizations, such as overloading archive operators for
saving/loading wide character arrays would produce surprises in this environment.
<li>Under certain circumstances, a program will fail to link with the message:
LIN1179 - "invalid or corrupt file: duplicate comdat". According
to <a href="http://groups.google.com/groups?th=8a05c82c4ffee280">
http://groups.google.com/groups?th=8a05c82c4ffee280
</a> (look for P78)
A LNK1179 error occurs when:
<ul>
<li>The template class takes at least two arguments.
<li>The template is used at least two times with identical first
and different second arguments.
<li>The static member variable is of an object type with at least one
base class. (In another scenario it also occurred using a member
without a base class.)
</ul>
Working around this in the implementation of the library for this compiler
entailed a ridiculous amount of effort. Even so, the effort wasn't entirely successful.
With this compiler, this message will still appear under the following conditions:
<ul>
<li>When serializing a class with multiple base classes. This problem causes two
failure in the test suite. I have been unable to devise a way to work around this.
<li>Using more than one kind of archive in the same code module. This should be easy
to work around in practice.
</ul>
<li>Code modules exceeding some undetermined size that use the library will fail with
<i>fatal error C1204: compiler limit : internal structure overflow</i>. This can be addressed
by dividing the module into smaller ones.
</ul>
<h4><a name="borland">Borland 5.64 and 5.51</a></h4>
<ul>
<li><code style="white-space: normal">enum</code> data members cannot be serialized.
Conversion to/from integers will work around the problem.
<li>If class serialize functions are not accessible either by making them public or by
including <code style="white-space: normal">friend</code> declarations as described in
<a href="serialization.html#member">Class Serialization - Member Function</a>, the code
will compile but fail at runtime.
<li>Tests using custom extended type which doesn't use RTTI fails. (5.64 only !).
<li>Tests built in release mode fail. This seems to be an issue with the boost test system
with this compiler.
<li>XML serialization only works with version 1.6x of spirit. In order to build
and use this library with this compiler, one must use version 1.6x rather than the
latest version shipped with boost. See <a href="release.html">Release Notes</a>.
</ul>
<h4><a name="comeau">Comeau 4.3.3</a></h4>
<ul>
<li>This compiler fails to make a DLL with export under windows.
@@ -434,7 +247,7 @@ These platforms have several issues:
<hr>
<p>Revised 1 November, 2004
<p><i>&copy; Copyright <a href="http://www.rrsd.com">Robert Ramey</a> 2002-2004.
<p><i>&copy; Copyright <a href="http://www.rrsd.com">Robert Ramey</a> 2002-2015.
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)
</i></p>
+170
View File
@@ -0,0 +1,170 @@
<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!--
(C) Copyright 2002-4 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)
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Serialization - Private Base Classes</title>
</head>
<body link="#0000ff" vlink="#800080">
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary="header">
<tr>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../boost.png" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Serialization</h1>
<h2 align="center">Private Base Classes</h2>
</td>
</tr>
</table>
<hr>
In many cases, serialization of private or protected base classes present no special problems.
This is true for both simple classes and types as well as pointers to those
classes and types. That is, the following program compiles and runs exactly as one would expect.
<pre><code>
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// test_private_base.cpp
// (C) Copyright 2009 Eric Moyer - 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 <fstream>
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::remove;
}
#endif
#include <boost/serialization/access.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/export.hpp>
class Base {
friend class boost::serialization::access;
int m_i;
template<class Archive>
void serialize(Archive & ar, const unsigned int version){
ar & BOOST_SERIALIZATION_NVP(m_i);
}
protected:
bool equals(const Base &rhs) const {
return m_i == rhs.m_i;
}
Base(int i = 0) :
m_i(i)
{}
};
class Derived : private Base {
friend class boost::serialization::access;
private:
Base & base_cast(){
return static_cast<Base &>(*this);
}
template<class Archive>
void serialize(Archive & ar, const unsigned int version){
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
}
public:
bool operator==(const Derived &rhs) const {
return Base::equals(static_cast<const Base &>(rhs));
}
Derived(int i = 0) :
Base(i)
{}
};
int
main( int /* argc */, char* /* argv */[] )
{
const char * testfile = boost::archive::tmpnam(NULL);
// serialize Derived and Base
Derived a(1), a1(2);
{
test_ostream os(testfile);
test_oarchive oa(os);
oa << boost::serialization::make_nvp("a", a);
}
{
test_istream is(testfile, TEST_STREAM_FLAGS);
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
ia >> boost::serialization::make_nvp("a", a1);
}
std::remove(testfile);
if(a != a1)
return 1;
// serialize Derived and Base
Derived *ta = &a;
Derived *ta1 = NULL;
{
test_ostream os(testfile);
test_oarchive oa(os);
oa << boost::serialization::make_nvp("ta", ta);
}
{
test_istream is(testfile, TEST_STREAM_FLAGS);
test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
ia >> boost::serialization::make_nvp("ta", ta1);
}
std::remove(testfile);
if(*ta != *ta1)
return 1;
return 0;
}
</code></pre>
Difficulties start to occur when the base class is made polymorphic by the designation
of one or more functions as "virtual". If a class is polymorphic, the library
presumes that one will want the ability to serialize a derived class through
a pointer to the base class. Included in the macro
<code>
BOOST_SERIALIZATION_BASE_OBJECT_NVP
</code>
is code which links derived and base class definitions in tables used to serialize
derived classes through pointers to a polymorphinc base class. This code requires
the ability to invoke
<code>
static_cast&lt;Base &&gt;(Derived &)
</code>
which C++ will only permit from within the derived class if the base class is
private or protected. The program will fail to compile with an error message
indicating invalid cast.
<p>
In order for this
code compiler the following alteration must be made:
<pre><code>
template<class Archive>
void serialize(Archive & ar, const unsigned int version){
//ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
ar & boost::serialization::make_nvp(
"Base",
static_cast&lt;Base &&gt;(*this)
);
}
</code></pre>
With this change the program will now compile.
<p>
If we made one of the functions of <code>Base></code> <code>virtual</code>
in order to use the "export" functionality of the serialization library and permit serialization through
a pointer the the base class, we'll be disappointed. Without the ability to
cast to the base class, we can't use the functionality.
<hr>
<p><i>&copy; Copyright <a href="http://www.rrsd.com">Robert Ramey</a> 2015.
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)
</i></p>
</body>
</html>
+19 -1
View File
@@ -29,6 +29,8 @@ http://www.boost.org/LICENSE_1_0.txt)
</table>
<hr>
<dl class="index">
<dt><a href="#differences_1_59">Differences from version 1.58</a></dt>
<dt><a href="#differences_1_58">Differences from version 1.48</a></dt>
<dt><a href="#differences_1_45">Differences from version 1.45</a></dt>
<dt><a href="#differences_1_43">Differences from version 1.43</a></dt>
<dt><a href="#differences_1_42">Differences from version 1.42</a></dt>
@@ -39,12 +41,28 @@ http://www.boost.org/LICENSE_1_0.txt)
<dt><a href="#differences_1_35">Differences from version 1.35</a></dt>
<dt><a href="#differences_1_34">Differences from version 1.34</a></dt>
<dt><a href="#differences_1_33">Differences from version 1.33</a></dt>
<dt><a href="#differences_1_32">Differences from version 1.32</a></dt>
<dt><a href="#differences_1_32">Differences from version 1.32</a></dt>
<dt><a href="#todo">Pending Issues</a></dt>
</dl>
As of this writing, there are no known bugs. However, due to compiler/library
quirks and or bugs, some tests fail with some combinations of compilers and
libraries.
<h2><a name="differences_1_59"></a>Differences from Boost 1.58</h2>
<ul>
<li>Eliminated support for Borland compilers and Microsoft compilers prior to version
7.1.
<li>Eliminated support for compilers which do not support Partial Function Template
Ordering (pfto).
<li>Added support for "visibility hidden" for GCC compilers. Shared libraries
will only expose symbols actually needed rather than all sympols in the library. This
should result in smaller shared libraries which are faster to load.
</ul>
<h2><a name="differences_1_58"></a>Differences from Boost 1.48</h2>
<ul>
<li>Added support for C++11 types such as std::shared_ptr, std::array, and others.
<li>Implemented the concept of a "Helper" which can be used to implement serialization of types which are otherwise not serializable."
<li>Made library compatible with C++11, Compatibility with C++03 has been maintained.
</ul>
<h2><a name="differences_1_45"></a>Differences from Boost 1.45</h2>
Since the release of version 1.42, it has been discovered that binary
archives created by versions 1.42-1.44 cannot always be read by the
+1 -1
View File
@@ -792,7 +792,7 @@ class derived : public base {
ar & boost::serialization::base_object&lt;base&gt;(*this);
// method 2 : explicitly register base/derived relationship
boost::serialization::void_cast_register&lt;derived, base&gt;(
static_cast&lt;derived *&gt;=NULL),
static_cast&lt;derived *&gt;(NULL),
static_cast&lt;base *&gt;(NULL)
)
}
+24 -39
View File
@@ -11,47 +11,32 @@ project libs/serialization/example
: requirements <library>../build//boost_serialization
;
rule demo_bsl_run ( demo-name : othersources * : requirements * )
{
return [ run
# sources
$(demo-name).cpp
$(othersources).cpp
: # command
: # input files
: # requirements
# toolset suppress-warnings
<toolset>gcc:<cxxflags>"-Wno-non-virtual-dtor -Wno-ctor-dtor-privacy"
<toolset>msvc-8.0:<cxxflags>"-wd4996"
<toolset>borland:<cxxflags>"-w-8080 -w-8071 -w-8057 -w-8062 -w-8008 -w-0018 -w-8066"
# toolset optimizations
<toolset>gcc:<cxxflags>"-ftemplate-depth-255"
<toolset>msvc:<cxxflags>"-Gy"
# toolset shared library support
<toolset>como,<runtime-link>shared:<build>no
<toolset>msvc,<stdlib>stlport,<runtime-link>shared:<build>no
<toolset>cw,<runtime-link>static:<build>no
$(requirements)
: # test name
$(demo-name)
]
;
}
import ../util/test :
run-template
run-invoke
run-winvoke
test-bsl-run-no-lib
test-bsl-run
test-bsl-run_archive
test-bsl-run_files
test-bsl-run_polymorphic_archive
;
test-suite "demo-suite" :
# demos
[ demo_bsl_run demo ]
[ demo_bsl_run demo_auto_ptr ]
[ demo_bsl_run demo_exception ]
[ demo_bsl_run demo_log : log_archive ]
[ demo_bsl_run demo_pimpl : demo_pimpl_A ]
[ demo_bsl_run demo_polymorphic : demo_polymorphic_A ]
[ demo_bsl_run demo_portable_archive : portable_binary_iarchive portable_binary_oarchive ]
[ demo_bsl_run demo_shared_ptr ]
[ demo_bsl_run demo_simple_log ]
[ demo_bsl_run demo_trivial_archive ]
[ demo_bsl_run demo_xml ]
[ demo_bsl_run demo_xml_save ]
[ demo_bsl_run demo_xml_load : : <dependency>demo_xml_save ]
[ test-bsl-run demo ]
[ test-bsl-run demo_auto_ptr ]
[ test-bsl-run demo_exception ]
[ test-bsl-run demo_fast_archive ]
[ test-bsl-run demo_log : log_archive ]
[ test-bsl-run demo_pimpl : demo_pimpl_A ]
[ test-bsl-run demo_polymorphic : demo_polymorphic_A ]
[ test-bsl-run demo_portable_archive : portable_binary_iarchive portable_binary_oarchive ]
[ test-bsl-run demo_shared_ptr ]
[ test-bsl-run demo_simple_log ]
[ test-bsl-run demo_trivial_archive ]
[ test-bsl-run demo_xml ]
[ test-bsl-run demo_xml_save ]
[ test-bsl-run demo_xml_load : : : <dependency>demo_xml_save ]
;
+12 -13
View File
@@ -11,7 +11,6 @@
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/serialization/pfto.hpp>
#define BOOST_ARCHIVE_SOURCE
#include <boost/archive/binary_oarchive_impl.hpp>
@@ -61,26 +60,26 @@ public:
// binary_oarchive_impl<derived_t>::load_override;
// so we use the sure-fire method below. This failed to work as well
template<class T>
void save_override(T & t, BOOST_PFTO int){
base_t::save_override(t, 0);
void save_override(T & t){
base_t::save_override(t);
// verify that this program is in fact working by making sure
// that arrays are getting passed here
BOOST_STATIC_ASSERT(! (boost::is_array<T>::value) );
}
template<int N>
void save_override(const int (& t)[N] , int){
void save_override(const int (& t)[N]){
save_binary(t, sizeof(t));
}
template<int N>
void save_override(const unsigned int (& t)[N], int){
void save_override(const unsigned int (& t)[N]){
save_binary(t, sizeof(t));
}
template<int N>
void save_override(const long (& t)[N], int){
void save_override(const long (& t)[N]){
save_binary(t, sizeof(t));
}
template<int N>
void save_override(const unsigned long (& t)[N], int){
void save_override(const unsigned long (& t)[N]){
save_binary(t, sizeof(t));
}
public:
@@ -129,24 +128,24 @@ public:
// binary_oarchive_impl<derived_t>::load_override;
// so we use the sure-fire method below. This failed to work as well
template<class T>
void load_override(T & t, BOOST_PFTO int){
base_t::load_override(t, 0);
void load_override(T & t){
base_t::load_override(t);
BOOST_STATIC_ASSERT(! (boost::is_array<T>::value) );
}
template<int N>
void load_override(int (& t)[N], int){
void load_override(int (& t)[N]){
load_binary(t, sizeof(t));
}
template<int N>
void load_override(unsigned int (& t)[N], int){
void load_override(unsigned int (& t)[N]){
load_binary(t, sizeof(t));
}
template<int N>
void load_override(long (& t)[N], int){
void load_override(long (& t)[N]){
load_binary(t, sizeof(t));
}
template<int N>
void load_override(unsigned long (& t)[N], int){
void load_override(unsigned long (& t)[N]){
load_binary(t, sizeof(t));
}
public:
+3 -3
View File
@@ -13,8 +13,7 @@
#include "demo_gps.hpp"
#include "log_archive.hpp"
int main(int argc, char *argv[])
{
int main(int argc, char *argv[]){
// make the schedule
bus_schedule schedule;
@@ -65,7 +64,7 @@ int main(int argc, char *argv[])
// display the complete schedule
log_archive oa(std::cout);
//oa << BOOST_SERIALIZATION_NVP(schedule);
oa << BOOST_SERIALIZATION_NVP(schedule);
oa << schedule;
delete bs0;
@@ -74,3 +73,4 @@ int main(int argc, char *argv[])
delete bs3;
return 0;
}
+19 -21
View File
@@ -19,11 +19,12 @@
#include <boost/archive/xml_oarchive.hpp>
namespace boost {
namespace archive {
namespace detail {
template<class Archive> class interface_oarchive;
} // namespace detail
} // namespace archive
namespace archive {
namespace detail {
template<class Archive> class interface_oarchive;
} // namespace detail
} // namespace archive
} // boost
/////////////////////////////////////////////////////////////////////////
// log data to an output stream. This illustrates a simpler implemenation
@@ -43,34 +44,31 @@ class log_archive :
// Override functions defined in basic_xml_oarchive
// Anything not an attribute and not a name-value pair is an
// error and should be trapped here. Note the usage of
// function argument matching (BOOST_PFTO) to permit usage
// with compilers which fail to properly support
// function template ordering
// error and should be trapped here.
template<class T>
void save_override(T & t, BOOST_PFTO int){
void save_override(T & t){
// make it a name-value pair and pass it on.
// this permits this to be used even with data types which
// are not wrapped with the name
base::save_override(boost::serialization::make_nvp(NULL, t), 0);
base::save_override(boost::serialization::make_nvp(NULL, t));
}
template<class T>
void save_override(const boost::serialization::nvp< T > & t, int){
void save_override(const boost::serialization::nvp< T > & t){
// this is here to remove the "const" requirement. Since
// this class is to be used only for output, it's not required.
base::save_override(t, 0);
base::save_override(t);
}
// specific overrides for attributes - not name value pairs so we
// want to trap them before the above "fall through"
// since we don't want to see these in the output - make them no-ops.
void save_override(const boost::archive::object_id_type & t, int){}
void save_override(const boost::archive::object_reference_type & t, int){}
void save_override(const boost::archive::version_type & t, int){}
void save_override(const boost::archive::class_id_type & t, int){}
void save_override(const boost::archive::class_id_optional_type & t, int){}
void save_override(const boost::archive::class_id_reference_type & t, int){}
void save_override(const boost::archive::class_name_type & t, int){}
void save_override(const boost::archive::tracking_type & t, int){}
void save_override(const boost::archive::object_id_type & t){}
void save_override(const boost::archive::object_reference_type & t){}
void save_override(const boost::archive::version_type & t){}
void save_override(const boost::archive::class_id_type & t){}
void save_override(const boost::archive::class_id_optional_type & t){}
void save_override(const boost::archive::class_id_reference_type & t){}
void save_override(const boost::archive::class_name_type & t){}
void save_override(const boost::archive::tracking_type & t){}
public:
log_archive(std::ostream & os, unsigned int flags = 0) :
boost::archive::xml_oarchive_impl<log_archive>(
-1
View File
@@ -13,7 +13,6 @@
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#include <boost/serialization/pfto.hpp>
#include <boost/static_assert.hpp>
#include <climits>
+3 -3
View File
@@ -47,7 +47,7 @@ portable_binary_iarchive::load_impl(boost::intmax_t & l, char maxsize){
#else
if(m_flags & endian_big)
#endif
reverse_bytes(size, cptr);
reverse_bytes(size, cptr);
if(negative)
l = -l;
@@ -55,11 +55,11 @@ portable_binary_iarchive::load_impl(boost::intmax_t & l, char maxsize){
void
portable_binary_iarchive::load_override(
boost::archive::class_name_type & t, int
boost::archive::class_name_type & t
){
std::string cn;
cn.reserve(BOOST_SERIALIZATION_MAX_KEY_SIZE);
load_override(cn, 0);
load_override(cn);
if(cn.size() > (BOOST_SERIALIZATION_MAX_KEY_SIZE - 1))
boost::serialization::throw_exception(
boost::archive::archive_exception(
+4 -10
View File
@@ -148,21 +148,15 @@ protected:
void load(unsigned char & t){
this->primitive_base_t::load(t);
}
// intermediate level to support override of operators
// fot templates in the absence of partial function
// template ordering
typedef boost::archive::detail::common_iarchive<portable_binary_iarchive>
detail_common_iarchive;
template<class T>
void load_override(T & t, BOOST_PFTO int){
this->detail_common_iarchive::load_override(t, 0);
void load_override(T & t){
this->detail_common_iarchive::load_override(t);
}
void load_override(boost::archive::class_name_type & t, int);
void load_override(boost::archive::class_name_type & t);
// binary files don't include the optional information
void load_override(
boost::archive::class_id_optional_type & /* t */,
int
){}
void load_override(boost::archive::class_id_optional_type &){}
void init(unsigned int flags);
public:
+4 -5
View File
@@ -131,18 +131,17 @@ protected:
typedef boost::archive::detail::common_oarchive<portable_binary_oarchive>
detail_common_oarchive;
template<class T>
void save_override(T & t, BOOST_PFTO int){
this->detail_common_oarchive::save_override(t, 0);
void save_override(T & t){
this->detail_common_oarchive::save_override(t);
}
// explicitly convert to char * to avoid compile ambiguities
void save_override(const boost::archive::class_name_type & t, int){
void save_override(const boost::archive::class_name_type & t){
const std::string s(t);
* this << s;
}
// binary files don't include the optional information
void save_override(
const boost::archive::class_id_optional_type & /* t */,
int
const boost::archive::class_id_optional_type & /* t */
){}
void init(unsigned int flags);
-55
View File
@@ -1,55 +0,0 @@
#ifndef BOOST_ARCHIVE_ADD_FACET_HPP
#define BOOST_ARCHIVE_ADD_FACET_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// add_facet.hpp
// (C) Copyright 2003 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.
#include <locale>
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
// does STLport uses native STL for locales?
#if (defined(__SGI_STL_PORT)&& defined(_STLP_NO_OWN_IOSTREAMS))
// and this native STL lib is old Dinkumware (has not defined _CPPLIB_VER)
# if (defined(_YVALS) && !defined(__IBMCPP__)) || !defined(_CPPLIB_VER)
# define BOOST_ARCHIVE_OLD_DINKUMWARE_BENEATH_STLPORT
# endif
#endif
namespace boost {
namespace archive {
template<class Facet>
inline std::locale *
add_facet(const std::locale &l, Facet * f){
return
#if defined BOOST_ARCHIVE_OLD_DINKUMWARE_BENEATH_STLPORT
// std namespace used for native locale
new std::locale(std::_Addfac(l, f));
#elif BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) // old Dinkumwar
// std namespace used for native locale
new std::locale(std::_Addfac(l, f));
#else
// standard compatible
new std::locale(l, f);
#endif
}
} // namespace archive
} // namespace boost
#undef BOOST_ARCHIVE_OLD_DINKUMWARE_BENEATH_STLPORT
#endif // BOOST_ARCHIVE_ADD_FACET_HPP
+13 -12
View File
@@ -21,7 +21,6 @@
#include <string>
#include <boost/config.hpp>
#include <boost/preprocessor/empty.hpp>
#include <boost/archive/detail/decl.hpp>
// note: the only reason this is in here is that windows header
@@ -40,11 +39,16 @@ namespace archive {
//////////////////////////////////////////////////////////////////////
// exceptions thrown by archives
//
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) archive_exception :
class BOOST_SYMBOL_VISIBLE archive_exception :
public virtual std::exception
{
protected:
private:
char m_buffer[128];
protected:
BOOST_ARCHIVE_DECL unsigned int
append(unsigned int l, const char * a);
BOOST_ARCHIVE_DECL
archive_exception() BOOST_NOEXCEPT;
public:
typedef enum {
no_exception, // initialized without code
@@ -76,19 +80,16 @@ public:
// type has been instantiated in more than one module.
output_stream_error // error on input stream
} exception_code;
public:
exception_code code;
archive_exception(
BOOST_ARCHIVE_DECL archive_exception(
exception_code c,
const char * e1 = NULL,
const char * e2 = NULL
);
virtual ~archive_exception() throw();
virtual const char *what() const throw();
protected:
unsigned int
append(unsigned int l, const char * a);
archive_exception();
) BOOST_NOEXCEPT;
BOOST_ARCHIVE_DECL archive_exception(archive_exception const &) BOOST_NOEXCEPT ;
virtual BOOST_ARCHIVE_DECL ~archive_exception() BOOST_NOEXCEPT_OR_NOTHROW ;
virtual BOOST_ARCHIVE_DECL const char * what() const BOOST_NOEXCEPT_OR_NOTHROW ;
};
}// namespace archive
+2 -2
View File
@@ -69,7 +69,7 @@ public:
}
};
BOOST_ARCHIVE_DECL(library_version_type)
BOOST_ARCHIVE_DECL library_version_type
BOOST_ARCHIVE_VERSION();
class version_type {
@@ -242,7 +242,7 @@ enum archive_flags {
flags_last = 8
};
BOOST_ARCHIVE_DECL(const char *)
BOOST_ARCHIVE_DECL const char *
BOOST_ARCHIVE_SIGNATURE();
/* NOTE : Warning : Warning : Warning : Warning : Warning
+17 -41
View File
@@ -25,7 +25,6 @@
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/serialization/pfto.hpp>
#include <boost/archive/basic_archive.hpp>
#include <boost/archive/detail/common_iarchive.hpp>
@@ -51,7 +50,7 @@ namespace detail {
/////////////////////////////////////////////////////////////////////////
// class basic_binary_iarchive - read serialized objects from a input binary stream
template<class Archive>
class basic_binary_iarchive :
class BOOST_SYMBOL_VISIBLE basic_binary_iarchive :
public detail::common_iarchive<Archive>
{
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
@@ -72,8 +71,8 @@ protected:
// note extra nonsense to sneak it pass the borland compiers
typedef detail::common_iarchive<Archive> detail_common_iarchive;
template<class T>
void load_override(T & t, BOOST_PFTO int version){
this->detail_common_iarchive::load_override(t, static_cast<int>(version));
void load_override(T & t){
this->detail_common_iarchive::load_override(t);
}
// include these to trap a change in binary format which
@@ -86,7 +85,7 @@ protected:
BOOST_STATIC_ASSERT(sizeof(object_reference_type) == sizeof(uint_least32_t));
// binary files don't include the optional information
void load_override(class_id_optional_type & /* t */, int){}
void load_override(class_id_optional_type & /* t */){}
void load_override(tracking_type & t, int /*version*/){
library_version_type lvt = this->get_library_version();
@@ -101,10 +100,10 @@ protected:
t = boost::archive::tracking_type(x);
}
}
void load_override(class_id_type & t, int version){
void load_override(class_id_type & t){
library_version_type lvt = this->get_library_version();
if(boost::archive::library_version_type(7) < lvt){
this->detail_common_iarchive::load_override(t, version);
this->detail_common_iarchive::load_override(t);
}
else
if(boost::archive::library_version_type(6) < lvt){
@@ -118,37 +117,14 @@ protected:
t = boost::archive::class_id_type(x);
}
}
void load_override(class_id_reference_type & t, int version){
load_override(static_cast<class_id_type &>(t), version);
void load_override(class_id_reference_type & t){
load_override(static_cast<class_id_type &>(t));
}
#if 0
void load_override(class_id_reference_type & t, int version){
library_version_type lvt = this->get_library_version();
if(boost::archive::library_version_type(7) < lvt){
this->detail_common_iarchive::load_override(t, version);
}
else
if(boost::archive::library_version_type(6) < lvt){
int_least16_t x=0;
* this->This() >> x;
t = boost::archive::class_id_reference_type(
boost::archive::class_id_type(x)
);
}
else{
int x=0;
* this->This() >> x;
t = boost::archive::class_id_reference_type(
boost::archive::class_id_type(x)
);
}
}
#endif
void load_override(version_type & t, int version){
void load_override(version_type & t){
library_version_type lvt = this->get_library_version();
if(boost::archive::library_version_type(7) < lvt){
this->detail_common_iarchive::load_override(t, version);
this->detail_common_iarchive::load_override(t);
}
else
if(boost::archive::library_version_type(6) < lvt){
@@ -176,11 +152,11 @@ protected:
}
}
void load_override(boost::serialization::item_version_type & t, int version){
void load_override(boost::serialization::item_version_type & t){
library_version_type lvt = this->get_library_version();
// if(boost::archive::library_version_type(7) < lvt){
if(boost::archive::library_version_type(6) < lvt){
this->detail_common_iarchive::load_override(t, version);
this->detail_common_iarchive::load_override(t);
}
else
if(boost::archive::library_version_type(6) < lvt){
@@ -195,9 +171,9 @@ protected:
}
}
void load_override(serialization::collection_size_type & t, int version){
void load_override(serialization::collection_size_type & t){
if(boost::archive::library_version_type(5) < this->get_library_version()){
this->detail_common_iarchive::load_override(t, version);
this->detail_common_iarchive::load_override(t);
}
else{
unsigned int x=0;
@@ -206,9 +182,9 @@ protected:
}
}
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
load_override(class_name_type & t, int);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load_override(class_name_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
init();
basic_binary_iarchive(unsigned int flags) :
@@ -44,16 +44,16 @@ namespace std{
#endif
#include <boost/cstdint.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/serialization/throw_exception.hpp>
#include <boost/integer.hpp>
#include <boost/integer_traits.hpp>
#include <boost/mpl/placeholders.hpp>
//#include <boost/mpl/placeholders.hpp>
#include <boost/serialization/is_bitwise_serializable.hpp>
#include <boost/serialization/array.hpp>
#include <boost/archive/basic_streambuf_locale_saver.hpp>
#include <boost/archive/codecvt_null.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/archive/detail/auto_link_archive.hpp>
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
@@ -61,14 +61,10 @@ namespace std{
namespace boost {
namespace archive {
template<class Ch>
class codecvt_null;
/////////////////////////////////////////////////////////////////////////////
// class binary_iarchive - read serialized objects from a input binary stream
template<class Archive, class Elem, class Tr>
class basic_binary_iprimitive
{
class BOOST_SYMBOL_VISIBLE basic_binary_iprimitive {
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
friend class load_access;
protected:
@@ -82,9 +78,16 @@ public:
}
#ifndef BOOST_NO_STD_LOCALE
boost::scoped_ptr<codecvt_null<Elem> > codecvt_facet;
boost::scoped_ptr<std::locale> archive_locale;
// note order! - if you change this, libstd++ will fail!
// a) create new locale with new codecvt facet
// b) save current locale
// c) change locale to new one
// d) use stream buffer
// e) change locale back to original
// f) destroy new codecvt facet
boost::archive::codecvt_null<Elem> codecvt_null_facet;
basic_streambuf_locale_saver<Elem, Tr> locale_saver;
std::locale archive_locale;
#endif
// main template for serilization of primitive types
@@ -103,25 +106,25 @@ public:
BOOST_ASSERT(0 == i || 1 == i);
(void)i; // warning suppression for release builds.
}
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load(std::string &s);
#ifndef BOOST_NO_STD_WSTRING
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load(std::wstring &ws);
#endif
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load(char * t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load(wchar_t * t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
init();
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_binary_iprimitive(
std::basic_streambuf<Elem, Tr> & sb,
bool no_codecvt
);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
~basic_binary_iprimitive();
public:
// we provide an optimized load for all fundamental types
@@ -140,7 +143,7 @@ public:
// the optimized load_array dispatches to load_binary
template <class ValueType>
void load_array(serialization::array<ValueType>& a, unsigned int)
void load_array(serialization::array_wrapper<ValueType>& a, unsigned int)
{
load_binary(a.address(),a.count()*sizeof(ValueType));
}
+16 -17
View File
@@ -26,7 +26,6 @@
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/serialization/pfto.hpp>
#include <boost/integer.hpp>
#include <boost/integer_traits.hpp>
@@ -59,8 +58,8 @@ namespace detail {
// does have the virtue of buiding the smalles archive in the minimum amount
// of time. So under some circumstances it may be he right choice.
template<class Archive>
class basic_binary_oarchive :
public archive::detail::common_oarchive<Archive>
class BOOST_SYMBOL_VISIBLE basic_binary_oarchive :
public detail::common_oarchive<Archive>
{
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
public:
@@ -77,8 +76,8 @@ protected:
// any datatype not specifed below will be handled by base class
typedef detail::common_oarchive<Archive> detail_common_oarchive;
template<class T>
void save_override(const T & t, BOOST_PFTO int version){
this->detail_common_oarchive::save_override(t, static_cast<int>(version));
void save_override(const T & t){
this->detail_common_oarchive::save_override(t);
}
// include these to trap a change in binary format which
@@ -92,14 +91,14 @@ protected:
BOOST_STATIC_ASSERT(sizeof(object_reference_type) == sizeof(uint_least32_t));
// binary files don't include the optional information
void save_override(const class_id_optional_type & /* t */, int){}
void save_override(const class_id_optional_type & /* t */){}
// enable this if we decide to support generation of previous versions
#if 0
void save_override(const boost::archive::version_type & t, int version){
void save_override(const boost::archive::version_type & t){
library_version_type lvt = this->get_library_version();
if(boost::archive::library_version_type(7) < lvt){
this->detail_common_oarchive::save_override(t, version);
this->detail_common_oarchive::save_override(t);
}
else
if(boost::archive::library_version_type(6) < lvt){
@@ -111,10 +110,10 @@ protected:
* this->This() << x;
}
}
void save_override(const boost::serialization::item_version_type & t, int version){
void save_override(const boost::serialization::item_version_type & t){
library_version_type lvt = this->get_library_version();
if(boost::archive::library_version_type(7) < lvt){
this->detail_common_oarchive::save_override(t, version);
this->detail_common_oarchive::save_override(t);
}
else
if(boost::archive::library_version_type(6) < lvt){
@@ -127,10 +126,10 @@ protected:
}
}
void save_override(class_id_type & t, int version){
void save_override(class_id_type & t){
library_version_type lvt = this->get_library_version();
if(boost::archive::library_version_type(7) < lvt){
this->detail_common_oarchive::save_override(t, version);
this->detail_common_oarchive::save_override(t);
}
else
if(boost::archive::library_version_type(6) < lvt){
@@ -142,20 +141,20 @@ protected:
* this->This() << x;
}
}
void save_override(class_id_reference_type & t, int version){
save_override(static_cast<class_id_type &>(t), version);
void save_override(class_id_reference_type & t){
save_override(static_cast<class_id_type &>(t));
}
#endif
// explicitly convert to char * to avoid compile ambiguities
void save_override(const class_name_type & t, int){
void save_override(const class_name_type & t){
const std::string s(t);
* this->This() << s;
}
#if 0
void save_override(const serialization::collection_size_type & t, int){
void save_override(const serialization::collection_size_type & t){
if (get_library_version() < boost::archive::library_version_type(6)){
unsigned int x=0;
* this->This() >> x;
@@ -166,7 +165,7 @@ protected:
}
}
#endif
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
init();
basic_binary_oarchive(unsigned int flags) :
@@ -43,25 +43,24 @@ namespace std{
#include <boost/scoped_ptr.hpp>
#include <boost/serialization/throw_exception.hpp>
#include <boost/archive/basic_streambuf_locale_saver.hpp>
#include <boost/archive/archive_exception.hpp>
//#include <boost/mpl/placeholders.hpp>
#include <boost/serialization/is_bitwise_serializable.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/serialization/array.hpp>
#include <boost/archive/basic_streambuf_locale_saver.hpp>
#include <boost/archive/codecvt_null.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/archive/detail/auto_link_archive.hpp>
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
namespace boost {
namespace archive {
template<class Ch>
class codecvt_null;
/////////////////////////////////////////////////////////////////////////
// class basic_binary_oprimitive - binary output of prmitives
template<class Archive, class Elem, class Tr>
class basic_binary_oprimitive {
class BOOST_SYMBOL_VISIBLE basic_binary_oprimitive {
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
friend class save_access;
protected:
@@ -74,9 +73,16 @@ public:
return static_cast<Archive *>(this);
}
#ifndef BOOST_NO_STD_LOCALE
boost::scoped_ptr<codecvt_null<Elem> > codecvt_facet;
boost::scoped_ptr<std::locale> archive_locale;
// note order! - if you change this, libstd++ will fail!
// a) create new locale with new codecvt facet
// b) save current locale
// c) change locale to new one
// d) use stream buffer
// e) change locale back to original
// f) destroy new codecvt facet
boost::archive::codecvt_null<Elem> codecvt_null_facet;
basic_streambuf_locale_saver<Elem, Tr> locale_saver;
std::locale archive_locale;
#endif
// default saving of primitives.
template<class T>
@@ -94,26 +100,26 @@ public:
BOOST_ASSERT(0 == static_cast<int>(t) || 1 == static_cast<int>(t));
save_binary(& t, sizeof(t));
}
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save(const std::string &s);
#ifndef BOOST_NO_STD_WSTRING
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save(const std::wstring &ws);
#endif
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save(const char * t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save(const wchar_t * t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
init();
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_binary_oprimitive(
std::basic_streambuf<Elem, Tr> & sb,
bool no_codecvt
);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
~basic_binary_oprimitive();
public:
@@ -131,11 +137,10 @@ public:
struct apply : public boost::serialization::is_bitwise_serializable< T > {};
#endif
};
// the optimized save_array dispatches to save_binary
template <class ValueType>
void save_array(boost::serialization::array<ValueType> const& a, unsigned int)
void save_array(boost::serialization::array_wrapper<ValueType> const& a, unsigned int)
{
save_binary(a.address(),a.count()*sizeof(ValueType));
}
@@ -149,9 +154,7 @@ basic_binary_oprimitive<Archive, Elem, Tr>::save_binary(
const void *address,
std::size_t count
){
//BOOST_ASSERT(
// static_cast<std::size_t>((std::numeric_limits<std::streamsize>::max)()) >= count
//);
// BOOST_ASSERT(count <= std::size_t(boost::integer_traits<std::streamsize>::const_max));
// note: if the following assertions fail
// a likely cause is that the output stream is set to "text"
// mode where by cr characters recieve special treatment.
@@ -161,9 +164,7 @@ basic_binary_oprimitive<Archive, Elem, Tr>::save_binary(
// archive_exception(archive_exception::output_stream_error)
// );
// figure number of elements to output - round up
count = ( count + sizeof(Elem) - 1)
/ sizeof(Elem);
BOOST_ASSERT(count <= std::size_t(boost::integer_traits<std::streamsize>::const_max));
count = ( count + sizeof(Elem) - 1) / sizeof(Elem);
std::streamsize scount = m_sb.sputn(
static_cast<const Elem *>(address),
static_cast<std::streamsize>(count)
@@ -27,6 +27,7 @@
#ifndef BOOST_NO_STD_LOCALE
#include <locale> // for std::locale
#include <ios>
#include <streambuf> // for std::basic_streambuf
#include <boost/config.hpp>
@@ -45,25 +46,57 @@ class basic_streambuf_locale_saver :
private boost::noncopyable
{
public:
typedef ::std::basic_streambuf<Ch, Tr> state_type;
typedef ::std::locale aspect_type;
explicit basic_streambuf_locale_saver( state_type &s )
: s_save_( s ), a_save_( s.getloc() )
{}
explicit basic_streambuf_locale_saver( state_type &s, aspect_type const &a )
: s_save_( s ), a_save_( s.pubimbue(a) )
{}
~basic_streambuf_locale_saver()
{ this->restore(); }
void restore(){
s_save_.pubsync();
s_save_.pubimbue( a_save_ );
explicit basic_streambuf_locale_saver(std::basic_streambuf<Ch, Tr> &s) :
m_streambuf(s),
m_locale(s.getloc())
{}
~basic_streambuf_locale_saver(){
m_streambuf.pubsync();
m_streambuf.pubimbue(m_locale);
}
private:
state_type & s_save_;
aspect_type const a_save_;
std::basic_streambuf<Ch, Tr> & m_streambuf;
std::locale const m_locale;
};
template < typename Ch, class Tr >
class basic_istream_locale_saver :
private boost::noncopyable
{
public:
explicit basic_istream_locale_saver(std::basic_istream<Ch, Tr> &s) :
m_istream(s),
m_locale(s.getloc())
{}
~basic_istream_locale_saver(){
// libstdc++ crashes without this
m_istream.sync();
m_istream.imbue(m_locale);
}
private:
std::basic_istream<Ch, Tr> & m_istream;
std::locale const m_locale;
};
template < typename Ch, class Tr >
class basic_ostream_locale_saver :
private boost::noncopyable
{
public:
explicit basic_ostream_locale_saver(std::basic_ostream<Ch, Tr> &s) :
m_ostream(s),
m_locale(s.getloc())
{}
~basic_ostream_locale_saver(){
m_ostream.flush();
m_ostream.imbue(m_locale);
}
private:
std::basic_ostream<Ch, Tr> & m_ostream;
std::locale const m_locale;
};
} // archive
} // boost
@@ -25,7 +25,6 @@
// use two template parameters
#include <boost/config.hpp>
#include <boost/serialization/pfto.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/archive/detail/common_iarchive.hpp>
@@ -47,7 +46,7 @@ namespace detail {
/////////////////////////////////////////////////////////////////////////
// class basic_text_iarchive - read serialized objects from a input text stream
template<class Archive>
class basic_text_iarchive :
class BOOST_SYMBOL_VISIBLE basic_text_iarchive :
public detail::common_iarchive<Archive>
{
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
@@ -67,16 +66,16 @@ protected:
// template ordering
typedef detail::common_iarchive<Archive> detail_common_iarchive;
template<class T>
void load_override(T & t, BOOST_PFTO int){
this->detail_common_iarchive::load_override(t, 0);
void load_override(T & t){
this->detail_common_iarchive::load_override(t);
}
// text file don't include the optional information
void load_override(class_id_optional_type & /*t*/, int){}
void load_override(class_id_optional_type & /*t*/){}
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
load_override(class_name_type & t, int);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load_override(class_name_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
init(void);
basic_text_iarchive(unsigned int flags) :
+19 -14
View File
@@ -24,7 +24,6 @@
// in such cases. So we can't use basic_ostream<IStream::char_type> but rather
// use two template parameters
#include <boost/assert.hpp>
#include <locale>
#include <cstddef> // size_t
@@ -38,17 +37,15 @@ namespace std{
} // namespace std
#endif
#include <boost/io/ios_state.hpp>
#include <boost/static_assert.hpp>
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
#include <boost/archive/dinkumware.hpp>
#endif
#include <boost/limits.hpp>
#include <boost/io/ios_state.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/static_assert.hpp>
#include <boost/serialization/throw_exception.hpp>
#include <boost/archive/codecvt_null.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/archive/basic_streambuf_locale_saver.hpp>
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
@@ -64,16 +61,24 @@ namespace archive {
#endif
template<class IStream>
class basic_text_iprimitive {
class BOOST_SYMBOL_VISIBLE basic_text_iprimitive {
protected:
IStream &is;
io::ios_flags_saver flags_saver;
io::ios_precision_saver precision_saver;
#ifndef BOOST_NO_STD_LOCALE
boost::scoped_ptr<std::locale> archive_locale;
basic_streambuf_locale_saver<
typename IStream::char_type,
// note order! - if you change this, libstd++ will fail!
// a) create new locale with new codecvt facet
// b) save current locale
// c) change locale to new one
// d) use stream buffer
// e) change locale back to original
// f) destroy new codecvt facet
boost::archive::codecvt_null<typename IStream::char_type> codecvt_null_facet;
std::locale archive_locale;
basic_istream_locale_saver<
typename IStream::char_type,
typename IStream::traits_type
> locale_saver;
#endif
@@ -116,12 +121,12 @@ protected:
t = i;
}
#endif
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_text_iprimitive(IStream &is, bool no_codecvt);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
~basic_text_iprimitive();
public:
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load_binary(void *address, std::size_t count);
};
+9 -10
View File
@@ -25,7 +25,6 @@
// use two template parameters
#include <boost/config.hpp>
#include <boost/serialization/pfto.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/archive/detail/common_oarchive.hpp>
#include <boost/serialization/string.hpp>
@@ -47,7 +46,7 @@ namespace detail {
/////////////////////////////////////////////////////////////////////////
// class basic_text_oarchive
template<class Archive>
class basic_text_oarchive :
class BOOST_SYMBOL_VISIBLE basic_text_oarchive :
public detail::common_oarchive<Archive>
{
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
@@ -69,7 +68,7 @@ protected:
space
} delimiter;
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
newtoken();
void newline(){
@@ -80,25 +79,25 @@ protected:
// extra stuff to get it passed borland compilers
typedef detail::common_oarchive<Archive> detail_common_oarchive;
template<class T>
void save_override(T & t, BOOST_PFTO int){
this->detail_common_oarchive::save_override(t, 0);
void save_override(T & t){
this->detail_common_oarchive::save_override(t);
}
// start new objects on a new line
void save_override(const object_id_type & t, int){
void save_override(const object_id_type & t){
this->This()->newline();
this->detail_common_oarchive::save_override(t, 0);
this->detail_common_oarchive::save_override(t);
}
// text file don't include the optional information
void save_override(const class_id_optional_type & /* t */, int){}
void save_override(const class_id_optional_type & /* t */){}
void save_override(const class_name_type & t, int){
void save_override(const class_name_type & t){
const std::string s(t);
* this->This() << s;
}
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
init();
basic_text_oarchive(unsigned int flags) :
+18 -13
View File
@@ -26,14 +26,13 @@
#include <iomanip>
#include <locale>
#include <boost/assert.hpp>
#include <cstddef> // size_t
#include <boost/config.hpp>
#include <boost/static_assert.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/io/ios_state.hpp>
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
#include <boost/archive/dinkumware.hpp>
#endif
@@ -52,10 +51,10 @@ namespace std{
#include <boost/limits.hpp>
#include <boost/integer.hpp>
#include <boost/io/ios_state.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/serialization/throw_exception.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/archive/basic_streambuf_locale_saver.hpp>
#include <boost/archive/codecvt_null.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
namespace boost {
@@ -64,7 +63,7 @@ namespace archive {
/////////////////////////////////////////////////////////////////////////
// class basic_text_oprimitive - output of prmitives to stream
template<class OStream>
class basic_text_oprimitive
class BOOST_SYMBOL_VISIBLE basic_text_oprimitive
{
protected:
OStream &os;
@@ -72,9 +71,17 @@ protected:
io::ios_precision_saver precision_saver;
#ifndef BOOST_NO_STD_LOCALE
boost::scoped_ptr<std::locale> archive_locale;
basic_streambuf_locale_saver<
typename OStream::char_type,
// note order! - if you change this, libstd++ will fail!
// a) create new locale with new codecvt facet
// b) save current locale
// c) change locale to new one
// d) use stream buffer
// e) change locale back to original
// f) destroy new codecvt facet
boost::archive::codecvt_null<typename OStream::char_type> codecvt_null_facet;
std::locale archive_locale;
basic_ostream_locale_saver<
typename OStream::char_type,
typename OStream::traits_type
> locale_saver;
#endif
@@ -168,15 +175,13 @@ protected:
template<class T>
void save(const T & t){
boost::io::ios_flags_saver fs(os);
boost::io::ios_precision_saver ps(os);
typename is_float<T>::type tf;
save_impl(t, tf);
}
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_text_oprimitive(OStream & os, bool no_codecvt);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
~basic_text_oprimitive();
public:
// unformatted append of one character
@@ -192,7 +197,7 @@ public:
while('\0' != *s)
os.put(*s++);
}
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_binary(const void *address, std::size_t count);
};
+8 -8
View File
@@ -27,35 +27,35 @@ namespace archive {
// constant strings used in xml i/o
extern
BOOST_ARCHIVE_DECL(const char *)
BOOST_ARCHIVE_DECL const char *
BOOST_ARCHIVE_XML_OBJECT_ID();
extern
BOOST_ARCHIVE_DECL(const char *)
BOOST_ARCHIVE_DECL const char *
BOOST_ARCHIVE_XML_OBJECT_REFERENCE();
extern
BOOST_ARCHIVE_DECL(const char *)
BOOST_ARCHIVE_DECL const char *
BOOST_ARCHIVE_XML_CLASS_ID();
extern
BOOST_ARCHIVE_DECL(const char *)
BOOST_ARCHIVE_DECL const char *
BOOST_ARCHIVE_XML_CLASS_ID_REFERENCE();
extern
BOOST_ARCHIVE_DECL(const char *)
BOOST_ARCHIVE_DECL const char *
BOOST_ARCHIVE_XML_CLASS_NAME();
extern
BOOST_ARCHIVE_DECL(const char *)
BOOST_ARCHIVE_DECL const char *
BOOST_ARCHIVE_XML_TRACKING();
extern
BOOST_ARCHIVE_DECL(const char *)
BOOST_ARCHIVE_DECL const char *
BOOST_ARCHIVE_XML_VERSION();
extern
BOOST_ARCHIVE_DECL(const char *)
BOOST_ARCHIVE_DECL const char *
BOOST_ARCHIVE_XML_SIGNATURE();
}// namespace archive
+24 -37
View File
@@ -17,16 +17,12 @@
// See http://www.boost.org for updates, documentation, and revision history.
#include <boost/config.hpp>
#include <boost/serialization/pfto.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/archive/detail/common_iarchive.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/string.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
#ifdef BOOST_MSVC
@@ -42,39 +38,33 @@ namespace detail {
} // namespace detail
/////////////////////////////////////////////////////////////////////////
// class xml_iarchive - read serialized objects from a input text stream
// class basic_xml_iarchive - read serialized objects from a input text stream
template<class Archive>
class basic_xml_iarchive :
class BOOST_SYMBOL_VISIBLE basic_xml_iarchive :
public detail::common_iarchive<Archive>
{
unsigned int depth;
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
public:
#else
protected:
#if BOOST_WORKAROUND(BOOST_MSVC, < 1500)
// for some inexplicable reason insertion of "class" generates compile erro
// on msvc 7.1
friend detail::interface_iarchive<Archive>;
#else
friend class detail::interface_iarchive<Archive>;
#endif
friend class detail::interface_iarchive<Archive>;
#endif
unsigned int depth;
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load_start(const char *name);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load_end(const char *name);
// Anything not an attribute and not a name-value pair is an
// should be trapped here.
template<class T>
void load_override(T & t, BOOST_PFTO int)
void load_override(T & t)
{
// If your program fails to compile here, its most likely due to
// not specifying an nvp wrapper around the variable to
// be serialized.
BOOST_MPL_ASSERT((serialization::is_wrapper< T >));
this->detail_common_iarchive::load_override(t, 0);
this->detail_common_iarchive::load_override(t);
}
// Anything not an attribute - see below - should be a name value
@@ -82,14 +72,10 @@ protected:
typedef detail::common_iarchive<Archive> detail_common_iarchive;
template<class T>
void load_override(
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
const
#endif
boost::serialization::nvp< T > & t,
int
const boost::serialization::nvp< T > & t
){
this->This()->load_start(t.name());
this->detail_common_iarchive::load_override(t.value(), 0);
this->detail_common_iarchive::load_override(t.value());
this->This()->load_end(t.name());
}
@@ -101,23 +87,24 @@ protected:
// an xml archive. So we can skip it here. Note: we MUST override
// it otherwise it will be loaded as a normal primitive w/o tag and
// leaving the archive in an undetermined state
void load_override(class_id_optional_type & /* t */, int){}
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
load_override(object_id_type & t, int);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
load_override(version_type & t, int);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
load_override(class_id_type & t, int);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
load_override(tracking_type & t, int);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load_override(class_id_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load_override(class_id_optional_type & /* t */){}
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load_override(object_id_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load_override(version_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load_override(tracking_type & t);
// class_name_type can't be handled here as it depends upon the
// char type used by the stream. So require the derived implementation
// handle this.
// void load_override(class_name_type & t, int);
// void load_override(class_name_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_xml_iarchive(unsigned int flags);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
~basic_xml_iarchive();
};
+35 -49
View File
@@ -18,16 +18,11 @@
#include <boost/config.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/serialization/pfto.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/archive/detail/common_oarchive.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/tracking.hpp>
#include <boost/serialization/string.hpp>
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
#ifdef BOOST_MSVC
@@ -45,98 +40,89 @@ namespace detail {
//////////////////////////////////////////////////////////////////////
// class basic_xml_oarchive - write serialized objects to a xml output stream
template<class Archive>
class basic_xml_oarchive :
class BOOST_SYMBOL_VISIBLE basic_xml_oarchive :
public detail::common_oarchive<Archive>
{
// special stuff for xml output
unsigned int depth;
bool pending_preamble;
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
public:
#else
protected:
#endif
#if BOOST_WORKAROUND(BOOST_MSVC, < 1500)
// for some inexplicable reason insertion of "class" generates compile erro
// on msvc 7.1
friend detail::interface_oarchive<Archive>;
#else
friend class detail::interface_oarchive<Archive>;
#endif
friend class save_access;
// special stuff for xml output
unsigned int depth;
bool indent_next;
bool pending_preamble;
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
indent();
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
init();
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
windup();
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
write_attribute(
const char *attribute_name,
int t,
const char *conjunction = "=\""
);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
write_attribute(
const char *attribute_name,
const char *key
);
// helpers used below
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_start(const char *name);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_end(const char *name);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
end_preamble();
// Anything not an attribute and not a name-value pair is an
// error and should be trapped here.
template<class T>
void save_override(T & t, BOOST_PFTO int)
void save_override(T & t)
{
// If your program fails to compile here, its most likely due to
// not specifying an nvp wrapper around the variable to
// be serialized.
BOOST_MPL_ASSERT((serialization::is_wrapper< T >));
this->detail_common_oarchive::save_override(t, 0);
this->detail_common_oarchive::save_override(t);
}
// special treatment for name-value pairs.
typedef detail::common_oarchive<Archive> detail_common_oarchive;
template<class T>
void save_override(
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
const
#endif
::boost::serialization::nvp< T > & t,
int
const ::boost::serialization::nvp< T > & t
){
this->This()->save_start(t.name());
this->detail_common_oarchive::save_override(t.const_value(), 0);
this->detail_common_oarchive::save_override(t.const_value());
this->This()->save_end(t.name());
}
// specific overrides for attributes - not name value pairs so we
// want to trap them before the above "fall through"
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
save_override(const object_id_type & t, int);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
save_override(const object_reference_type & t, int);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
save_override(const version_type & t, int);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
save_override(const class_id_type & t, int);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
save_override(const class_id_optional_type & t, int);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
save_override(const class_id_reference_type & t, int);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
save_override(const class_name_type & t, int);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
save_override(const tracking_type & t, int);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_override(const class_id_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_override(const class_id_optional_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_override(const class_id_reference_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_override(const object_id_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_override(const object_reference_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_override(const version_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_override(const class_name_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_override(const tracking_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_xml_oarchive(unsigned int flags);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
~basic_xml_oarchive();
};
+1 -1
View File
@@ -31,7 +31,7 @@ namespace archive {
// do not derive from this class. If you want to extend this functionality
// via inhertance, derived from binary_iarchive_impl instead. This will
// preserve correct static polymorphism.
class binary_iarchive :
class BOOST_SYMBOL_VISIBLE binary_iarchive :
public binary_iarchive_impl<
boost::archive::binary_iarchive,
std::istream::char_type,
@@ -17,7 +17,6 @@
// See http://www.boost.org for updates, documentation, and revision history.
#include <istream>
#include <boost/serialization/pfto.hpp>
#include <boost/archive/basic_binary_iprimitive.hpp>
#include <boost/archive/basic_binary_iarchive.hpp>
@@ -34,7 +33,7 @@ namespace detail {
} // namespace detail
template<class Archive, class Elem, class Tr>
class binary_iarchive_impl :
class BOOST_SYMBOL_VISIBLE binary_iarchive_impl :
public basic_binary_iprimitive<Archive, Elem, Tr>,
public basic_binary_iarchive<Archive>
{
@@ -54,16 +53,14 @@ protected:
friend class load_access;
#endif
#endif
// note: the following should not needed - but one compiler (vc 7.1)
// fails to compile one test (test_shared_ptr) without it !!!
// make this protected so it can be called from a derived archive
template<class T>
void load_override(T & t, BOOST_PFTO int){
this->basic_binary_iarchive<Archive>::load_override(t, 0L);
void load_override(T & t){
this->basic_binary_iarchive<Archive>::load_override(t);
}
void init(unsigned int flags){
if(0 != (flags & no_header))
if(0 != (flags & no_header)){
return;
}
#if ! defined(__MWERKS__)
this->basic_binary_iarchive<Archive>::init();
this->basic_binary_iprimitive<Archive, Elem, Tr>::init();
+1 -1
View File
@@ -32,7 +32,7 @@ namespace archive {
// do not derive from this class. If you want to extend this functionality
// via inhertance, derived from binary_oarchive_impl instead. This will
// preserve correct static polymorphism.
class binary_oarchive :
class BOOST_SYMBOL_VISIBLE binary_oarchive :
public binary_oarchive_impl<
binary_oarchive, std::ostream::char_type, std::ostream::traits_type
>
@@ -18,7 +18,6 @@
#include <ostream>
#include <boost/config.hpp>
#include <boost/serialization/pfto.hpp>
#include <boost/archive/basic_binary_oprimitive.hpp>
#include <boost/archive/basic_binary_oarchive.hpp>
@@ -35,7 +34,7 @@ namespace detail {
} // namespace detail
template<class Archive, class Elem, class Tr>
class binary_oarchive_impl :
class BOOST_SYMBOL_VISIBLE binary_oarchive_impl :
public basic_binary_oprimitive<Archive, Elem, Tr>,
public basic_binary_oarchive<Archive>
{
@@ -55,16 +54,14 @@ protected:
friend class save_access;
#endif
#endif
// note: the following should not needed - but one compiler (vc 7.1)
// fails to compile one test (test_shared_ptr) without it !!!
// make this protected so it can be called from a derived archive
template<class T>
void save_override(T & t, BOOST_PFTO int){
this->basic_binary_oarchive<Archive>::save_override(t, 0L);
void save_override(T & t){
this->basic_binary_oarchive<Archive>::save_override(t);
}
void init(unsigned int flags) {
if(0 != (flags & no_header))
if(0 != (flags & no_header)){
return;
}
#if ! defined(__MWERKS__)
this->basic_binary_oarchive<Archive>::init();
this->basic_binary_oprimitive<Archive, Elem, Tr>::init();
+5 -3
View File
@@ -56,12 +56,13 @@ public:
explicit codecvt_null(std::size_t no_locale_manage = 0) :
std::codecvt<char, char, std::mbstate_t>(no_locale_manage)
{}
virtual ~codecvt_null(){};
};
template<>
class codecvt_null<wchar_t> : public std::codecvt<wchar_t, char, std::mbstate_t>
class BOOST_SYMBOL_VISIBLE codecvt_null<wchar_t> : public std::codecvt<wchar_t, char, std::mbstate_t>
{
virtual BOOST_WARCHIVE_DECL(std::codecvt_base::result)
virtual BOOST_WARCHIVE_DECL std::codecvt_base::result
do_out(
std::mbstate_t & state,
const wchar_t * first1,
@@ -71,7 +72,7 @@ class codecvt_null<wchar_t> : public std::codecvt<wchar_t, char, std::mbstate_t>
char * last2,
char * & next2
) const;
virtual BOOST_WARCHIVE_DECL(std::codecvt_base::result)
virtual BOOST_WARCHIVE_DECL std::codecvt_base::result
do_in(
std::mbstate_t & state,
const char * first1,
@@ -91,6 +92,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(){};
};
} // namespace archive
@@ -14,7 +14,3 @@
# pragma warning(disable : 4251 4231 4660 4275)
#endif
#if defined( __BORLANDC__ )
#pragma nopushoptwarn
#endif
@@ -13,7 +13,3 @@
#endif
#include <boost/config/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
#if defined( __BORLANDC__ )
#pragma nopushoptwarn
#endif
@@ -36,12 +36,11 @@ namespace detail {
class basic_serializer;
template<class Archive>
class BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
archive_serializer_map {
class BOOST_SYMBOL_VISIBLE archive_serializer_map {
public:
static bool insert(const basic_serializer * bs);
static void erase(const basic_serializer * bs);
static const basic_serializer * find(
static BOOST_ARCHIVE_OR_WARCHIVE_DECL bool insert(const basic_serializer * bs);
static BOOST_ARCHIVE_OR_WARCHIVE_DECL void erase(const basic_serializer * bs);
static BOOST_ARCHIVE_OR_WARCHIVE_DECL const basic_serializer * find(
const boost::serialization::extended_type_info & type_
);
};
@@ -1,45 +0,0 @@
#ifndef BOOST_ARCHIVE_DETAIL_BASIC_ARCHIVE_IMPL_HPP
#define BOOST_ARCHIVE_DETAIL_BASIC_ARCHIVE_IMPL_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_archive_impl.hpp:
// (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)
// See http://www.boost.org for updates, documentation, and revision history.
#include <set>
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
namespace boost {
namespace serialization {
class extended_type_info;
} // namespace serialization
namespace archive {
namespace detail {
//////////////////////////////////////////////////////////////////////
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_archive_impl
{
};
} // namespace detail
} // namespace serialization
} // namespace boost
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
#endif //BOOST_ARCHIVE_DETAIL_BASIC_ARCHIVE_IMPL_HPP
@@ -1,45 +0,0 @@
#ifndef BOOST_ARCHIVE_DETAIL_BASIC_CONFIG_HPP
#define BOOST_ARCHIVE_DETAIL_BASIC_CONFIG_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
// basic_config.hpp ---------------------------------------------//
// (c) Copyright Robert Ramey 2004
// 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 library home page at http://www.boost.org/libs/serialization
//----------------------------------------------------------------------------//
// This header implements separate compilation features as described in
// http://www.boost.org/more/separate_compilation.html
#include <boost/config.hpp>
#ifdef BOOST_HAS_DECLSPEC // defined in config system
// we need to import/export our code only if the user has specifically
// asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost
// libraries to be dynamically linked, or BOOST_ARCHIVE_DYN_LINK
// if they want just this one to be dynamically linked:
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_ARCHIVE_DYN_LINK)
// export if this is our own source, otherwise import:
#ifdef BOOST_ARCHIVE_SOURCE
# define BOOST_ARCHIVE_DECL __declspec(dllexport)
#else
# define BOOST_ARCHIVE_DECL __declspec(dllimport)
#endif // BOOST_ARCHIVE_SOURCE
#endif // DYN_LINK
#endif // BOOST_HAS_DECLSPEC
//
// if BOOST_ARCHIVE_DECL isn't defined yet define it now:
#ifndef BOOST_ARCHIVE_DECL
#define BOOST_ARCHIVE_DECL
#endif
#endif // BOOST_ARCHIVE_DETAIL_BASIC_CONFIG_HPP
+21 -19
View File
@@ -37,11 +37,12 @@ namespace archive {
namespace detail {
class basic_iarchive_impl;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iserializer;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_iserializer;
class basic_iserializer;
class basic_pointer_iserializer;
//////////////////////////////////////////////////////////////////////
// class basic_iarchive - read serialized objects from a input stream
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iarchive :
class BOOST_SYMBOL_VISIBLE basic_iarchive :
private boost::noncopyable,
public boost::archive::detail::helper_collection
{
@@ -56,41 +57,42 @@ class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iarchive :
virtual void vload(class_name_type &t) = 0;
virtual void vload(tracking_type &t) = 0;
protected:
basic_iarchive(unsigned int flags);
BOOST_ARCHIVE_DECL basic_iarchive(unsigned int flags);
boost::archive::detail::helper_collection &
get_helper_collection(){
return *this;
}
public:
// account for bogus gcc warning
#if defined(__GNUC__)
virtual
#endif
~basic_iarchive();
// some msvc versions require that the following function be public
// otherwise it should really protected.
virtual BOOST_ARCHIVE_DECL ~basic_iarchive();
// note: NOT part of the public API.
void next_object_pointer(void *t);
void register_basic_serializer(
BOOST_ARCHIVE_DECL void next_object_pointer(void *t);
BOOST_ARCHIVE_DECL void register_basic_serializer(
const basic_iserializer & bis
);
void load_object(
BOOST_ARCHIVE_DECL void load_object(
void *t,
const basic_iserializer & bis
);
const basic_pointer_iserializer *
BOOST_ARCHIVE_DECL const basic_pointer_iserializer *
load_pointer(
void * & t,
const basic_pointer_iserializer * bpis_ptr,
const basic_pointer_iserializer * (*finder)(
const boost::serialization::extended_type_info & eti
)
);
// real public API starts here
void
BOOST_ARCHIVE_DECL void
set_library_version(library_version_type archive_library_version);
library_version_type
BOOST_ARCHIVE_DECL library_version_type
get_library_version() const;
unsigned int
BOOST_ARCHIVE_DECL unsigned int
get_flags() const;
void
BOOST_ARCHIVE_DECL void
reset_object_address(const void * new_address, const void * old_address);
void
BOOST_ARCHIVE_DECL void
delete_created_pointers();
};
@@ -39,23 +39,19 @@ namespace serialization {
namespace archive {
namespace detail {
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iarchive;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_iserializer;
class basic_iarchive;
class basic_pointer_iserializer;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iserializer :
class BOOST_SYMBOL_VISIBLE basic_iserializer :
public basic_serializer
{
private:
basic_pointer_iserializer *m_bpis;
protected:
explicit basic_iserializer(
explicit BOOST_ARCHIVE_DECL basic_iserializer(
const boost::serialization::extended_type_info & type
);
// account for bogus gcc warning
#if defined(__GNUC__)
virtual
#endif
~basic_iserializer();
virtual BOOST_ARCHIVE_DECL ~basic_iserializer();
public:
bool serialized_as_pointer() const {
return m_bpis != NULL;
+13 -15
View File
@@ -35,12 +35,12 @@ namespace archive {
namespace detail {
class basic_oarchive_impl;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oserializer;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_oserializer;
class basic_oserializer;
class basic_pointer_oserializer;
//////////////////////////////////////////////////////////////////////
// class basic_oarchive - write serialized objects to an output stream
class BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oarchive :
class BOOST_SYMBOL_VISIBLE basic_oarchive :
private boost::noncopyable,
public boost::archive::detail::helper_collection
{
@@ -59,22 +59,20 @@ class BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oarchive :
virtual void vsave(const class_name_type & t) = 0;
virtual void vsave(const tracking_type t) = 0;
protected:
basic_oarchive(unsigned int flags = 0);
// account for bogus gcc warning
#if defined(__GNUC__)
virtual
#endif
~basic_oarchive();
BOOST_ARCHIVE_DECL basic_oarchive(unsigned int flags = 0);
BOOST_ARCHIVE_DECL boost::archive::detail::helper_collection &
get_helper_collection();
virtual BOOST_ARCHIVE_DECL ~basic_oarchive();
public:
// note: NOT part of the public interface
void register_basic_serializer(
BOOST_ARCHIVE_DECL void register_basic_serializer(
const basic_oserializer & bos
);
void save_object(
BOOST_ARCHIVE_DECL void save_object(
const void *x,
const basic_oserializer & bos
);
void save_pointer(
BOOST_ARCHIVE_DECL void save_pointer(
const void * t,
const basic_pointer_oserializer * bpos_ptr
);
@@ -82,9 +80,9 @@ public:
vsave(NULL_POINTER_TAG);
}
// real public interface starts here
void end_preamble(); // default implementation does nothing
library_version_type get_library_version() const;
unsigned int get_flags() const;
BOOST_ARCHIVE_DECL void end_preamble(); // default implementation does nothing
BOOST_ARCHIVE_DECL library_version_type get_library_version() const;
BOOST_ARCHIVE_DECL unsigned int get_flags() const;
};
} // namespace detail
@@ -40,23 +40,19 @@ namespace serialization {
namespace archive {
namespace detail {
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oarchive;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_oserializer;
class basic_oarchive;
class basic_pointer_oserializer;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oserializer :
class BOOST_SYMBOL_VISIBLE basic_oserializer :
public basic_serializer
{
private:
basic_pointer_oserializer *m_bpos;
protected:
explicit basic_oserializer(
explicit BOOST_ARCHIVE_DECL basic_oserializer(
const boost::serialization::extended_type_info & type_
);
// account for bogus gcc warning
#if defined(__GNUC__)
virtual
#endif
~basic_oserializer();
virtual BOOST_ARCHIVE_DECL ~basic_oserializer();
public:
bool serialized_as_pointer() const {
return m_bpos != NULL;
@@ -37,20 +37,16 @@ namespace serialization {
namespace archive {
namespace detail {
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iarchive;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iserializer;
class basic_iarchive;
class basic_iserializer;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_iserializer
class BOOST_SYMBOL_VISIBLE basic_pointer_iserializer
: public basic_serializer {
protected:
explicit basic_pointer_iserializer(
explicit BOOST_ARCHIVE_DECL basic_pointer_iserializer(
const boost::serialization::extended_type_info & type_
);
// account for bogus gcc warning
#if defined(__GNUC__)
virtual
#endif
~basic_pointer_iserializer();
virtual BOOST_ARCHIVE_DECL ~basic_pointer_iserializer();
public:
virtual void * heap_allocation() const = 0;
virtual const basic_iserializer & get_basic_serializer() const = 0;
@@ -36,22 +36,18 @@ namespace serialization {
namespace archive {
namespace detail {
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oarchive;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oserializer;
class basic_oarchive;
class basic_oserializer;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_oserializer :
class BOOST_SYMBOL_VISIBLE basic_pointer_oserializer :
public basic_serializer
{
protected:
explicit basic_pointer_oserializer(
explicit BOOST_ARCHIVE_DECL basic_pointer_oserializer(
const boost::serialization::extended_type_info & type_
);
public:
// account for bogus gcc warning
#if defined(__GNUC__)
virtual
#endif
~basic_pointer_oserializer();
virtual BOOST_ARCHIVE_DECL ~basic_pointer_oserializer();
virtual const basic_oserializer & get_basic_serializer() const = 0;
virtual void save_object_ptr(
basic_oarchive & ar,
@@ -41,9 +41,7 @@ protected:
const boost::serialization::extended_type_info & eti
) :
m_eti(& eti)
{
BOOST_ASSERT(NULL != & eti);
}
{}
public:
inline bool
operator<(const basic_serializer & rhs) const {
@@ -34,7 +34,7 @@ namespace detail {
class basic_serializer;
class BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
class BOOST_SYMBOL_VISIBLE
basic_serializer_map : public
boost::noncopyable
{
@@ -50,9 +50,9 @@ basic_serializer_map : public
> map_type;
map_type m_map;
public:
bool insert(const basic_serializer * bs);
void erase(const basic_serializer * bs);
const basic_serializer * find(
BOOST_ARCHIVE_DECL bool insert(const basic_serializer * bs);
BOOST_ARCHIVE_DECL void erase(const basic_serializer * bs);
BOOST_ARCHIVE_DECL const basic_serializer * find(
const boost::serialization::extended_type_info & type_
) const;
private:
@@ -35,7 +35,7 @@ class extended_type_info;
// note: referred to as Curiously Recurring Template Patter (CRTP)
template<class Archive>
class common_iarchive :
class BOOST_SYMBOL_VISIBLE common_iarchive :
public basic_iarchive,
public interface_iarchive<Archive>
{
@@ -62,7 +62,7 @@ private:
protected:
// default processing - invoke serialization library
template<class T>
void load_override(T & t, BOOST_PFTO int){
void load_override(T & t){
archive::load(* this->This(), t);
}
// default implementations of functions which emit start/end tags for
@@ -32,7 +32,8 @@ namespace detail {
// note: referred to as Curiously Recurring Template Patter (CRTP)
template<class Archive>
class common_oarchive :
class BOOST_SYMBOL_VISIBLE common_oarchive :
public basic_oarchive,
public interface_oarchive<Archive>
{
@@ -65,7 +66,7 @@ private:
protected:
// default processing - invoke serialization library
template<class T>
void save_override(T & t, BOOST_PFTO int){
void save_override(T & t){
archive::save(* this->This(), t);
}
void save_start(const char * /*name*/){}
+22 -44
View File
@@ -22,58 +22,36 @@
// http://www.boost.org/more/separate_compilation.html
#include <boost/config.hpp>
#include <boost/preprocessor/facilities/empty.hpp>
#if defined(BOOST_HAS_DECLSPEC)
#if (defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SERIALIZATION_DYN_LINK))
#if defined(BOOST_ARCHIVE_SOURCE)
#if defined(__BORLANDC__)
#define BOOST_ARCHIVE_DECL(T) T __export
#define BOOST_ARCHIVE_OR_WARCHIVE_DECL(T) T __export
#else
#define BOOST_ARCHIVE_DECL(T) __declspec(dllexport) T
#define BOOST_ARCHIVE_OR_WARCHIVE_DECL(T) __declspec(dllexport) T
#endif
#else
#if defined(__BORLANDC__)
#define BOOST_ARCHIVE_DECL(T) T __import
#else
#define BOOST_ARCHIVE_DECL(T) __declspec(dllimport) T
#endif
#endif
#if defined(BOOST_WARCHIVE_SOURCE)
#if defined(__BORLANDC__)
#define BOOST_WARCHIVE_DECL(T) T __export
#define BOOST_ARCHIVE_OR_WARCHIVE_DECL(T) T __export
#else
#define BOOST_WARCHIVE_DECL(T) __declspec(dllexport) T
#define BOOST_ARCHIVE_OR_WARCHIVE_DECL(T) __declspec(dllexport) T
#endif
#else
#if defined(__BORLANDC__)
#define BOOST_WARCHIVE_DECL(T) T __import
#else
#define BOOST_WARCHIVE_DECL(T) __declspec(dllimport) T
#endif
#endif
#if !defined(BOOST_WARCHIVE_SOURCE) && !defined(BOOST_ARCHIVE_SOURCE)
#if defined(__BORLANDC__)
#define BOOST_ARCHIVE_OR_WARCHIVE_DECL(T) T __import
#else
#define BOOST_ARCHIVE_OR_WARCHIVE_DECL(T) __declspec(dllimport) T
#endif
#endif
#if (defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SERIALIZATION_DYN_LINK))
#if defined(BOOST_ARCHIVE_SOURCE)
#define BOOST_ARCHIVE_DECL BOOST_SYMBOL_EXPORT
#else
#define BOOST_ARCHIVE_DECL BOOST_SYMBOL_IMPORT
#endif
#endif // BOOST_HAS_DECLSPEC
#if defined(BOOST_WARCHIVE_SOURCE)
#define BOOST_WARCHIVE_DECL BOOST_SYMBOL_EXPORT
#else
#define BOOST_WARCHIVE_DECL BOOST_SYMBOL_IMPORT
#endif
#if defined(BOOST_WARCHIVE_SOURCE) || defined(BOOST_ARCHIVE_SOURCE)
#define BOOST_ARCHIVE_OR_WARCHIVE_DECL BOOST_SYMBOL_EXPORT
#else
#define BOOST_ARCHIVE_OR_WARCHIVE_DECL BOOST_SYMBOL_IMPORT
#endif
#endif
#if ! defined(BOOST_ARCHIVE_DECL)
#define BOOST_ARCHIVE_DECL(T) T
#define BOOST_ARCHIVE_DECL
#endif
#if ! defined(BOOST_WARCHIVE_DECL)
#define BOOST_WARCHIVE_DECL(T) T
#define BOOST_WARCHIVE_DECL
#endif
#if ! defined(BOOST_ARCHIVE_OR_WARCHIVE_DECL)
#define BOOST_ARCHIVE_OR_WARCHIVE_DECL(T) T
#define BOOST_ARCHIVE_OR_WARCHIVE_DECL
#endif
#endif // BOOST_ARCHIVE_DETAIL_DECL_HPP
@@ -55,11 +55,12 @@ class helper_collection
collection m_collection;
struct predicate {
BOOST_DELETED_FUNCTION(predicate & operator=(const predicate & rhs))
public:
const void * const m_ti;
bool operator()(helper_value_type const &rhs) const {
return m_ti == rhs.first;
}
predicate & operator=(const void * ti); // to suppress warning
predicate(const void * ti) :
m_ti(ti)
{}
@@ -69,7 +70,7 @@ protected:
~helper_collection(){}
public:
template<typename Helper>
Helper& get_helper(void * const id = 0) {
Helper& find_helper(void * const id = 0) {
collection::const_iterator it =
std::find_if(
m_collection.begin(),
@@ -20,6 +20,7 @@
#include <boost/mpl/bool.hpp>
#include <boost/archive/detail/auto_link_archive.hpp>
#include <boost/archive/detail/iserializer.hpp>
#include <boost/archive/detail/helper_collection.hpp>
#include <boost/serialization/singleton.hpp>
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
@@ -27,7 +28,7 @@ namespace boost {
namespace archive {
namespace detail {
class BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_iserializer;
class basic_pointer_iserializer;
template<class Archive>
class interface_iarchive
@@ -55,9 +56,16 @@ public:
this->This()->register_basic_serializer(bpis.get_basic_serializer());
return & bpis;
}
template<class Helper>
Helper &
get_helper(void * const id = 0){
helper_collection & hc = this->This()->get_helper_collection();
return hc.template find_helper<Helper>(id);
}
template<class T>
Archive & operator>>(T & t){
this->This()->load_override(t, 0);
this->This()->load_override(t);
return * this->This();
}
@@ -29,7 +29,7 @@ namespace boost {
namespace archive {
namespace detail {
class BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_oserializer;
class basic_pointer_oserializer;
template<class Archive>
class interface_oarchive
@@ -57,21 +57,24 @@ public:
this->This()->register_basic_serializer(bpos.get_basic_serializer());
return & bpos;
}
template<class Helper>
Helper &
get_helper(void * const id = 0){
helper_collection & hc = this->This()->get_helper_collection();
return hc.template find_helper<Helper>(id);
}
template<class T>
Archive & operator<<(T & t){
this->This()->save_override(t, 0);
Archive & operator<<(const T & t){
this->This()->save_override(t);
return * this->This();
}
// the & operator
template<class T>
Archive & operator&(T & t){
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
return * this->This() << const_cast<const T &>(t);
#else
return * this->This() << t;
#endif
Archive & operator&(const T & t){
return * this ->This() << t;
}
};
+26 -53
View File
@@ -39,7 +39,6 @@ namespace std{
#include <boost/mpl/identity.hpp>
#include <boost/mpl/greater_equal.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/core/no_exceptions_support.hpp>
#ifndef BOOST_SERIALIZATION_DEFAULT_TYPE_INFO
@@ -57,11 +56,16 @@ namespace std{
#include <boost/type_traits/is_polymorphic.hpp>
#include <boost/serialization/assume_abstract.hpp>
#define DONT_USE_HAS_NEW_OPERATOR ( \
defined(__BORLANDC__) \
|| BOOST_WORKAROUND(__IBMCPP__, < 1210) \
|| defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x590) \
)
#ifndef BOOST_MSVC
#define DONT_USE_HAS_NEW_OPERATOR ( \
BOOST_WORKAROUND(__IBMCPP__, < 1210) \
|| defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x590) \
)
#else
#define DONT_USE_HAS_NEW_OPERATOR 0
#endif
#if ! DONT_USE_HAS_NEW_OPERATOR
#include <boost/type_traits/has_new_operator.hpp>
#endif
@@ -224,17 +228,13 @@ struct heap_allocation {
static void invoke_delete(T * t) {
// if compilation fails here, the likely cause that the class
// T has a class specific new operator but no class specific
// delete operator which matches the following signature. Fix
// your program to have this. Note that adding operator delete
// with only one parameter doesn't seem correct to me since
// the standard(3.7.4.2) says "
// "If a class T has a member deallocation function named
// 'operator delete' with exactly one parameter, then that function
// is a usual (non-placement) deallocation function" which I take
// to mean that it will call the destructor of type T which we don't
// want to do here.
// Note: reliance upon automatic conversion from T * to void * here
(T::operator delete)(t, sizeof(T));
// delete operator which matches the following signature.
// note that this solution addresses the issue that two
// possible signatures. But it doesn't address the possibility
// that the class might have class specific new with NO
// class specific delete at all. Patches (compatible with
// C++03) welcome!
delete t;
}
};
struct doesnt_have_new_operator {
@@ -243,7 +243,7 @@ struct heap_allocation {
}
static void invoke_delete(T * t) {
// Note: I'm reliance upon automatic conversion from T * to void * here
(operator delete)(t);
delete t;
}
};
static T * invoke_new() {
@@ -588,7 +588,14 @@ struct load_array_type {
boost::archive::archive_exception::array_size_too_short
)
);
ar >> serialization::make_array(static_cast<value_type*>(&t[0]),count);
// explict template arguments to pass intel C++ compiler
ar >> serialization::make_array<
value_type,
boost::serialization::collection_size_type
>(
static_cast<value_type *>(&t[0]),
count
);
}
};
@@ -618,40 +625,6 @@ inline void load(Archive & ar, T &t){
typex::invoke(ar, t);
}
#if 0
// BORLAND
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560))
// borland has a couple of problems
// a) if function is partially specialized - see below
// const paramters are transformed to non-const ones
// b) implementation of base_object can't be made to work
// correctly which results in all base_object s being const.
// So, strip off the const for borland. This breaks the trap
// for loading const objects - but I see no alternative
template<class Archive, class T>
inline void load(Archive &ar, const T & t){
load(ar, const_cast<T &>(t));
}
#endif
// let wrappers through.
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template<class Archive, class T>
inline void load_wrapper(Archive &ar, const T&t, mpl::true_){
boost::archive::load(ar, const_cast<T&>(t));
}
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560))
template<class Archive, class T>
inline void load(Archive &ar, const T&t){
load_wrapper(ar,t,serialization::is_wrapper< T >());
}
#endif
#endif
#endif
} // namespace archive
} // namespace boost
+9 -1
View File
@@ -33,6 +33,7 @@
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/greater_equal.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/bool_fwd.hpp>
#ifndef BOOST_SERIALIZATION_DEFAULT_TYPE_INFO
#include <boost/serialization/extended_type_info_typeid.hpp>
@@ -500,7 +501,14 @@ struct save_array_type
);
boost::serialization::collection_size_type count(c);
ar << BOOST_SERIALIZATION_NVP(count);
ar << serialization::make_array(static_cast<value_type const*>(&t[0]),count);
// explict template arguments to pass intel C++ compiler
ar << serialization::make_array<
const value_type,
boost::serialization::collection_size_type
>(
static_cast<const value_type *>(&t[0]),
count
);
}
};
@@ -39,8 +39,8 @@ namespace serialization {
namespace archive {
namespace detail{
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iserializer;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_iserializer;
class basic_iserializer;
class basic_pointer_iserializer;
#ifdef BOOST_MSVC
# pragma warning(push)
@@ -166,10 +166,13 @@ private:
virtual void load_end(const char * name){
ArchiveImplementation::load_end(name);
}
virtual void register_basic_serializer(const basic_iserializer & bis){
ArchiveImplementation::register_basic_serializer(bis);
}
virtual helper_collection &
get_helper_collection(){
return ArchiveImplementation::get_helper_collection();
}
public:
// this can't be inheriteded because they appear in mulitple
// parents
@@ -39,8 +39,8 @@ namespace serialization {
namespace archive {
namespace detail{
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oserializer;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_oserializer;
class basic_oserializer;
class basic_pointer_oserializer;
#ifdef BOOST_MSVC
# pragma warning(push)
@@ -160,6 +160,10 @@ private:
virtual void register_basic_serializer(const detail::basic_oserializer & bos){
ArchiveImplementation::register_basic_serializer(bos);
}
virtual helper_collection &
get_helper_collection(){
return ArchiveImplementation::get_helper_collection();
}
public:
// this can't be inheriteded because they appear in mulitple
// parents
@@ -7,10 +7,17 @@
#ifndef BOOST_ARCHIVE_DETAIL_UTF8_CODECVT_FACET_HPP
#define BOOST_ARCHIVE_DETAIL_UTF8_CODECVT_FACET_HPP
#ifdef BOOST_NO_CXX11_HDR_CODECVT
#include <boost/config.hpp>
// std::codecvt_utf8 doesn't seem to work for msvc
// versions prior to MSVC 14.0
#if defined(_MSC_VER) && _MSC_VER < 1900 \
|| defined( BOOST_NO_CXX11_HDR_CODECVT )
#include <boost/archive/detail/decl.hpp>
#define BOOST_UTF8_BEGIN_NAMESPACE \
namespace boost { namespace archive { namespace detail {
#define BOOST_UTF8_DECL
#define BOOST_UTF8_DECL BOOST_ARCHIVE_DECL
#define BOOST_UTF8_END_NAMESPACE }}}
#include <boost/detail/utf8_codecvt_facet.hpp>
@@ -18,6 +25,10 @@
#undef BOOST_UTF8_END_NAMESPACE
#undef BOOST_UTF8_DECL
#undef BOOST_UTF8_BEGIN_NAMESPACE
#else
#include <codecvt>
namespace boost { namespace archive { namespace detail {
typedef std::codecvt_utf8<wchar_t> utf8_codecvt_facet;
} } }
#endif // BOOST_NO_CXX11_HDR_CODECVT
#endif // BOOST_ARCHIVE_DETAIL_UTF8_CODECVT_FACET_HPP
@@ -37,7 +37,7 @@ namespace extra_detail { // anon
#endif
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(bool)
BOOST_ARCHIVE_OR_WARCHIVE_DECL bool
archive_serializer_map<Archive>::insert(const basic_serializer * bs){
return boost::serialization::singleton<
extra_detail::map<Archive>
@@ -45,7 +45,7 @@ archive_serializer_map<Archive>::insert(const basic_serializer * bs){
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
archive_serializer_map<Archive>::erase(const basic_serializer * bs){
if(boost::serialization::singleton<
extra_detail::map<Archive>
@@ -57,7 +57,7 @@ archive_serializer_map<Archive>::erase(const basic_serializer * bs){
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(const basic_serializer *)
BOOST_ARCHIVE_OR_WARCHIVE_DECL const basic_serializer *
archive_serializer_map<Archive>::find(
const boost::serialization::extended_type_info & eti
) {
@@ -32,11 +32,11 @@ namespace archive {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// implementation of binary_binary_archive
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_binary_iarchive<Archive>::load_override(class_name_type & t, int){
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_iarchive<Archive>::load_override(class_name_type & t){
std::string cn;
cn.reserve(BOOST_SERIALIZATION_MAX_KEY_SIZE);
load_override(cn, 0);
load_override(cn);
if(cn.size() > (BOOST_SERIALIZATION_MAX_KEY_SIZE - 1))
boost::serialization::throw_exception(
archive_exception(archive_exception::invalid_class_name)
@@ -47,8 +47,8 @@ basic_binary_iarchive<Archive>::load_override(class_name_type & t, int){
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_binary_iarchive<Archive>::init(){
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_iarchive<Archive>::init(void){
// read signature in an archive version independent manner
std::string file_signature;
@@ -20,14 +20,9 @@ namespace std{
} // namespace std
#endif
#include <boost/detail/workaround.hpp> // fixup for RogueWave
#include <boost/serialization/throw_exception.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/archive/codecvt_null.hpp>
#include <boost/archive/add_facet.hpp>
#include <boost/archive/basic_binary_iprimitive.hpp>
namespace boost {
@@ -37,7 +32,7 @@ namespace archive {
// implementation of basic_binary_iprimitive
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_iprimitive<Archive, Elem, Tr>::init()
{
// Detect attempts to pass native binary archives across
@@ -90,7 +85,7 @@ basic_binary_iprimitive<Archive, Elem, Tr>::init()
}
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_iprimitive<Archive, Elem, Tr>::load(wchar_t * ws)
{
std::size_t l; // number of wchar_t !!!
@@ -100,7 +95,7 @@ basic_binary_iprimitive<Archive, Elem, Tr>::load(wchar_t * ws)
}
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_iprimitive<Archive, Elem, Tr>::load(std::string & s)
{
std::size_t l;
@@ -117,7 +112,7 @@ basic_binary_iprimitive<Archive, Elem, Tr>::load(std::string & s)
#ifndef BOOST_NO_CWCHAR
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_iprimitive<Archive, Elem, Tr>::load(char * s)
{
std::size_t l;
@@ -129,7 +124,7 @@ basic_binary_iprimitive<Archive, Elem, Tr>::load(char * s)
#ifndef BOOST_NO_STD_WSTRING
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_iprimitive<Archive, Elem, Tr>::load(std::wstring & ws)
{
std::size_t l;
@@ -145,23 +140,20 @@ basic_binary_iprimitive<Archive, Elem, Tr>::load(std::wstring & ws)
#endif
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_binary_iprimitive<Archive, Elem, Tr>::basic_binary_iprimitive(
std::basic_streambuf<Elem, Tr> & sb,
bool no_codecvt
) :
#ifndef BOOST_NO_STD_LOCALE
m_sb(sb),
locale_saver(m_sb)
codecvt_null_facet(1),
locale_saver(m_sb),
archive_locale(sb.getloc(), & codecvt_null_facet)
{
if(! no_codecvt){
archive_locale.reset(
add_facet(
std::locale::classic(),
new codecvt_null<Elem>
)
);
//m_sb.pubimbue(* archive_locale);
m_sb.pubsync();
m_sb.pubimbue(archive_locale);
}
}
#else
@@ -169,42 +161,11 @@ basic_binary_iprimitive<Archive, Elem, Tr>::basic_binary_iprimitive(
{}
#endif
// some libraries including stl and libcomo fail if the
// buffer isn't flushed before the code_cvt facet is changed.
// I think this is a bug. We explicity invoke sync to when
// we're done with the streambuf to work around this problem.
// Note that sync is a protected member of stream buff so we
// have to invoke it through a contrived derived class.
namespace detail {
// note: use "using" to get past msvc bug
using namespace std;
template<class Elem, class Tr>
class input_streambuf_access : public std::basic_streambuf<Elem, Tr> {
public:
virtual int sync(){
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206))
return this->basic_streambuf::sync();
#else
return this->basic_streambuf<Elem, Tr>::sync();
#endif
}
};
} // detail
// scoped_ptr requires that archive_locale be a complete type at time of
// scoped_ptr requires that g be a complete type at time of
// destruction so define destructor here rather than in the header
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
basic_binary_iprimitive<Archive, Elem, Tr>::~basic_binary_iprimitive(){
// push back unread characters
//destructor can't throw !
BOOST_TRY{
static_cast<detail::input_streambuf_access<Elem, Tr> &>(m_sb).sync();
}
BOOST_CATCH(...){
}
BOOST_CATCH_END
}
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_binary_iprimitive<Archive, Elem, Tr>::~basic_binary_iprimitive(){}
} // namespace archive
} // namespace boost
@@ -28,11 +28,7 @@ namespace archive {
// implementation of binary_binary_oarchive
template<class Archive>
#if !defined(__BORLANDC__)
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
#else
void
#endif
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_oarchive<Archive>::init(){
// write signature in an archive version independent manner
const std::string file_signature(BOOST_ARCHIVE_SIGNATURE());
@@ -27,10 +27,6 @@ namespace std{ using ::wcslen; }
#endif
#endif
#include <boost/detail/workaround.hpp>
#include <boost/archive/add_facet.hpp>
#include <boost/archive/codecvt_null.hpp>
#include <boost/archive/basic_binary_oprimitive.hpp>
#include <boost/core/no_exceptions_support.hpp>
@@ -41,7 +37,7 @@ namespace archive {
// implementation of basic_binary_oprimitive
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_oprimitive<Archive, Elem, Tr>::init()
{
// record native sizes of fundamental types
@@ -57,7 +53,7 @@ basic_binary_oprimitive<Archive, Elem, Tr>::init()
}
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_oprimitive<Archive, Elem, Tr>::save(const char * s)
{
std::size_t l = std::strlen(s);
@@ -66,7 +62,7 @@ basic_binary_oprimitive<Archive, Elem, Tr>::save(const char * s)
}
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_oprimitive<Archive, Elem, Tr>::save(const std::string &s)
{
std::size_t l = static_cast<std::size_t>(s.size());
@@ -76,7 +72,7 @@ basic_binary_oprimitive<Archive, Elem, Tr>::save(const std::string &s)
#ifndef BOOST_NO_CWCHAR
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_oprimitive<Archive, Elem, Tr>::save(const wchar_t * ws)
{
std::size_t l = std::wcslen(ws);
@@ -87,7 +83,7 @@ basic_binary_oprimitive<Archive, Elem, Tr>::save(const wchar_t * ws)
#ifndef BOOST_NO_STD_WSTRING
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_binary_oprimitive<Archive, Elem, Tr>::save(const std::wstring &ws)
{
std::size_t l = ws.size();
@@ -97,23 +93,20 @@ basic_binary_oprimitive<Archive, Elem, Tr>::save(const std::wstring &ws)
#endif
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_binary_oprimitive<Archive, Elem, Tr>::basic_binary_oprimitive(
std::basic_streambuf<Elem, Tr> & sb,
bool no_codecvt
) :
#ifndef BOOST_NO_STD_LOCALE
m_sb(sb),
locale_saver(m_sb)
codecvt_null_facet(1),
locale_saver(m_sb),
archive_locale(sb.getloc(), & codecvt_null_facet)
{
if(! no_codecvt){
archive_locale.reset(
add_facet(
std::locale::classic(),
new codecvt_null<Elem>
)
);
//m_sb.pubimbue(* archive_locale);
m_sb.pubsync();
m_sb.pubimbue(archive_locale);
}
}
#else
@@ -121,42 +114,11 @@ basic_binary_oprimitive<Archive, Elem, Tr>::basic_binary_oprimitive(
{}
#endif
// some libraries including stl and libcomo fail if the
// buffer isn't flushed before the code_cvt facet is changed.
// I think this is a bug. We explicity invoke sync to when
// we're done with the streambuf to work around this problem.
// Note that sync is a protected member of stream buff so we
// have to invoke it through a contrived derived class.
namespace detail {
// note: use "using" to get past msvc bug
using namespace std;
template<class Elem, class Tr>
class output_streambuf_access : public std::basic_streambuf<Elem, Tr> {
public:
virtual int sync(){
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206))
return this->basic_streambuf::sync();
#else
return this->basic_streambuf<Elem, Tr>::sync();
#endif
}
};
} // detail
// scoped_ptr requires that g be a complete type at time of
// destruction so define destructor here rather than in the header
template<class Archive, class Elem, class Tr>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
basic_binary_oprimitive<Archive, Elem, Tr>::~basic_binary_oprimitive(){
// flush buffer
//destructor can't throw
BOOST_TRY{
static_cast<detail::output_streambuf_access<Elem, Tr> &>(m_sb).sync();
}
BOOST_CATCH(...){
}
BOOST_CATCH_END
}
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_binary_oprimitive<Archive, Elem, Tr>::~basic_binary_oprimitive(){}
} // namespace archive
} // namespace boost
@@ -29,11 +29,11 @@ namespace archive {
// implementation of text_text_archive
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_text_iarchive<Archive>::load_override(class_name_type & t, int){
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_text_iarchive<Archive>::load_override(class_name_type & t){
std::string cn;
cn.reserve(BOOST_SERIALIZATION_MAX_KEY_SIZE);
load_override(cn, 0);
load_override(cn);
if(cn.size() > (BOOST_SERIALIZATION_MAX_KEY_SIZE - 1))
boost::serialization::throw_exception(
archive_exception(archive_exception::invalid_class_name)
@@ -44,7 +44,7 @@ basic_text_iarchive<Archive>::load_override(class_name_type & t, int){
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_text_iarchive<Archive>::init(void){
// read signature in an archive version independent manner
std::string file_signature;
@@ -8,8 +8,8 @@
// See http://www.boost.org for updates, documentation, and revision history.
#include <cstddef> // size_t
#include <cstddef> // NULL
#include <cstddef> // size_t, NULL
#include <limits> // NULL
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
@@ -19,11 +19,8 @@ namespace std{
#endif
#include <boost/serialization/throw_exception.hpp>
#include <boost/serialization/pfto.hpp>
#include <boost/archive/basic_text_iprimitive.hpp>
#include <boost/archive/codecvt_null.hpp>
#include <boost/archive/add_facet.hpp>
#include <boost/archive/iterators/remove_whitespace.hpp>
#include <boost/archive/iterators/istream_iterator.hpp>
@@ -53,7 +50,7 @@ namespace detail {
// translate base64 text into binary and copy into buffer
// until buffer is full.
template<class IStream>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_text_iprimitive<IStream>::load_binary(
void *address,
std::size_t count
@@ -79,7 +76,7 @@ basic_text_iprimitive<IStream>::load_binary(
iterators::remove_whitespace<
iterators::istream_iterator<CharType>
>
,CharType
,typename IStream::int_type
>
,8
,6
@@ -87,11 +84,7 @@ basic_text_iprimitive<IStream>::load_binary(
>
binary;
binary i = binary(
BOOST_MAKE_PFTO_WRAPPER(
iterators::istream_iterator<CharType>(is)
)
);
binary i = binary(iterators::istream_iterator<CharType>(is));
char * caddr = static_cast<char *>(address);
@@ -112,39 +105,32 @@ basic_text_iprimitive<IStream>::load_binary(
}
template<class IStream>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_text_iprimitive<IStream>::basic_text_iprimitive(
IStream &is_,
bool no_codecvt
) :
#ifndef BOOST_NO_STD_LOCALE
is(is_),
flags_saver(is_),
precision_saver(is_),
locale_saver(* is_.rdbuf())
#ifndef BOOST_NO_STD_LOCALE
codecvt_null_facet(1),
archive_locale(is.getloc(), & codecvt_null_facet),
locale_saver(is)
{
if(! no_codecvt){
archive_locale.reset(
add_facet(
std::locale::classic(),
new boost::archive::codecvt_null<typename IStream::char_type>
)
);
//is.imbue(* archive_locale);
is_.sync();
is_.imbue(archive_locale);
}
is >> std::noboolalpha;
is_ >> std::noboolalpha;
}
#else
is(is_),
flags_saver(is_),
precision_saver(is_)
{}
#endif
template<class IStream>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_text_iprimitive<IStream>::~basic_text_iprimitive(){
is.sync();
}
} // namespace archive
@@ -27,7 +27,7 @@ namespace archive {
// implementation of basic_text_oarchive
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_text_oarchive<Archive>::newtoken()
{
switch(delimiter){
@@ -48,7 +48,7 @@ basic_text_oarchive<Archive>::newtoken()
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_text_oarchive<Archive>::init(){
// write signature in an archive version independent manner
const std::string file_signature(BOOST_ARCHIVE_SIGNATURE());
@@ -10,11 +10,15 @@
#include <cstddef> // NULL
#include <algorithm> // std::copy
#include <boost/serialization/pfto.hpp>
#include <exception> // std::uncaught_exception
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::size_t;
} // namespace std
#endif
#include <boost/archive/basic_text_oprimitive.hpp>
#include <boost/archive/codecvt_null.hpp>
#include <boost/archive/add_facet.hpp>
#include <boost/archive/iterators/base64_from_binary.hpp>
#include <boost/archive/iterators/insert_linebreaks.hpp>
@@ -26,7 +30,7 @@ namespace archive {
// translate to base64 and copy in to buffer.
template<class OStream>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_text_oprimitive<OStream>::save_binary(
const void *address,
std::size_t count
@@ -59,9 +63,9 @@ basic_text_oprimitive<OStream>::save_binary(
boost::archive::iterators::ostream_iterator<CharType> oi(os);
std::copy(
base64_text(BOOST_MAKE_PFTO_WRAPPER(static_cast<const char *>(address))),
base64_text(static_cast<const char *>(address)),
base64_text(
BOOST_MAKE_PFTO_WRAPPER(static_cast<const char *>(address) + count)
static_cast<const char *>(address) + count
),
oi
);
@@ -75,38 +79,35 @@ basic_text_oprimitive<OStream>::save_binary(
}
template<class OStream>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_text_oprimitive<OStream>::basic_text_oprimitive(
OStream & os_,
bool no_codecvt
) :
#ifndef BOOST_NO_STD_LOCALE
os(os_),
flags_saver(os_),
precision_saver(os_),
locale_saver(* os_.rdbuf())
#ifndef BOOST_NO_STD_LOCALE
codecvt_null_facet(1),
archive_locale(os.getloc(), & codecvt_null_facet),
locale_saver(os)
{
if(! no_codecvt){
archive_locale.reset(
add_facet(
std::locale::classic(),
new boost::archive::codecvt_null<typename OStream::char_type>
)
);
//os.imbue(* archive_locale);
os_.flush();
os_.imbue(archive_locale);
}
os << std::noboolalpha;
os_ << std::noboolalpha;
}
#else
os(os_),
flags_saver(os_),
precision_saver(os_)
{}
#endif
template<class OStream>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_text_oprimitive<OStream>::~basic_text_oprimitive(){
if(std::uncaught_exception())
return;
os << std::endl;
}
@@ -72,14 +72,14 @@ public:
friend struct return_values;
private:
typedef BOOST_DEDUCED_TYPENAME std::basic_istream<CharType> IStream;
typedef BOOST_DEDUCED_TYPENAME std::basic_string<CharType> StringType;
typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::chset<CharType> chset_t;
typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::chlit<CharType> chlit_t;
typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::scanner<
BOOST_DEDUCED_TYPENAME std::basic_string<CharType>::iterator
typedef typename std::basic_istream<CharType> IStream;
typedef typename std::basic_string<CharType> StringType;
typedef typename boost::spirit::classic::chset<CharType> chset_t;
typedef typename boost::spirit::classic::chlit<CharType> chlit_t;
typedef typename boost::spirit::classic::scanner<
typename std::basic_string<CharType>::iterator
> scanner_t;
typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::rule<scanner_t> rule_t;
typedef typename boost::spirit::classic::rule<scanner_t> rule_t;
// Start grammar definition
rule_t
Reference,
@@ -163,7 +163,7 @@ public:
bool parse_end_tag(IStream & is) const;
bool parse_string(IStream & is, StringType & s) /*const*/;
void init(IStream & is);
void windup(IStream & is);
bool windup(IStream & is);
basic_xml_grammar();
};
@@ -24,7 +24,7 @@ namespace archive {
// implementation of xml_text_archive
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_iarchive<Archive>::load_start(const char *name){
// if there's no name
if(NULL == name)
@@ -41,7 +41,7 @@ basic_xml_iarchive<Archive>::load_start(const char *name){
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_iarchive<Archive>::load_end(const char *name){
// if there's no name
if(NULL == name)
@@ -77,38 +77,39 @@ basic_xml_iarchive<Archive>::load_end(const char *name){
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_xml_iarchive<Archive>::load_override(object_id_type & t, int){
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_iarchive<Archive>::load_override(object_id_type & t){
t = object_id_type(this->This()->gimpl->rv.object_id);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_xml_iarchive<Archive>::load_override(version_type & t, int){
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_iarchive<Archive>::load_override(version_type & t){
t = version_type(this->This()->gimpl->rv.version);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_xml_iarchive<Archive>::load_override(class_id_type & t, int){
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_iarchive<Archive>::load_override(class_id_type & t){
t = class_id_type(this->This()->gimpl->rv.class_id);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_xml_iarchive<Archive>::load_override(tracking_type & t, int){
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_iarchive<Archive>::load_override(tracking_type & t){
t = this->This()->gimpl->rv.tracking_level;
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_xml_iarchive<Archive>::basic_xml_iarchive(unsigned int flags) :
detail::common_iarchive<Archive>(flags),
depth(0)
{}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
basic_xml_iarchive<Archive>::~basic_xml_iarchive(){}
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_xml_iarchive<Archive>::~basic_xml_iarchive(){
}
} // namespace archive
} // namespace boost
@@ -58,7 +58,7 @@ struct XML_name {
// implemenations of functions common to both types of xml output
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::write_attribute(
const char *attribute_name,
int t,
@@ -72,7 +72,7 @@ basic_xml_oarchive<Archive>::write_attribute(
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::write_attribute(
const char *attribute_name,
const char *key
@@ -85,7 +85,7 @@ basic_xml_oarchive<Archive>::write_attribute(
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::indent(){
int i;
for(i = depth; i-- > 0;)
@@ -93,7 +93,7 @@ basic_xml_oarchive<Archive>::indent(){
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_start(const char *name)
{
if(NULL == name)
@@ -115,7 +115,7 @@ basic_xml_oarchive<Archive>::save_start(const char *name)
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_end(const char *name)
{
if(NULL == name)
@@ -139,7 +139,7 @@ basic_xml_oarchive<Archive>::save_end(const char *name)
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::end_preamble(){
if(pending_preamble){
this->This()->put('>');
@@ -148,14 +148,14 @@ basic_xml_oarchive<Archive>::end_preamble(){
}
#if 0
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_xml_oarchive<Archive>::save_override(const object_id_type & t, int)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(const object_id_type & t)
{
int i = t.t; // extra .t is for borland
write_attribute(BOOST_ARCHIVE_XML_OBJECT_ID(), i, "=\"_");
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(
const object_reference_type & t,
int
@@ -164,8 +164,8 @@ basic_xml_oarchive<Archive>::save_override(
write_attribute(BOOST_ARCHIVE_XML_OBJECT_REFERENCE(), i, "=\"_");
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_xml_oarchive<Archive>::save_override(const version_type & t, int)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(const version_type & t)
{
int i = t.t; // extra .t is for borland
write_attribute(BOOST_ARCHIVE_XML_VERSION(), i);
@@ -173,55 +173,52 @@ basic_xml_oarchive<Archive>::save_override(const version_type & t, int)
#endif
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_xml_oarchive<Archive>::save_override(const object_id_type & t, int)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(const object_id_type & t)
{
// borland doesn't do conversion of STRONG_TYPEDEFs very well
const unsigned int i = t;
write_attribute(BOOST_ARCHIVE_XML_OBJECT_ID(), i, "=\"_");
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(
const object_reference_type & t,
int
const object_reference_type & t
){
const unsigned int i = t;
write_attribute(BOOST_ARCHIVE_XML_OBJECT_REFERENCE(), i, "=\"_");
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_xml_oarchive<Archive>::save_override(const version_type & t, int)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(const version_type & t)
{
const unsigned int i = t;
write_attribute(BOOST_ARCHIVE_XML_VERSION(), i);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_xml_oarchive<Archive>::save_override(const class_id_type & t, int)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(const class_id_type & t)
{
write_attribute(BOOST_ARCHIVE_XML_CLASS_ID(), t);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(
const class_id_reference_type & t,
int
const class_id_reference_type & t
){
write_attribute(BOOST_ARCHIVE_XML_CLASS_ID_REFERENCE(), t);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(
const class_id_optional_type & t,
int
const class_id_optional_type & t
){
write_attribute(BOOST_ARCHIVE_XML_CLASS_ID(), t);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_xml_oarchive<Archive>::save_override(const class_name_type & t, int)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(const class_name_type & t)
{
const char * key = t;
if(NULL == key)
@@ -230,14 +227,14 @@ basic_xml_oarchive<Archive>::save_override(const class_name_type & t, int)
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_xml_oarchive<Archive>::save_override(const tracking_type & t, int)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::save_override(const tracking_type & t)
{
write_attribute(BOOST_ARCHIVE_XML_TRACKING(), t.t);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::init(){
// xml header
this->This()->put("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n");
@@ -250,25 +247,25 @@ basic_xml_oarchive<Archive>::init(){
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
basic_xml_oarchive<Archive>::windup(){
// xml_trailer
this->This()->put("</boost_serialization>\n");
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_xml_oarchive<Archive>::basic_xml_oarchive(unsigned int flags) :
detail::common_oarchive<Archive>(flags),
depth(0),
indent_next(false),
pending_preamble(false)
pending_preamble(false),
indent_next(false)
{
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_xml_oarchive<Archive>::~basic_xml_oarchive(){
if(0 == (this->get_flags() & no_header)){
BOOST_TRY{
this->This()->put("</boost_serialization>\n");
}
BOOST_CATCH(...){}
BOOST_CATCH_END
}
}
} // namespace archive
@@ -28,7 +28,7 @@ namespace boost {
namespace archive {
template<class Archive>
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
text_iarchive_impl<Archive>::load(char *s)
{
std::size_t size;
@@ -41,7 +41,7 @@ text_iarchive_impl<Archive>::load(char *s)
}
template<class Archive>
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
text_iarchive_impl<Archive>::load(std::string &s)
{
std::size_t size;
@@ -60,7 +60,7 @@ text_iarchive_impl<Archive>::load(std::string &s)
#ifndef BOOST_NO_CWCHAR
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template<class Archive>
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
text_iarchive_impl<Archive>::load(wchar_t *ws)
{
std::size_t size;
@@ -74,7 +74,7 @@ text_iarchive_impl<Archive>::load(wchar_t *ws)
#ifndef BOOST_NO_STD_WSTRING
template<class Archive>
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
text_iarchive_impl<Archive>::load(std::wstring &ws)
{
std::size_t size;
@@ -93,19 +93,19 @@ text_iarchive_impl<Archive>::load(std::wstring &ws)
#endif // BOOST_NO_CWCHAR
template<class Archive>
BOOST_ARCHIVE_DECL(void)
text_iarchive_impl<Archive>::load_override(class_name_type & t, int){
basic_text_iarchive<Archive>::load_override(t, 0);
BOOST_ARCHIVE_DECL void
text_iarchive_impl<Archive>::load_override(class_name_type & t){
basic_text_iarchive<Archive>::load_override(t);
}
template<class Archive>
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
text_iarchive_impl<Archive>::init(){
basic_text_iarchive<Archive>::init();
}
template<class Archive>
BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_DECL
text_iarchive_impl<Archive>::text_iarchive_impl(
std::istream & is,
unsigned int flags
@@ -10,7 +10,6 @@
#include <string>
#include <boost/config.hpp>
#include <locale>
#include <cstddef> // size_t
#include <boost/config.hpp>
@@ -27,7 +26,6 @@ namespace std{ using ::wcslen; }
#endif
#endif
#include <boost/archive/add_facet.hpp>
#include <boost/archive/text_oarchive.hpp>
namespace boost {
@@ -38,7 +36,7 @@ namespace archive {
// of template parameters used to create a text_oprimitive
template<class Archive>
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
text_oarchive_impl<Archive>::save(const char * s)
{
const std::size_t len = std::ostream::traits_type::length(s);
@@ -48,7 +46,7 @@ text_oarchive_impl<Archive>::save(const char * s)
}
template<class Archive>
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
text_oarchive_impl<Archive>::save(const std::string &s)
{
const std::size_t size = s.size();
@@ -60,7 +58,7 @@ text_oarchive_impl<Archive>::save(const std::string &s)
#ifndef BOOST_NO_CWCHAR
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template<class Archive>
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
text_oarchive_impl<Archive>::save(const wchar_t * ws)
{
const std::size_t l = std::wcslen(ws);
@@ -72,7 +70,7 @@ text_oarchive_impl<Archive>::save(const wchar_t * ws)
#ifndef BOOST_NO_STD_WSTRING
template<class Archive>
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
text_oarchive_impl<Archive>::save(const std::wstring &ws)
{
const std::size_t l = ws.size();
@@ -84,7 +82,7 @@ text_oarchive_impl<Archive>::save(const std::wstring &ws)
#endif // BOOST_NO_CWCHAR
template<class Archive>
BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_DECL
text_oarchive_impl<Archive>::text_oarchive_impl(
std::ostream & os,
unsigned int flags
@@ -104,7 +102,7 @@ text_oarchive_impl<Archive>::text_oarchive_impl(
}
template<class Archive>
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
text_oarchive_impl<Archive>::save_binary(const void *address, std::size_t count){
put('\n');
this->end_preamble();
@@ -29,7 +29,7 @@ namespace archive {
// implementation of wiprimtives functions
//
template<class Archive>
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
text_wiarchive_impl<Archive>::load(char *s)
{
std::size_t size;
@@ -43,7 +43,7 @@ text_wiarchive_impl<Archive>::load(char *s)
}
template<class Archive>
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
text_wiarchive_impl<Archive>::load(std::string &s)
{
std::size_t size;
@@ -63,7 +63,7 @@ text_wiarchive_impl<Archive>::load(std::string &s)
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template<class Archive>
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
text_wiarchive_impl<Archive>::load(wchar_t *s)
{
std::size_t size;
@@ -78,7 +78,7 @@ text_wiarchive_impl<Archive>::load(wchar_t *s)
#ifndef BOOST_NO_STD_WSTRING
template<class Archive>
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
text_wiarchive_impl<Archive>::load(std::wstring &ws)
{
std::size_t size;
@@ -97,7 +97,7 @@ text_wiarchive_impl<Archive>::load(std::wstring &ws)
#endif
template<class Archive>
BOOST_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_WARCHIVE_DECL
text_wiarchive_impl<Archive>::text_wiarchive_impl(
std::wistream & is,
unsigned int flags
@@ -31,7 +31,7 @@ namespace archive {
// implementation of woarchive functions
//
template<class Archive>
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
text_woarchive_impl<Archive>::save(const char *s)
{
// note: superfluous local variable fixes borland warning
@@ -43,7 +43,7 @@ text_woarchive_impl<Archive>::save(const char *s)
}
template<class Archive>
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
text_woarchive_impl<Archive>::save(const std::string &s)
{
const std::size_t size = s.size();
@@ -56,7 +56,7 @@ text_woarchive_impl<Archive>::save(const std::string &s)
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template<class Archive>
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
text_woarchive_impl<Archive>::save(const wchar_t *ws)
{
const std::size_t size = std::wostream::traits_type::length(ws);
@@ -68,7 +68,7 @@ text_woarchive_impl<Archive>::save(const wchar_t *ws)
#ifndef BOOST_NO_STD_WSTRING
template<class Archive>
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
text_woarchive_impl<Archive>::save(const std::wstring &ws)
{
const std::size_t size = ws.length();
@@ -11,6 +11,8 @@
#include <boost/config.hpp>
#include <cstring> // memcpy
#include <cstddef> // NULL
#include <exception>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::memcpy;
@@ -18,10 +20,11 @@ namespace std{
#endif
#ifndef BOOST_NO_CWCHAR
#include <cstdlib> // mbtowc
#include <cwchar> // mbstate_t and mbrtowc
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::mbtowc;
using ::mbstate_t;
using ::mbrtowc;
} // namespace std
#endif
#endif // BOOST_NO_CWCHAR
@@ -51,7 +54,7 @@ namespace archive {
#ifndef BOOST_NO_CWCHAR
#ifndef BOOST_NO_STD_WSTRING
template<class Archive>
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
xml_iarchive_impl<Archive>::load(std::wstring &ws){
std::string s;
bool result = gimpl->parse_string(is, s);
@@ -63,52 +66,57 @@ xml_iarchive_impl<Archive>::load(std::wstring &ws){
#if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101))
if(NULL != ws.data())
#endif
ws.resize(0);
ws.resize(0);
std::mbstate_t mbs = std::mbstate_t();
const char * start = s.data();
const char * end = start + s.size();
while(start < end){
wchar_t wc;
int resultx = std::mbtowc(&wc, start, end - start);
if(0 < resultx){
start += resultx;
ws += wc;
std::size_t count = std::mbrtowc(&wc, start, end - start, &mbs);
if(count == static_cast<std::size_t>(-1))
boost::serialization::throw_exception(
iterators::dataflow_exception(
iterators::dataflow_exception::invalid_conversion
)
);
if(count == static_cast<std::size_t>(-2))
continue;
}
boost::serialization::throw_exception(
iterators::dataflow_exception(
iterators::dataflow_exception::invalid_conversion
)
);
start += count;
ws += wc;
}
}
#endif // BOOST_NO_STD_WSTRING
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template<class Archive>
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
xml_iarchive_impl<Archive>::load(wchar_t * ws){
std::string s;
bool result = gimpl->parse_string(is, s);
if(! result)
boost::serialization::throw_exception(
xml_archive_exception(xml_archive_exception::xml_archive_parsing_error)
xml_archive_exception(
xml_archive_exception::xml_archive_parsing_error
)
);
std::mbstate_t mbs = std::mbstate_t();
const char * start = s.data();
const char * end = start + s.size();
while(start < end){
wchar_t wc;
int length = std::mbtowc(&wc, start, end - start);
if(0 < length){
start += length;
*ws++ = wc;
std::size_t length = std::mbrtowc(&wc, start, end - start, &mbs);
if(static_cast<std::size_t>(-1) == length)
boost::serialization::throw_exception(
iterators::dataflow_exception(
iterators::dataflow_exception::invalid_conversion
)
);
if(static_cast<std::size_t>(-2) == length)
continue;
}
boost::serialization::throw_exception(
iterators::dataflow_exception(
iterators::dataflow_exception::invalid_conversion
)
);
start += length;
*ws++ = wc;
}
*ws = L'\0';
}
@@ -117,7 +125,7 @@ xml_iarchive_impl<Archive>::load(wchar_t * ws){
#endif // BOOST_NO_CWCHAR
template<class Archive>
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
xml_iarchive_impl<Archive>::load(std::string &s){
bool result = gimpl->parse_string(is, s);
if(! result)
@@ -127,7 +135,7 @@ xml_iarchive_impl<Archive>::load(std::string &s){
}
template<class Archive>
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
xml_iarchive_impl<Archive>::load(char * s){
std::string tstring;
bool result = gimpl->parse_string(is, tstring);
@@ -140,8 +148,8 @@ xml_iarchive_impl<Archive>::load(char * s){
}
template<class Archive>
BOOST_ARCHIVE_DECL(void)
xml_iarchive_impl<Archive>::load_override(class_name_type & t, int){
BOOST_ARCHIVE_DECL void
xml_iarchive_impl<Archive>::load_override(class_name_type & t){
const std::string & s = gimpl->rv.class_name;
if(s.size() > BOOST_SERIALIZATION_MAX_KEY_SIZE - 1)
boost::serialization::throw_exception(
@@ -153,7 +161,7 @@ xml_iarchive_impl<Archive>::load_override(class_name_type & t, int){
}
template<class Archive>
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
xml_iarchive_impl<Archive>::init(){
gimpl->init(is);
this->set_library_version(
@@ -162,7 +170,7 @@ xml_iarchive_impl<Archive>::init(){
}
template<class Archive>
BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_DECL
xml_iarchive_impl<Archive>::xml_iarchive_impl(
std::istream &is_,
unsigned int flags
@@ -179,14 +187,12 @@ xml_iarchive_impl<Archive>::xml_iarchive_impl(
}
template<class Archive>
BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_DECL
xml_iarchive_impl<Archive>::~xml_iarchive_impl(){
if(std::uncaught_exception())
return;
if(0 == (this->get_flags() & no_header)){
BOOST_TRY{
gimpl->windup(is);
}
BOOST_CATCH(...){}
BOOST_CATCH_END
gimpl->windup(is);
}
}
} // namespace archive
@@ -10,6 +10,7 @@
#include <iomanip>
#include <algorithm> // std::copy
#include <string>
#include <exception>
#include <cstring> // strlen
#include <boost/config.hpp> // msvc 6.0 needs this to suppress warnings
@@ -42,15 +43,15 @@ void save_iterator(std::ostream &os, InputIterator begin, InputIterator end){
boost::archive::iterators::xml_escape<InputIterator>
> translator;
std::copy(
translator(BOOST_MAKE_PFTO_WRAPPER(begin)),
translator(BOOST_MAKE_PFTO_WRAPPER(end)),
translator(begin),
translator(end),
boost::archive::iterators::ostream_iterator<char>(os)
);
}
#ifndef BOOST_NO_STD_WSTRING
template<class Archive>
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
xml_oarchive_impl<Archive>::save(const std::wstring & ws){
// at least one library doesn't typedef value_type for strings
// so rather than using string directly make a pointer iterator out of it
@@ -61,7 +62,7 @@ xml_oarchive_impl<Archive>::save(const std::wstring & ws){
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template<class Archive>
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
xml_oarchive_impl<Archive>::save(const wchar_t * ws){
save_iterator(os, ws, ws + std::wcslen(ws));
}
@@ -70,7 +71,7 @@ xml_oarchive_impl<Archive>::save(const wchar_t * ws){
#endif // BOOST_NO_CWCHAR
template<class Archive>
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
xml_oarchive_impl<Archive>::save(const std::string & s){
// at least one library doesn't typedef value_type for strings
// so rather than using string directly make a pointer iterator out of it
@@ -78,27 +79,27 @@ xml_oarchive_impl<Archive>::save(const std::string & s){
const char *
> xml_escape_translator;
std::copy(
xml_escape_translator(BOOST_MAKE_PFTO_WRAPPER(s.data())),
xml_escape_translator(BOOST_MAKE_PFTO_WRAPPER(s.data()+ s.size())),
xml_escape_translator(s.data()),
xml_escape_translator(s.data()+ s.size()),
boost::archive::iterators::ostream_iterator<char>(os)
);
}
template<class Archive>
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
xml_oarchive_impl<Archive>::save(const char * s){
typedef boost::archive::iterators::xml_escape<
const char *
> xml_escape_translator;
std::copy(
xml_escape_translator(BOOST_MAKE_PFTO_WRAPPER(s)),
xml_escape_translator(BOOST_MAKE_PFTO_WRAPPER(s + std::strlen(s))),
xml_escape_translator(s),
xml_escape_translator(s + std::strlen(s)),
boost::archive::iterators::ostream_iterator<char>(os)
);
}
template<class Archive>
BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_DECL
xml_oarchive_impl<Archive>::xml_oarchive_impl(
std::ostream & os_,
unsigned int flags
@@ -113,5 +114,29 @@ xml_oarchive_impl<Archive>::xml_oarchive_impl(
this->init();
}
template<class Archive>
BOOST_ARCHIVE_DECL void
xml_oarchive_impl<Archive>::save_binary(const void *address, std::size_t count){
this->end_preamble();
#if ! defined(__MWERKS__)
this->basic_text_oprimitive<std::ostream>::save_binary(
#else
this->basic_text_oprimitive::save_binary(
#endif
address,
count
);
this->indent_next = true;
}
template<class Archive>
BOOST_ARCHIVE_DECL
xml_oarchive_impl<Archive>::~xml_oarchive_impl(){
if(std::uncaught_exception())
return;
if(0 == (this->get_flags() & no_header))
this->windup();
}
} // namespace archive
} // namespace boost
@@ -20,7 +20,7 @@ namespace std{
#include <boost/assert.hpp>
#include <algorithm> // std::copy
#include <exception> // uncaught exception
#include <boost/detail/workaround.hpp> // Dinkumware and RogueWave
#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
#include <boost/archive/dinkumware.hpp>
@@ -28,17 +28,16 @@ namespace std{
#include <boost/io/ios_state.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <boost/serialization/pfto.hpp>
#include <boost/serialization/string.hpp>
#include <boost/archive/basic_xml_archive.hpp>
#include <boost/archive/xml_wiarchive.hpp>
#include <boost/archive/add_facet.hpp>
#include <boost/archive/xml_archive_exception.hpp>
#include <boost/archive/iterators/mb_from_wchar.hpp>
#include <boost/archive/detail/utf8_codecvt_facet.hpp>
#include "basic_xml_grammar.hpp"
namespace boost {
@@ -52,10 +51,10 @@ namespace { // anonymous
void copy_to_ptr(char * s, const std::wstring & ws){
std::copy(
iterators::mb_from_wchar<std::wstring::const_iterator>(
BOOST_MAKE_PFTO_WRAPPER(ws.begin())
ws.begin()
),
iterators::mb_from_wchar<std::wstring::const_iterator>(
BOOST_MAKE_PFTO_WRAPPER(ws.end())
ws.end()
),
s
);
@@ -65,7 +64,7 @@ void copy_to_ptr(char * s, const std::wstring & ws){
} // anonymous
template<class Archive>
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
xml_wiarchive_impl<Archive>::load(std::string & s){
std::wstring ws;
bool result = gimpl->parse_string(is, ws);
@@ -80,10 +79,10 @@ xml_wiarchive_impl<Archive>::load(std::string & s){
s.reserve(ws.size());
std::copy(
iterators::mb_from_wchar<std::wstring::iterator>(
BOOST_MAKE_PFTO_WRAPPER(ws.begin())
ws.begin()
),
iterators::mb_from_wchar<std::wstring::iterator>(
BOOST_MAKE_PFTO_WRAPPER(ws.end())
ws.end()
),
std::back_inserter(s)
);
@@ -91,7 +90,7 @@ xml_wiarchive_impl<Archive>::load(std::string & s){
#ifndef BOOST_NO_STD_WSTRING
template<class Archive>
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
xml_wiarchive_impl<Archive>::load(std::wstring & ws){
bool result = gimpl->parse_string(is, ws);
if(! result)
@@ -102,7 +101,7 @@ xml_wiarchive_impl<Archive>::load(std::wstring & ws){
#endif
template<class Archive>
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
xml_wiarchive_impl<Archive>::load(char * s){
std::wstring ws;
bool result = gimpl->parse_string(is, ws);
@@ -115,7 +114,7 @@ xml_wiarchive_impl<Archive>::load(char * s){
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template<class Archive>
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
xml_wiarchive_impl<Archive>::load(wchar_t * ws){
std::wstring twstring;
bool result = gimpl->parse_string(is, twstring);
@@ -129,8 +128,8 @@ xml_wiarchive_impl<Archive>::load(wchar_t * ws){
#endif
template<class Archive>
BOOST_WARCHIVE_DECL(void)
xml_wiarchive_impl<Archive>::load_override(class_name_type & t, int){
BOOST_WARCHIVE_DECL void
xml_wiarchive_impl<Archive>::load_override(class_name_type & t){
const std::wstring & ws = gimpl->rv.class_name;
if(ws.size() > BOOST_SERIALIZATION_MAX_KEY_SIZE - 1)
boost::serialization::throw_exception(
@@ -140,7 +139,7 @@ xml_wiarchive_impl<Archive>::load_override(class_name_type & t, int){
}
template<class Archive>
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
xml_wiarchive_impl<Archive>::init(){
gimpl->init(is);
this->set_library_version(
@@ -149,7 +148,7 @@ xml_wiarchive_impl<Archive>::init(){
}
template<class Archive>
BOOST_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_WARCHIVE_DECL
xml_wiarchive_impl<Archive>::xml_wiarchive_impl(
std::wistream &is_,
unsigned int flags
@@ -162,29 +161,25 @@ xml_wiarchive_impl<Archive>::xml_wiarchive_impl(
gimpl(new xml_wgrammar())
{
if(0 == (flags & no_codecvt)){
// note usage of argument "1" so that the locale isn't
// automatically delete the facet
archive_locale.reset(
add_facet(
is_.getloc(),
new boost::archive::detail::utf8_codecvt_facet
)
std::locale l = std::locale(
is_.getloc(),
new boost::archive::detail::utf8_codecvt_facet
);
//is.imbue(* archive_locale);
// libstdc++ crashes without this
is_.sync();
is_.imbue(l);
}
if(0 == (flags & no_header))
init();
}
template<class Archive>
BOOST_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_WARCHIVE_DECL
xml_wiarchive_impl<Archive>::~xml_wiarchive_impl(){
if(std::uncaught_exception())
return;
if(0 == (this->get_flags() & no_header)){
BOOST_TRY{
gimpl->windup(is);
}
BOOST_CATCH(...){}
BOOST_CATCH_END
gimpl->windup(is);
}
}
@@ -13,6 +13,7 @@
#include <string>
#include <algorithm> // std::copy
#include <locale>
#include <exception>
#include <cstring> // strlen
#include <cstdlib> // mbtowc
@@ -30,6 +31,8 @@ namespace std{
#endif
#include <boost/archive/xml_woarchive.hpp>
#include <boost/archive/detail/utf8_codecvt_facet.hpp>
#include <boost/serialization/throw_exception.hpp>
#include <boost/archive/iterators/xml_escape.hpp>
@@ -37,8 +40,6 @@ namespace std{
#include <boost/archive/iterators/ostream_iterator.hpp>
#include <boost/archive/iterators/dataflow_exception.hpp>
#include <boost/archive/add_facet.hpp>
namespace boost {
namespace archive {
@@ -52,14 +53,14 @@ void save_iterator(std::wostream &os, InputIterator begin, InputIterator end){
iterators::xml_escape<InputIterator>
> xmbtows;
std::copy(
xmbtows(BOOST_MAKE_PFTO_WRAPPER(begin)),
xmbtows(BOOST_MAKE_PFTO_WRAPPER(end)),
xmbtows(begin),
xmbtows(end),
boost::archive::iterators::ostream_iterator<wchar_t>(os)
);
}
template<class Archive>
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
xml_woarchive_impl<Archive>::save(const std::string & s){
// note: we don't use s.begin() and s.end() because dinkumware
// doesn't have string::value_type defined. So use a wrapper
@@ -71,47 +72,47 @@ xml_woarchive_impl<Archive>::save(const std::string & s){
#ifndef BOOST_NO_STD_WSTRING
template<class Archive>
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
xml_woarchive_impl<Archive>::save(const std::wstring & ws){
#if 0
typedef iterators::xml_escape<std::wstring::const_iterator> xmbtows;
std::copy(
xmbtows(BOOST_MAKE_PFTO_WRAPPER(ws.begin())),
xmbtows(BOOST_MAKE_PFTO_WRAPPER(ws.end())),
xmbtows(ws.begin()),
xmbtows(ws.end()),
boost::archive::iterators::ostream_iterator<wchar_t>(os)
);
#endif
typedef iterators::xml_escape<const wchar_t *> xmbtows;
std::copy(
xmbtows(BOOST_MAKE_PFTO_WRAPPER(ws.data())),
xmbtows(BOOST_MAKE_PFTO_WRAPPER(ws.data() + ws.size())),
xmbtows(ws.data()),
xmbtows(ws.data() + ws.size()),
boost::archive::iterators::ostream_iterator<wchar_t>(os)
);
}
#endif //BOOST_NO_STD_WSTRING
template<class Archive>
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
xml_woarchive_impl<Archive>::save(const char * s){
save_iterator(os, s, s + std::strlen(s));
}
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template<class Archive>
BOOST_WARCHIVE_DECL(void)
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(BOOST_MAKE_PFTO_WRAPPER(ws)),
xmbtows(BOOST_MAKE_PFTO_WRAPPER(ws + std::wcslen(ws))),
xmbtows(ws),
xmbtows(ws + std::wcslen(ws)),
boost::archive::iterators::ostream_iterator<wchar_t>(os)
);
}
#endif
template<class Archive>
BOOST_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_WARCHIVE_DECL
xml_woarchive_impl<Archive>::xml_woarchive_impl(
std::wostream & os_,
unsigned int flags
@@ -122,27 +123,44 @@ xml_woarchive_impl<Archive>::xml_woarchive_impl(
),
basic_xml_oarchive<Archive>(flags)
{
// Standard behavior is that imbue can be called
// a) before output is invoked or
// b) after flush has been called. This prevents one-to-many
// transforms (such as one to many transforms from getting
// mixed up.
if(0 == (flags & no_codecvt)){
archive_locale.reset(
add_facet(
os_.getloc(),
new boost::archive::detail::utf8_codecvt_facet
)
std::locale l = std::locale(
os_.getloc(),
new boost::archive::detail::utf8_codecvt_facet
);
//os.imbue(* archive_locale);
os_.flush();
os_.imbue(l);
}
if(0 == (flags & no_header))
this->init();
}
template<class Archive>
BOOST_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_WARCHIVE_DECL
xml_woarchive_impl<Archive>::~xml_woarchive_impl(){
if(std::uncaught_exception())
return;
if(0 == (this->get_flags() & no_header)){
save(L"</boost_serialization>\n");
}
}
template<class Archive>
BOOST_WARCHIVE_DECL void
xml_woarchive_impl<Archive>::save_binary(
const void *address,
std::size_t count
){
this->end_preamble();
#if ! defined(__MWERKS__)
this->basic_text_oprimitive<std::wostream>::save_binary(
#else
this->basic_text_oprimitive::save_binary(
#endif
address,
count
);
this->indent_next = true;
}
} // namespace archive
@@ -25,8 +25,6 @@ namespace std{
} // namespace std
#endif
#include <boost/serialization/pfto.hpp>
#include <boost/iterator/transform_iterator.hpp>
#include <boost/archive/iterators/dataflow_exception.hpp>
@@ -88,9 +86,9 @@ class base64_from_binary :
public:
// make composible buy using templated constructor
template<class T>
base64_from_binary(BOOST_PFTO_WRAPPER(T) start) :
base64_from_binary(T start) :
super_t(
Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start))),
Base(static_cast< T >(start)),
detail::from_6_bit<CharType>()
)
{}
@@ -19,7 +19,6 @@
#include <boost/assert.hpp>
#include <boost/serialization/throw_exception.hpp>
#include <boost/serialization/pfto.hpp>
#include <boost/static_assert.hpp>
#include <boost/iterator/transform_iterator.hpp>
@@ -96,9 +95,9 @@ class binary_from_base64 : public
public:
// make composible buy using templated constructor
template<class T>
binary_from_base64(BOOST_PFTO_WRAPPER(T) start) :
binary_from_base64(T start) :
super_t(
Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start))),
Base(static_cast< T >(start)),
detail::to_6_bit<CharType>()
)
{}
@@ -20,7 +20,6 @@
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/plus.hpp>
#include <boost/mpl/int.hpp>
@@ -1,80 +0,0 @@
#ifndef BOOST_ARCHIVE_ITERATORS_HEAD_ITERATOR_HPP
#define BOOST_ARCHIVE_ITERATORS_HEAD_ITERATOR_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// head_iterator.hpp
// (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)
// See http://www.boost.org for updates, documentation, and revision history.
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/iterator/iterator_traits.hpp>
namespace boost {
namespace archive {
namespace iterators {
template<class Predicate, class Base>
class head_iterator
: public boost::iterator_adaptor<
head_iterator<Predicate, Base>,
Base,
use_default,
single_pass_traversal_tag
>
{
private:
friend class iterator_core_access;
typedef boost::iterator_adaptor<
head_iterator<Predicate, Base>,
Base,
use_default,
single_pass_traversal_tag
> super_t;
typedef head_iterator<Predicate, Base> this_t;
typedef super_t::value_type value_type;
typedef super_t::reference reference_type;
reference_type dereference_impl(){
if(! m_end){
while(! m_predicate(* this->base_reference()))
++ this->base_reference();
m_end = true;
}
return * this->base_reference();
}
reference_type dereference() const {
return const_cast<this_t *>(this)->dereference_impl();
}
void increment(){
++base_reference();
}
Predicate m_predicate;
bool m_end;
public:
template<class T>
head_iterator(Predicate f, T start) :
super_t(Base(start)),
m_predicate(f),
m_end(false)
{}
};
} // namespace iterators
} // namespace archive
} // namespace boost
#endif // BOOST_ARCHIVE_ITERATORS_HEAD_ITERATOR_HPP
@@ -23,8 +23,6 @@
namespace std{ using ::memcpy; }
#endif
#include <boost/serialization/pfto.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/iterator/iterator_traits.hpp>
@@ -83,8 +81,8 @@ private:
public:
// make composible buy using templated constructor
template<class T>
insert_linebreaks(BOOST_PFTO_WRAPPER(T) start) :
super_t(Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start)))),
insert_linebreaks(T start) :
super_t(Base(static_cast< T >(start))),
m_count(0)
{}
// intel 7.1 doesn't like default copy constructor
@@ -54,21 +54,6 @@ class istream_iterator :
return m_istream == rhs.m_istream;
}
/*
//Access the value referred to
Elem dereference() const {
return m_current_value;
}
void increment(){
if(NULL != m_istream){
m_current_value = static_cast<Elem>(m_istream->get());
if(! m_istream->good()){
const_cast<this_t *>(this)->m_istream = NULL;
}
}
}
*/
//Access the value referred to
Elem dereference() const {
return m_istream->peek();
@@ -18,17 +18,15 @@
#include <boost/assert.hpp>
#include <cstddef> // size_t
#include <cstdlib> // for wctomb()
#include <cwchar> // mbstate_t
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::size_t;
using ::wctomb;
using ::mbstate_t;
} // namespace std
#endif
#include <boost/serialization/pfto.hpp>
#include <boost/archive/detail/utf8_codecvt_facet.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
namespace boost {
@@ -67,10 +65,10 @@ class mb_from_wchar
}
return m_buffer[m_bnext];
}
char dereference() const {
return (const_cast<this_t *>(this))->dereference_impl();
}
// test for iterator equality
bool equal(const mb_from_wchar<Base> & rhs) const {
// once the value is filled, the base_reference has been incremented
@@ -84,16 +82,16 @@ class mb_from_wchar
void fill(){
wchar_t value = * this->base_reference();
#if (defined(__MINGW32__) && ((__MINGW32_MAJOR_VERSION > 3) \
|| ((__MINGW32_MAJOR_VERSION == 3) && (__MINGW32_MINOR_VERSION >= 8))))
m_bend = std::wcrtomb(m_buffer, value, 0);
#else
m_bend = std::wctomb(m_buffer, value);
#endif
BOOST_ASSERT(-1 != m_bend);
BOOST_ASSERT((std::size_t)m_bend <= sizeof(m_buffer));
BOOST_ASSERT(m_bend > 0);
const wchar_t *wend;
char *bend;
std::codecvt_base::result r = m_codecvt_facet.out(
m_mbs,
& value, & value + 1, wend,
m_buffer, m_buffer + sizeof(m_buffer), bend
);
BOOST_ASSERT(std::codecvt_base::ok == r);
m_bnext = 0;
m_bend = bend - m_buffer;
}
void increment(){
@@ -105,17 +103,20 @@ class mb_from_wchar
m_full = false;
}
boost::archive::detail::utf8_codecvt_facet m_codecvt_facet;
std::mbstate_t m_mbs;
// buffer to handle pending characters
int m_bend;
int m_bnext;
char m_buffer[9];
char m_buffer[9 /* MB_CUR_MAX */];
std::size_t m_bend;
std::size_t m_bnext;
bool m_full;
public:
// make composible buy using templated constructor
template<class T>
mb_from_wchar(BOOST_PFTO_WRAPPER(T) start) :
super_t(Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start)))),
mb_from_wchar(T start) :
super_t(Base(static_cast< T >(start))),
m_mbs(std::mbstate_t()),
m_bend(0),
m_bnext(0),
m_full(false)
@@ -18,8 +18,6 @@
#include <boost/assert.hpp>
#include <boost/serialization/pfto.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/iterator/filter_iterator.hpp>
#include <boost/iterator/iterator_traits.hpp>
@@ -153,8 +151,8 @@ public:
// remove_whitespace(){} // why is this needed?
// make composible buy using templated constructor
template<class T>
remove_whitespace(BOOST_PFTO_WRAPPER(T) start) :
super_t(Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start))))
remove_whitespace(T start) :
super_t(Base(static_cast< T >(start)))
{}
// intel 7.1 doesn't like default copy constructor
remove_whitespace(const remove_whitespace & rhs) :
@@ -24,8 +24,6 @@
// character and 8 bit bytes. Lowest common multiple is 24 => 4 6 bit characters
// or 3 8 bit characters
#include <boost/serialization/pfto.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/iterator/iterator_traits.hpp>
@@ -110,8 +108,8 @@ class transform_width :
public:
// make composible buy using templated constructor
template<class T>
transform_width(BOOST_PFTO_WRAPPER(T) start) :
super_t(Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start)))),
transform_width(T start) :
super_t(Base(static_cast< T >(start))),
m_buffer_out_full(false),
// To disable GCC warning, but not truly necessary
//(m_buffer_in will be initialized later before being
@@ -154,7 +152,7 @@ void transform_width<Base, BitsOut, BitsIn, CharType>::fill() {
// append these bits to the next output
// up to the size of the output
unsigned int i = std::min(missing_bits, m_remaining_bits);
unsigned int i = (std::min)(missing_bits, m_remaining_bits);
// shift interesting bits to least significant position
base_value_type j = m_buffer_in >> (m_remaining_bits - i);
// and mask off the un interesting higher bits
+108 -45
View File
@@ -19,21 +19,22 @@
#include <boost/assert.hpp>
#include <cctype>
#include <cstddef> // size_t
#include <cstdlib> // mblen
#include <cwchar> // mbstate_t
#include <algorithm> // copy
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::mblen;
using ::mbtowc;
using ::mbstate_t;
} // namespace std
#endif
#include <boost/serialization/throw_exception.hpp>
#include <boost/serialization/pfto.hpp>
#include <boost/array.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/archive/detail/utf8_codecvt_facet.hpp>
#include <boost/archive/iterators/dataflow_exception.hpp>
#include <boost/serialization/throw_exception.hpp>
#include <iostream>
namespace boost {
namespace archive {
@@ -63,63 +64,125 @@ class wchar_from_mb
typedef wchar_from_mb<Base> this_t;
wchar_t drain();
wchar_t dereference_impl() {
if(! m_full){
m_current_value = drain();
m_full = true;
}
return m_current_value;
}
void drain();
wchar_t dereference() const {
return const_cast<this_t *>(this)->dereference_impl();
if(m_output.m_next == m_output.m_next_available)
return static_cast<wchar_t>(0);
return * m_output.m_next;
}
void increment(){
dereference_impl();
m_full = false;
++(this->base_reference());
if(m_output.m_next == m_output.m_next_available)
return;
if(++m_output.m_next == m_output.m_next_available){
if(m_input.m_done)
return;
drain();
}
}
bool equal(this_t const & rhs) const {
return dereference() == rhs.dereference();
}
boost::archive::detail::utf8_codecvt_facet m_codecvt_facet;
std::mbstate_t m_mbs;
template<typename T>
struct sliding_buffer {
boost::array<T, 32> m_buffer;
typename boost::array<T, 32>::const_iterator m_next_available;
typename boost::array<T, 32>::iterator m_next;
bool m_done;
// default ctor
sliding_buffer() :
m_next_available(m_buffer.begin()),
m_next(m_buffer.begin()),
m_done(false)
{}
// copy ctor
sliding_buffer(const sliding_buffer & rhs) :
m_next_available(
std::copy(
rhs.m_buffer.begin(),
rhs.m_next_available,
m_buffer.begin()
)
),
m_next(
m_buffer.begin() + (rhs.m_next - rhs.m_buffer.begin())
),
m_done(rhs.m_done)
{}
};
wchar_t m_current_value;
bool m_full;
sliding_buffer<typename iterator_value<Base>::type> m_input;
sliding_buffer<typename iterator_value<this_t>::type> m_output;
public:
// make composible buy using templated constructor
template<class T>
wchar_from_mb(BOOST_PFTO_WRAPPER(T) start) :
super_t(Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start)))),
m_full(false)
{}
// intel 7.1 doesn't like default copy constructor
wchar_from_mb(const wchar_from_mb & rhs) :
wchar_from_mb(T start) :
super_t(Base(static_cast< T >(start))),
m_mbs(std::mbstate_t())
{
BOOST_ASSERT(std::mbsinit(&m_mbs));
drain();
}
// default constructor used as an end iterator
wchar_from_mb(){}
// copy ctor
wchar_from_mb(const wchar_from_mb & rhs) :
super_t(rhs.base_reference()),
m_full(rhs.m_full)
m_mbs(rhs.m_mbs),
m_input(rhs.m_input),
m_output(rhs.m_output)
{}
};
template<class Base>
wchar_t wchar_from_mb<Base>::drain(){
char buffer[9];
char * bptr = buffer;
char val;
for(std::size_t i = 0; i++ < (unsigned)MB_CUR_MAX;){
val = * this->base_reference();
*bptr++ = val;
int result = std::mblen(buffer, i);
if(-1 != result)
void wchar_from_mb<Base>::drain(){
BOOST_ASSERT(! m_input.m_done);
for(;;){
typename boost::iterators::iterator_reference<Base>::type c = *(this->base_reference());
// a null character in a multibyte stream is takes as end of string
if(0 == c){
m_input.m_done = true;
break;
}
++(this->base_reference());
* const_cast<typename iterator_value<Base>::type *>(
(m_input.m_next_available++)
) = c;
// if input buffer is full - we're done for now
if(m_input.m_buffer.end() == m_input.m_next_available)
break;
}
wchar_t retval;
int result = std::mbtowc(& retval, buffer, MB_CUR_MAX);
if(0 >= result)
boost::serialization::throw_exception(iterators::dataflow_exception(
iterators::dataflow_exception::invalid_conversion
));
return retval;
const typename boost::iterators::iterator_value<Base>::type * input_new_start;
typename iterator_value<this_t>::type * next_available;
std::codecvt_base::result r = m_codecvt_facet.in(
m_mbs,
m_input.m_buffer.begin(),
m_input.m_next_available,
input_new_start,
m_output.m_buffer.begin(),
m_output.m_buffer.end(),
next_available
);
BOOST_ASSERT(std::codecvt_base::ok == r);
m_output.m_next_available = next_available;
m_output.m_next = m_output.m_buffer.begin();
// we're done with some of the input so shift left.
m_input.m_next_available = std::copy(
input_new_start,
m_input.m_next_available,
m_input.m_buffer.begin()
);
m_input.m_next = m_input.m_buffer.begin();
}
} // namespace iterators
@@ -17,7 +17,6 @@
// See http://www.boost.org for updates, documentation, and revision history.
#include <boost/assert.hpp>
#include <boost/serialization/pfto.hpp>
#include <boost/archive/iterators/escape.hpp>
namespace boost {
@@ -40,8 +39,8 @@ public:
wchar_t fill(const wchar_t * & bstart, const wchar_t * & bend);
template<class T>
xml_escape(BOOST_PFTO_WRAPPER(T) start) :
super_t(Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start))))
xml_escape(T start) :
super_t(Base(static_cast< T >(start)))
{}
// intel 7.1 doesn't like default copy constructor
xml_escape(const xml_escape & rhs) :
@@ -19,7 +19,6 @@
#include <boost/assert.hpp>
#include <boost/serialization/throw_exception.hpp>
#include <boost/serialization/pfto.hpp>
#include <boost/archive/iterators/unescape.hpp>
#include <boost/archive/iterators/dataflow_exception.hpp>
@@ -54,8 +53,8 @@ public:
value_type drain();
template<class T>
xml_unescape(BOOST_PFTO_WRAPPER(T) start) :
super_t(Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start))))
xml_unescape(T start) :
super_t(Base(static_cast< T >(start)))
{}
// intel 7.1 doesn't like default copy constructor
xml_unescape(const xml_unescape & rhs) :
+7 -11
View File
@@ -29,7 +29,6 @@ namespace std{
#include <boost/cstdint.hpp>
#include <boost/serialization/pfto.hpp>
#include <boost/archive/detail/iserializer.hpp>
#include <boost/archive/detail/interface_iarchive.hpp>
#include <boost/serialization/nvp.hpp>
@@ -44,13 +43,13 @@ namespace serialization {
} // namespace serialization
namespace archive {
namespace detail {
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iarchive;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iarchive;
class basic_iarchive;
class basic_iserializer;
}
class polymorphic_iarchive;
class polymorphic_iarchive_impl :
class BOOST_SYMBOL_VISIBLE polymorphic_iarchive_impl :
public detail::interface_iarchive<polymorphic_iarchive>
{
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
@@ -98,22 +97,19 @@ public:
virtual void load_start(const char * name) = 0;
virtual void load_end(const char * name) = 0;
virtual void register_basic_serializer(const detail::basic_iserializer & bis) = 0;
virtual detail::helper_collection & get_helper_collection() = 0;
// msvc and borland won't automatically pass these to the base class so
// make it explicit here
template<class T>
void load_override(T & t, BOOST_PFTO int)
void load_override(T & t)
{
archive::load(* this->This(), t);
}
// special treatment for name-value pairs.
template<class T>
void load_override(
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
const
#endif
boost::serialization::nvp< T > & t,
int
const boost::serialization::nvp< T > & t
){
load_start(t.name());
archive::load(* this->This(), t.value());
@@ -156,7 +152,7 @@ public:
namespace boost {
namespace archive {
class polymorphic_iarchive :
class BOOST_SYMBOL_VISIBLE polymorphic_iarchive :
public polymorphic_iarchive_impl
{
public:
+7 -10
View File
@@ -28,7 +28,6 @@ namespace std{
#endif
#include <boost/cstdint.hpp>
#include <boost/serialization/pfto.hpp>
#include <boost/archive/detail/oserializer.hpp>
#include <boost/archive/detail/interface_oarchive.hpp>
#include <boost/serialization/nvp.hpp>
@@ -43,13 +42,13 @@ namespace serialization {
} // namespace serialization
namespace archive {
namespace detail {
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oarchive;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oserializer;
class basic_oarchive;
class basic_oserializer;
}
class polymorphic_oarchive;
class polymorphic_oarchive_impl :
class BOOST_SYMBOL_VISIBLE polymorphic_oarchive_impl :
public detail::interface_oarchive<polymorphic_oarchive>
{
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
@@ -98,23 +97,21 @@ public:
virtual void save_start(const char * name) = 0;
virtual void save_end(const char * name) = 0;
virtual void register_basic_serializer(const detail::basic_oserializer & bos) = 0;
virtual detail::helper_collection & get_helper_collection() = 0;
virtual void end_preamble() = 0;
// msvc and borland won't automatically pass these to the base class so
// make it explicit here
template<class T>
void save_override(T & t, BOOST_PFTO int)
void save_override(T & t)
{
archive::save(* this->This(), t);
}
// special treatment for name-value pairs.
template<class T>
void save_override(
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
const
#endif
::boost::serialization::nvp< T > & t, int
const ::boost::serialization::nvp< T > & t
){
save_start(t.name());
archive::save(* this->This(), t.const_value());
@@ -139,7 +136,7 @@ public:
};
// note: preserve naming symmetry
class polymorphic_oarchive :
class BOOST_SYMBOL_VISIBLE polymorphic_oarchive :
public polymorphic_oarchive_impl
{
public:
+15 -25
View File
@@ -40,7 +40,7 @@ namespace detail {
} // namespace detail
template<class Archive>
class text_iarchive_impl :
class BOOST_SYMBOL_VISIBLE text_iarchive_impl :
public basic_text_iprimitive<std::istream>,
public basic_text_iarchive<Archive>
{
@@ -48,15 +48,8 @@ class text_iarchive_impl :
public:
#else
protected:
#if BOOST_WORKAROUND(BOOST_MSVC, < 1500)
// for some inexplicable reason insertion of "class" generates compile erro
// on msvc 7.1
friend detail::interface_iarchive<Archive>;
friend load_access;
#else
friend class detail::interface_iarchive<Archive>;
friend class load_access;
#endif
friend class detail::interface_iarchive<Archive>;
friend class load_access;
#endif
template<class T>
void load(T & t){
@@ -72,33 +65,30 @@ protected:
load(v);
t = boost::serialization::item_version_type(v);
}
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
load(char * t);
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
load(wchar_t * t);
#endif
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
load(std::string &s);
#ifndef BOOST_NO_STD_WSTRING
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
load(std::wstring &ws);
#endif
// note: the following should not needed - but one compiler (vc 7.1)
// fails to compile one test (test_shared_ptr) without it !!!
// make this protected so it can be called from a derived archive
template<class T>
void load_override(T & t, BOOST_PFTO int){
basic_text_iarchive<Archive>::load_override(t, 0);
void load_override(T & t){
basic_text_iarchive<Archive>::load_override(t);
}
BOOST_ARCHIVE_DECL(void)
load_override(class_name_type & t, int);
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
load_override(class_name_type & t);
BOOST_ARCHIVE_DECL void
init();
BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_DECL
text_iarchive_impl(std::istream & is, unsigned int flags);
// don't import inline definitions! leave this as a reminder.
//BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
//BOOST_ARCHIVE_DECL
~text_iarchive_impl(){};
};
@@ -119,7 +109,7 @@ protected:
namespace boost {
namespace archive {
class text_iarchive :
class BOOST_SYMBOL_VISIBLE text_iarchive :
public text_iarchive_impl<text_iarchive>{
public:
text_iarchive(std::istream & is_, unsigned int flags = 0) :
+12 -20
View File
@@ -47,7 +47,7 @@ namespace detail {
} // namespace detail
template<class Archive>
class text_oarchive_impl :
class BOOST_SYMBOL_VISIBLE text_oarchive_impl :
/* protected ? */ public basic_text_oprimitive<std::ostream>,
public basic_text_oarchive<Archive>
{
@@ -55,17 +55,9 @@ class text_oarchive_impl :
public:
#else
protected:
#if BOOST_WORKAROUND(BOOST_MSVC, < 1500)
// for some inexplicable reason insertion of "class" generates compile erro
// on msvc 7.1
friend detail::interface_oarchive<Archive>;
friend basic_text_oarchive<Archive>;
friend save_access;
#else
friend class detail::interface_oarchive<Archive>;
friend class basic_text_oarchive<Archive>;
friend class save_access;
#endif
friend class detail::interface_oarchive<Archive>;
friend class basic_text_oarchive<Archive>;
friend class save_access;
#endif
template<class T>
void save(const T & t){
@@ -78,32 +70,32 @@ protected:
void save(const boost::serialization::item_version_type & t){
save(static_cast<const unsigned int>(t));
}
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
save(const char * t);
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
save(const wchar_t * t);
#endif
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
save(const std::string &s);
#ifndef BOOST_NO_STD_WSTRING
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
save(const std::wstring &ws);
#endif
BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_DECL
text_oarchive_impl(std::ostream & os, unsigned int flags);
// don't import inline definitions! leave this as a reminder.
//BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
//BOOST_ARCHIVE_DECL
~text_oarchive_impl(){};
public:
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
save_binary(const void *address, std::size_t count);
};
// do not derive from this class. If you want to extend this functionality
// via inhertance, derived from text_oarchive_impl instead. This will
// preserve correct static polymorphism.
class text_oarchive :
class BOOST_SYMBOL_VISIBLE text_oarchive :
public text_oarchive_impl<text_oarchive>
{
public:
+9 -11
View File
@@ -44,7 +44,7 @@ namespace detail {
} // namespace detail
template<class Archive>
class text_wiarchive_impl :
class BOOST_SYMBOL_VISIBLE text_wiarchive_impl :
public basic_text_iprimitive<std::wistream>,
public basic_text_iarchive<Archive>
{
@@ -76,25 +76,23 @@ protected:
load(v);
t = boost::serialization::item_version_type(v);
}
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
load(char * t);
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
load(wchar_t * t);
#endif
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
load(std::string &s);
#ifndef BOOST_NO_STD_WSTRING
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
load(std::wstring &ws);
#endif
// note: the following should not needed - but one compiler (vc 7.1)
// fails to compile one test (test_shared_ptr) without it !!!
template<class T>
void load_override(T & t, BOOST_PFTO int){
basic_text_iarchive<Archive>::load_override(t, 0);
void load_override(T & t){
basic_text_iarchive<Archive>::load_override(t);
}
BOOST_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_WARCHIVE_DECL
text_wiarchive_impl(std::wistream & is, unsigned int flags);
~text_wiarchive_impl(){};
};
@@ -116,7 +114,7 @@ protected:
namespace boost {
namespace archive {
class text_wiarchive :
class BOOST_SYMBOL_VISIBLE text_wiarchive :
public text_wiarchive_impl<text_wiarchive>{
public:
text_wiarchive(std::wistream & is, unsigned int flags = 0) :
+6 -6
View File
@@ -52,7 +52,7 @@ namespace detail {
} // namespace detail
template<class Archive>
class text_woarchive_impl :
class BOOST_SYMBOL_VISIBLE text_woarchive_impl :
public basic_text_oprimitive<std::wostream>,
public basic_text_oarchive<Archive>
{
@@ -83,16 +83,16 @@ protected:
void save(const boost::serialization::item_version_type & t){
save(static_cast<const unsigned int>(t));
}
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
save(const char * t);
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
save(const wchar_t * t);
#endif
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
save(const std::string &s);
#ifndef BOOST_NO_STD_WSTRING
BOOST_WARCHIVE_DECL(void)
BOOST_WARCHIVE_DECL void
save(const std::wstring &ws);
#endif
text_woarchive_impl(std::wostream & os, unsigned int flags) :
@@ -129,7 +129,7 @@ public:
// do not derive from this class. If you want to extend this functionality
// via inhertance, derived from text_oarchive_impl instead. This will
// preserve correct static polymorphism.
class text_woarchive :
class BOOST_SYMBOL_VISIBLE text_woarchive :
public text_woarchive_impl<text_woarchive>
{
public:
@@ -20,7 +20,6 @@
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/preprocessor/empty.hpp>
#include <boost/archive/detail/decl.hpp>
#include <boost/archive/archive_exception.hpp>
@@ -32,7 +31,7 @@ namespace archive {
//////////////////////////////////////////////////////////////////////
// exceptions thrown by xml archives
//
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) xml_archive_exception :
class BOOST_SYMBOL_VISIBLE xml_archive_exception :
public virtual boost::archive::archive_exception
{
public:
@@ -41,11 +40,13 @@ public:
xml_archive_tag_mismatch,
xml_archive_tag_name_error
} exception_code;
xml_archive_exception(
BOOST_ARCHIVE_DECL xml_archive_exception(
exception_code c,
const char * e1 = NULL,
const char * e2 = NULL
);
BOOST_ARCHIVE_DECL xml_archive_exception(xml_archive_exception const &) ;
virtual BOOST_ARCHIVE_DECL ~xml_archive_exception() BOOST_NOEXCEPT_OR_NOTHROW ;
};
}// namespace archive
+16 -24
View File
@@ -44,7 +44,7 @@ class basic_xml_grammar;
typedef basic_xml_grammar<char> xml_grammar;
template<class Archive>
class xml_iarchive_impl :
class BOOST_SYMBOL_VISIBLE xml_iarchive_impl :
public basic_text_iprimitive<std::istream>,
public basic_xml_iarchive<Archive>
{
@@ -52,17 +52,9 @@ class xml_iarchive_impl :
public:
#else
protected:
#if BOOST_WORKAROUND(BOOST_MSVC, < 1500)
// for some inexplicable reason insertion of "class" generates compile erro
// on msvc 7.1
friend detail::interface_iarchive<Archive>;
friend basic_xml_iarchive<Archive>;
friend load_access;
#else
friend class detail::interface_iarchive<Archive>;
friend class basic_xml_iarchive<Archive>;
friend class load_access;
#endif
friend class detail::interface_iarchive<Archive>;
friend class basic_xml_iarchive<Archive>;
friend class load_access;
#endif
// use boost:scoped_ptr to implement automatic deletion;
boost::scoped_ptr<xml_grammar> gimpl;
@@ -86,29 +78,29 @@ protected:
load(v);
t = boost::serialization::item_version_type(v);
}
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
load(char * t);
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
load(wchar_t * t);
#endif
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
load(std::string &s);
#ifndef BOOST_NO_STD_WSTRING
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
load(std::wstring &ws);
#endif
template<class T>
void load_override(T & t, BOOST_PFTO int){
basic_xml_iarchive<Archive>::load_override(t, 0);
void load_override(T & t){
basic_xml_iarchive<Archive>::load_override(t);
}
BOOST_ARCHIVE_DECL(void)
load_override(class_name_type & t, int);
BOOST_ARCHIVE_DECL(void)
BOOST_ARCHIVE_DECL void
load_override(class_name_type & t);
BOOST_ARCHIVE_DECL void
init();
BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_DECL
xml_iarchive_impl(std::istream & is, unsigned int flags);
BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_DECL
~xml_iarchive_impl();
};
@@ -128,7 +120,7 @@ protected:
namespace boost {
namespace archive {
class xml_iarchive :
class BOOST_SYMBOL_VISIBLE xml_iarchive :
public xml_iarchive_impl<xml_iarchive>{
public:
xml_iarchive(std::istream & is, unsigned int flags = 0) :

Some files were not shown because too many files have changed in this diff Show More