Compare commits

..

43 Commits

Author SHA1 Message Date
nobody 878283eed2 This commit was manufactured by cvs2svn to create tag
'Version_1_34_0'.

[SVN r37679]
2007-05-12 21:59:40 +00:00
Nicola Musatti 2334804623 no message
[SVN r37668]
2007-05-12 08:15:55 +00:00
Robert Ramey 5d9d00bf68 roll back erroneous check-in
[SVN r36434]
2006-12-16 21:44:42 +00:00
Robert Ramey c600890b0d backout mistaken checkin
[SVN r36432]
2006-12-16 21:09:19 +00:00
Robert Ramey 41e1b8000a moved to lightweight testing framework
[SVN r36420]
2006-12-16 06:07:09 +00:00
Robert Ramey 9008ddf64a remove superfluous functions for helpers
[SVN r36418]
2006-12-16 06:00:34 +00:00
Vladimir Prus 80a61bb579 Fix
[SVN r35993]
2006-11-10 21:03:16 +00:00
Vladimir Prus ea8735098e Merge from HEAD.
Allow building of shared versions of some Boost.Test libraries.
Adjust tests to use always use static linking to Boost.Test, since
linking to the shared version requires test changes.

Patch from Juergen Hunold.


[SVN r35990]
2006-11-10 19:59:52 +00:00
Robert Ramey 694a68be35 correct error in last update
[SVN r35893]
2006-11-07 04:40:34 +00:00
Rene Rivera 007bfe52b8 Remove obsolete Boost.Build v1 files.
[SVN r35880]
2006-11-06 17:10:46 +00:00
Robert Ramey 30b736df0b updated for hp
[SVN r35865]
2006-11-06 04:55:19 +00:00
Robert Ramey aaad58be00 modified for benefit of HP compiler
[SVN r35864]
2006-11-06 04:49:13 +00:00
Robert Ramey 1a4e75f492 fixup stlport macros
[SVN r34794]
2006-08-01 04:25:49 +00:00
Robert Ramey 8cdc138fe1 fixed link
[SVN r34565]
2006-07-16 20:34:47 +00:00
Robert Ramey a23d2e1c45 corrected html escapes
[SVN r34547]
2006-07-16 01:56:20 +00:00
Robert Ramey e15f15888e corrected spirit link
[SVN r34546]
2006-07-16 01:55:37 +00:00
Robert Ramey 5787031495 tweaks to fix borlands problem with strong type
[SVN r34218]
2006-06-07 03:33:30 +00:00
Robert Ramey b1cbb5841a fixups for vc 6.5 and intel 9.1
[SVN r34189]
2006-06-06 03:52:00 +00:00
Robert Ramey e4ffaa0ecc change hoping to fix borland test
[SVN r34172]
2006-06-04 18:55:01 +00:00
Robert Ramey a888b6a2c6 clarify text
[SVN r34167]
2006-06-04 15:14:51 +00:00
Robert Ramey 3771a72827 clarify role of common.hpp
[SVN r34166]
2006-06-04 15:13:44 +00:00
Robert Ramey 75bcbe70c1 fix spirit link
[SVN r34165]
2006-06-04 15:12:45 +00:00
Robert Ramey 1c0c86407c include serialization traits header
[SVN r34164]
2006-06-04 14:52:30 +00:00
Robert Ramey b271d42c4d correction for borland
[SVN r34163]
2006-06-04 14:51:24 +00:00
Robert Ramey 73f2332552 refine for dinkumare improvement
[SVN r34121]
2006-05-30 15:59:14 +00:00
Robert Ramey 0456f38813 fix for latest borland
[SVN r34120]
2006-05-30 15:58:22 +00:00
Robert Ramey c45e6b53e2 fix typos
[SVN r34119]
2006-05-30 15:57:15 +00:00
Robert Ramey 14e7353994 Borland fixes
[SVN r34118]
2006-05-30 15:56:35 +00:00
Robert Ramey 8a4a9fe353 efficiency improvement
[SVN r33745]
2006-04-19 15:50:41 +00:00
Robert Ramey 757e0319de correction
[SVN r33731]
2006-04-18 16:02:21 +00:00
Robert Ramey 8559cb7b1a correct error exposed by stlport 5.0
[SVN r33716]
2006-04-17 08:06:45 +00:00
Robert Ramey 4896421bb9 tweak for borland update
[SVN r33603]
2006-04-08 20:44:02 +00:00
Robert Ramey 35184e36b3 correction in is_base.. namespace
[SVN r33598]
2006-04-07 15:36:38 +00:00
Robert Ramey c785101476 correct hash tests
[SVN r33538]
2006-04-05 04:56:10 +00:00
Robert Ramey 117e7382a0 change encodeing to utf-8
[SVN r33537]
2006-04-05 04:54:57 +00:00
Robert Ramey aa4aa23be3 correct for STLPort
[SVN r33536]
2006-04-05 04:52:27 +00:00
Robert Ramey ccce8f7fdd project update
[SVN r33470]
2006-03-24 16:22:18 +00:00
Robert Ramey bb8d1be57c misc adjustments
[SVN r33469]
2006-03-24 16:17:17 +00:00
Robert Ramey deac1f07fc increase template depth for gcc compilers
[SVN r33468]
2006-03-24 16:15:13 +00:00
Robert Ramey a484107118 comment correction
[SVN r33467]
2006-03-24 16:13:23 +00:00
Robert Ramey 0b9108996b added set_library call to properly initialize library version from archive
[SVN r33466]
2006-03-24 15:57:30 +00:00
Robert Ramey 58becb4e26 added is_* to avoid multiple parent problem
[SVN r33465]
2006-03-24 15:55:05 +00:00
nobody a7bb283ddb This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'.
[SVN r33417]
2006-03-21 02:26:31 +00:00
288 changed files with 13957 additions and 6563 deletions
+3
View File
@@ -0,0 +1,3 @@
This file is used by the project manager only and should be treated like the project file
+147
View File
@@ -0,0 +1,147 @@
<?xml version='1.0' encoding='utf-8' ?>
<!-- C++Builder XML Project -->
<PROJECT>
<MACROS>
<VERSION value="BCB.06.00"/>
<PROJECT value="test_simple_class.exe"/>
<OBJFILES value="..\test\test_simple_class.obj"/>
<RESFILES value="test_simple_class.res"/>
<IDLFILES value=""/>
<IDLGENFILES value=""/>
<DEFFILE value=""/>
<RESDEPEN value="$(RESFILES)"/>
<LIBFILES value="..\..\..\bin\boost\libs\serialization\build\libboost_serialization.lib\borland\debug\runtime-link-static\libboost_serialization.lib
..\..\..\bin\boost\libs\serialization\build\libboost_wserialization.lib\borland\debug\runtime-link-static\libboost_wserialization.lib
..\..\..\bin\boost\libs\test\build\libboost_test_exec_monitor.lib\borland\debug\runtime-link-static\libboost_test_exec_monitor.lib"/>
<LIBRARIES value=""/>
<SPARELIBS value=""/>
<PACKAGES value="vcl.bpi rtl.bpi dbrtl.bpi adortl.bpi vcldb.bpi vclx.bpi bdertl.bpi
vcldbx.bpi ibxpress.bpi dsnap.bpi cds.bpi bdecds.bpi qrpt.bpi teeui.bpi
teedb.bpi tee.bpi dss.bpi teeqr.bpi visualclx.bpi visualdbclx.bpi
dsnapcrba.bpi dsnapcon.bpi bcbsmp.bpi vclie.bpi xmlrtl.bpi inet.bpi
inetdbbde.bpi inetdbxpress.bpi inetdb.bpi nmfast.bpi webdsnap.bpi
bcbie.bpi websnap.bpi soaprtl.bpi dclocx.bpi dbexpress.bpi dbxcds.bpi
indy.bpi bcb2kaxserver.bpi"/>
<PATHCPP value=".;..\test"/>
<PATHPAS value=".;"/>
<PATHRC value=".;"/>
<PATHASM value=".;"/>
<DEBUGLIBPATH value="$(BCB)\lib\debug"/>
<RELEASELIBPATH value="$(BCB)\lib\release"/>
<LINKER value="ilink32"/>
<USERDEFINES value="_DEBUG;BOOST_ARCHIVE_TEST=xml_warchive.hpp"/>
<SYSDEFINES value="NO_STRICT;_NO_VCL;USEPACKAGES"/>
<MAINSOURCE value="test_simple_class.bpf"/>
<INCLUDEPATH value="..\test;C:\boost_1_31_0;$(BCB)\include;$(BCB)\include\vcl"/>
<LIBPATH value="..\test;$(BCB)\lib\obj;$(BCB)\lib"/>
<WARNINGS value="-w-par"/>
<OTHERFILES value=""/>
</MACROS>
<OPTIONS>
<IDLCFLAGS value="-I..\test -IC:\boost_1_31_0 -I$(BCB)\include -I$(BCB)\include\vcl
-src_suffix cpp -D_DEBUG -DBOOST_ARCHIVE_TEST=xml_warchive.hpp -boa"/>
<CFLAG1 value="-Od -Vx -Ve -X- -r- -a8 -b- -k -y -v -vi- -tWC -tWM -c"/>
<PFLAGS value="-$YD -$W -$O- -$A8 -v -JPHNE -M"/>
<RFLAGS value=""/>
<AFLAGS value="/mx /w2 /zd"/>
<LFLAGS value="-D&quot;&quot; -ap -Tpe -x -Gn -v"/>
<OTHERFILES value=""/>
</OPTIONS>
<LINKER>
<ALLOBJ value="c0x32.obj $(PACKAGES) $(OBJFILES)"/>
<ALLRES value="$(RESFILES)"/>
<ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32mt.lib"/>
<OTHERFILES value=""/>
</LINKER>
<FILELIST>
<FILE FILENAME="test_simple_class.res" FORMNAME="" UNITNAME="test_simple_class.res" CONTAINERID="ResTool" DESIGNCLASS="" LOCALCOMMAND=""/>
<FILE FILENAME="test_simple_class.bpf" FORMNAME="" UNITNAME="test_simple_class" CONTAINERID="BPF" DESIGNCLASS="" LOCALCOMMAND=""/>
<FILE FILENAME="..\test\test_simple_class.cpp" FORMNAME="" UNITNAME="test_simple_class" CONTAINERID="CCompiler" DESIGNCLASS="" LOCALCOMMAND=""/>
<FILE FILENAME="..\..\..\bin\boost\libs\serialization\build\libboost_serialization.lib\borland\debug\runtime-link-static\libboost_serialization.lib" FORMNAME="" UNITNAME="libboost_serialization.lib" CONTAINERID="LibTool" DESIGNCLASS="" LOCALCOMMAND=""/>
<FILE FILENAME="..\..\..\bin\boost\libs\serialization\build\libboost_wserialization.lib\borland\debug\runtime-link-static\libboost_wserialization.lib" FORMNAME="" UNITNAME="libboost_wserialization.lib" CONTAINERID="LibTool" DESIGNCLASS="" LOCALCOMMAND=""/>
<FILE FILENAME="..\..\..\bin\boost\libs\test\build\libboost_test_exec_monitor.lib\borland\debug\runtime-link-static\libboost_test_exec_monitor.lib" FORMNAME="" UNITNAME="libboost_test_exec_monitor.lib" CONTAINERID="LibTool" DESIGNCLASS="" LOCALCOMMAND=""/>
</FILELIST>
<BUILDTOOLS>
</BUILDTOOLS>
<IDEOPTIONS>
[Version Info]
IncludeVerInfo=0
AutoIncBuild=0
MajorVer=1
MinorVer=0
Release=0
Build=0
Debug=0
PreRelease=0
Special=0
Private=0
DLL=0
Locale=1033
CodePage=1252
[Version Info Keys]
CompanyName=
FileDescription=
FileVersion=1.0.0.0
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=1.0.0.0
Comments=
[HistoryLists\hlIncludePath]
Count=5
Item0=..\test;C:\boost_1_31_0\libs\serialization\test;C:\boost_1_31_0;$(BCB)\include;$(BCB)\include\vcl
Item1=C:\boost_1_31_0\libs\serialization\test;C:\boost_1_31_0;$(BCB)\include;$(BCB)\include\vcl
Item2=C:\boost_1_31_0\libs;C:\boost_1_31_0\libs\serialization\test;$(BCB)\include;$(BCB)\include\vcl
Item3=C:\boost_1_31_0\libs\;C:\boost_1_31_0\libs\serialization\test;$(BCB)\include;$(BCB)\include\vcl
Item4=C:\boost_1_31_0\libs\serialization\test;$(BCB)\include;$(BCB)\include\vcl
[HistoryLists\hlLibraryPath]
Count=2
Item0=..\test;C:\boost_1_31_0\libs\serialization\test;$(BCB)\lib\obj;$(BCB)\lib
Item1=C:\boost_1_31_0\libs\serialization\test;$(BCB)\lib\obj;$(BCB)\lib
[HistoryLists\hlDebugSourcePath]
Count=1
Item0=$(BCB)\source\vcl
[HistoryLists\hlConditionals]
Count=2
Item0=_DEBUG;BOOST_ARCHIVE_TEST=xml_warchive.hpp
Item1=_DEBUG
[Debugging]
DebugSourceDirs=$(BCB)\source\vcl
[Parameters]
RunParams=
Launcher=
UseLauncher=0
DebugCWD=
HostApplication=
RemoteHost=
RemotePath=
RemoteLauncher=
RemoteCWD=
RemoteDebug=0
[Compiler]
ShowInfoMsgs=0
LinkDebugVcl=1
LinkCGLIB=0
[CORBA]
AddServerUnit=1
AddClientUnit=1
PrecompiledHeaders=1
[Language]
ActiveLang=
ProjectLang=
RootDir=
</IDEOPTIONS>
</PROJECT>
Binary file not shown.
+11 -28
View File
@@ -10,31 +10,12 @@ project boost/serialization
: source-location ../src
;
rule include-spirit ( properties * )
{
local result ;
local SPIRIT_ROOT = [ modules.peek : SPIRIT_ROOT ] ;
for local tset in borland { # vc iw
if ( <toolset>$(tset) in $(properties) ) {
if ( $(SPIRIT_ROOT) ) {
result = <cxxflags>-I$(SPIRIT_ROOT) ;
}
else {
echo **** spirit 1.6x required to build library with this compiler **** ;
result = <build>no ;
}
}
}
return $(result) ;
}
SOURCES =
basic_archive
basic_archive_impl
basic_iarchive
basic_iserializer
basic_oarchive
basic_iserializer
basic_oserializer
basic_pointer_iserializer
basic_pointer_oserializer
@@ -44,7 +25,6 @@ SOURCES =
basic_xml_archive
binary_iarchive
binary_oarchive
codecvt_null
extended_type_info
extended_type_info_no_rtti
extended_type_info_typeid
@@ -60,13 +40,14 @@ SOURCES =
;
WSOURCES =
codecvt_null
utf8_codecvt_facet
basic_text_wiprimitive
basic_text_woprimitive
binary_wiarchive
binary_woarchive
text_wiarchive
text_woarchive
utf8_codecvt_facet
xml_wgrammar
xml_wiarchive
xml_woarchive
@@ -75,13 +56,15 @@ WSOURCES =
lib boost_serialization
: $(SOURCES).cpp
: <toolset>msvc:<cxxflags>/Gy
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
<conditional>@include-spirit
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
:
: <link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
;
lib boost_wserialization
: $(WSOURCES).cpp boost_serialization
: <toolset>msvc:<cxxflags>/Gy
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
<conditional>@include-spirit
: <toolset>msvc:<cxxflags>/Gy
<link>shared:<define>BOOST_WSERIALIZATION_DYN_LINK=1
:
: <link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
;
-6
View File
@@ -27,12 +27,6 @@ http://www.boost.org/LICENSE_1_0.txt)
</table>
<hr>
<ul>
<li>David Abrahams improved implementation of "export" functionality. This not
only eliminated an annoying header sequencing requirement, but also the need to maintain
a list of "known archives".
<li>Mattias Troyer ehnanced the implementation of native binary archives. This includes
enhancement and generalization of the library itself including generalization of
the wrapper concept.
<li>Markus Schöpflin tracked down issues with TRU64 compiler resulting in 100% passing.
<li><a href="mailto::troy@resophonic.com"> Troy D. Straszheim</a> made the initial version of variant serialization.
<li>Tonko Juricic helped refine and complete project files for VC 7.1 ide
+4 -3
View File
@@ -43,7 +43,8 @@ for archives used for saving data.
Our archives have been factored in to a tree of classes in order to minimize
repetition of code. This is shown in the accompanying
<a target="class_diagram" href="class_diagram.html">class diagram</a>.
All input archives should be derived from the following template:
In order to diminish code repetition, input archives included with this library
have all been derived from the following template:
<pre><code>
template&lt;class Archive&gt;
detail::common_iarchive;
@@ -367,9 +368,9 @@ As can be seen in the
and the header files, this implementation is just a composition of the polymorphic
interface and the standard template driven implementation. This composition is
accomplished by the templates
<a target=polymorphic_iarchive_dispatch_hpp href="../../../boost/archive/detail/polymorphic_iarchive_dispatch.hpp"><code style="white-space: normal">polymorphic_iarchive_dispatch.hpp</code></a>
<a target=polymorphic_iarchive_impl_hpp href="../../../boost/archive/detail/polymorphic_iarchive_impl.hpp"><code style="white-space: normal">polymorphic_iarchive_impl.hpp</code></a>
and
<a target=polymorphic_oarchive_dispatch_hpp href="../../../boost/archive/detail/polymorphic_oarchive_dispatch.hpp"><code style="white-space: normal">polymorphic_oarchive_dispatch.hpp</code></a>.
<a target=polymorphic_oarchive_impl_hpp href="../../../boost/archive/detail/polymorphic_oarchive_impl.hpp"><code style="white-space: normal">polymorphic_oarchive_impl.hpp</code></a>.
As these contain no code specific to the particular implementation archive, they can be used to create
a polymorphic archive implementation from any functioning templated archive implementation.
<p>
+6 -6
View File
@@ -20,7 +20,7 @@ http://www.boost.org/LICENSE_1_0.txt)
</td>
<td valign="top">
<h1 align="center">Serialization</h1>
<h2 align="center">Text Archive Class Diagram</h2>
<h2 align="center">Archive Class Diagram</h2>
</td>
</tr>
</table>
@@ -59,7 +59,7 @@ common_iarchive&lt;text_iarchive&gt; <a href="../../../boost/archive/detail/comm
| \ /
| \ /
| \ /
<font color="red">text_iarchive</font> <a href="../../../boost/archive/text_iarchive.hpp">-></a> polymorphic_iarchive_dispatch&lt;text_iarchive_impl&lt;text_iarchive&gt; &gt; <a href="../../../boost/archive/detail/polymorphic_iarchive_dispatch.hpp">-></a>
<font color="red">text_iarchive</font> <a href="../../../boost/archive/text_iarchive.hpp">-></a> polymorphic_iarchive_impl&lt;text_iarchive_impl&lt;text_iarchive&gt; &gt; <a href="../../../boost/archive/detail/polymorphic_iarchive_impl.hpp">-></a>
|
|
|
@@ -72,7 +72,7 @@ serialization) for text files. The hierachy and organization is identical for s
other types of archives as well. In the diagram, classes written in <font color="blue">blue</font>
implement loading for a given archive type. (in this case its text archives).
Users include classes in <font color="red">red</font> to load their data from a partcular
type of archive. Other classes whose names are in black implement the library and should
type of archive. Other classes whose names are in black implment the library and should
never change. They are in <code>namespace boost::archive::detail</code>
<dl>
<dt><code>
@@ -146,19 +146,19 @@ never change. They are in <code>namespace boost::archive::detail</code>
for all archives present and future.
<p><dt><code>
<a href="../../../boost/archive/detail/polymorphic_iarchive_dispatch.hpp">polymorphic_iarchive_dispatch&lt;text_iarchive_impl&lt;text_iarchive&gt; &gt;</a>
<a href="../../../boost/archive/detail/polymorphic_iarchive_impl.hpp">polymorphic_iarchive_impl&lt;text_iarchive_impl&lt;text_iarchive&gt; &gt;</a>
</code></dt>
<dd><p>
This class implements the <code style="white-space: normal">polymorphic_iarchive</code> in terms of a specific
concrete class. Virtual function calls are forwarded to the implementing class. In this example,
that implementing class would be text_iarchive_impl.
that impelenting class would be text_iarchive_impl.
<p><dt><code>
<a href="../../../boost/archive/polymorphic_text_iarchive.hpp">polymorphic_text_iarchive</a>
</code></dt>
<dd>
this is just a typedef so we can write polymorphic_text_archive rather than
<code style="white-space: normal">polymorphic_iarchive_dispatch&lt;text_iarchive_impl&lt;text_iarchive&gt; &gt;</code>
<code style="white-space: normal">polymorphic_iarchive_impl&lt;text_iarchive_impl&lt;text_iarchive&gt; &gt;</code>
</dl>
<hr>
+1 -9
View File
@@ -87,9 +87,7 @@ function initialize() {
<dt><img style="display:none" src="plus.gif" id="release_notes"><a target="detail" href="release.html">Release Notes</a></dt>
<dd><div id="release_notes_detail"><dl class="page-index">
<dt><img style="display:none" src="dot.gif"><a target="detail" href="release.html#requirements">Requirements</a></dt>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="release.html#difference_1_32">Differences from version 1.32</a></dt>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="release.html#difference_1_33">Differences from version 1.33</a></dt>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="release.html#difference_1_34">Differences from version 1.34</a></dt>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="release.html#recent_improvements">Differences from version 1.32</a></dt>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="release.html#todo">Pending Issues</a></dt>
</dl></div></dd>
<dt><img style="display:none" src="plus.gif" id="overview"><a target="detail" href="overview.html">Overview</a></dt>
@@ -157,9 +155,7 @@ function initialize() {
<dt><img style="display:none" src="plus.gif" id="wrappers"><a target="detail" href="wrappers.html">Serialization Wrappers</a>
<dd><div id="wrappers_detail"><dl class="page-index">
<dt><img style="display:none" src="dot.gif"><a target="detail" href="wrappers.html#binaryobjects">Binary Objects</a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="wrappers.html#arrays">Arrays</a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="wrappers.html#strong_type"><code style="white-space: normal">strong_type</code></a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="wrappers.html#collection_size_type">Collection Sizes</a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="wrappers.html#nvp">Name-Value Pairs</a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="wrappers.html#composition">Composition</a>
</dl></div></dd>
@@ -171,7 +167,6 @@ function initialize() {
<dt><img style="display:none" src="dot.gif"><a target="detail" href="traits.html#export">Export Key</a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="traits.html#Abstract">Abstract</a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="traits.html#typeinfo">Type Information Implementation</a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="traits.html#wrappers">Wrappers</a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="traits.html#templates">Template Serialization Traits</a>
</dl></div></dd>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="serialization.html#models">Models - Serialization Implementations Included in the Library</a>
@@ -188,9 +183,6 @@ function initialize() {
</dl></div></dd>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="special.html#binary_archives">Binary Archives</a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="special.html#xml_archives">XML Archives</a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="special.html#dlls">DLLS - Serialization and Runtime Linking</a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="special.html#multi_threading">Multi-Threading</a>
<dt><img style="display:none" src="dot.gif"><a target="detail" href="special.html#optimizations">Optimzations</a>
<dt><img style="display:none" src="plus.gif" id="exceptions"><a target="detail" href="exceptions.html">Archive Exceptions</a>
<dd><div id="exceptions_detail"><dl class="page-index">
<dt><img style="display:none" src="dot.gif"><a target="detail" href="exceptions.html#unregistered_class"><code>unregistered_class</code></a>
+2 -5
View File
@@ -30,7 +30,6 @@ http://www.boost.org/LICENSE_1_0.txt)
<dt><a href="#runtime">Runtime Interface</a>
<dt><a href="#requirements">Requirements</a>
<dt><a href="#models">Models</a>
<dt><a href="#example">Example</a>
</dl>
@@ -94,7 +93,7 @@ following features:
</ul>
The serialization system maintains two global tables.
<ul>
<li>The first is a global type table. it has an entry for each type used.
<li>The first is a global type table. it and has with an entry for each type used.
Each entry is an instance of a class derived from
<code style="white-space: normal"><a target="extended_type_info.hpp" href = "../../../boost/serialization/extended_type_info.hpp">extended_type_info</a></code>. This table is used
to retrieve the unique <code style="white-space: normal"><a target="extended_type_info.hpp" href = "../../../boost/serialization/extended_type_info.hpp">extended_type_info</a></code>
@@ -311,9 +310,7 @@ virtual const char * get_key();
which returns a unique string the most derived object this class.
This function must be virtual in order to implement the functionality required by
<code style="white-space: normal">ETI::get_derived_extended_type_info</code>
as described above.
<h3><a name="example">Example</a></h3>
The test program <code style="white-space: normal"><a target="test_no_rtti" href="../test/test_no_rtti.cpp">test_no_rtti</a></code>
as described above. The test program <code style="white-space: normal"><a target="test_no_rtti" href="../test/test_no_rtti.cpp">test_no_rtti</a></code>
implements this function in terms of the <code style="white-space: normal"><a target="extended_type_info_no_rtti.hpp" href="../../../boost/serialization/extended_type_info_no_rtti.hpp">
extended_type_info</a></code> API above to return the export key associated with the class.
This requires that non-abstract types be exported.
+1 -12
View File
@@ -257,18 +257,7 @@ they are not strictly necessary to use the serialization package, the example an
program presume that they are enabled. So be sure your command line or IDE settings
enable these features if you want
these switches are enabled if you want to build and run these programs.
<p>
This compiler can treat <code style="white-space: normal">wchar_t</code> as either
a short integer or an intrinsic type.
If <code style="white-space: normal">/Zc:wchar_t</code> is specified on the
compile command line, <code style="white-space: normal">wchar_t</code> will be
considered an intrinsic type - otherwise
it will be treated as a synonym for a 16 bit integer. The libary can be used
either way - <strong>BUT</strong> - both the libray <strong>AND</strong> the application
must be compiled with the same switch settings. Note that <code style="white-space: normal">BJAM</code>
includes this switch by default. So if want to use the libraries that
<code style="white-space: normal">BJAM</code> builds, you should include this switch
when you compile your own applications.
<h5>Using the Visual C++ IDE</h5>
The library includes a VC++ 7.1 "Solution" - <code style="white-space: normal">BoostSerializationLibrary</code>
along with of a set of project files - one for each demo and test. Consider the following if you
+3 -3
View File
@@ -235,9 +235,9 @@ BOOST_SERIALIZATION_TRACKING(construct_from, track_never)
<li><code style="white-space: normal">shared_ptr&lt;construct_from&gt;</code>
is not going to have a single raw pointer shared amongst the instances. Each loaded
<code style="white-space: normal">shared_ptr&lt;construct_from&gt;</code> is going to
have its own distinct raw pointer. This will break
have its own distince raw pointer. This will break
<code style="white-space: normal">shared_ptr</code> and cause a memory leak. Again,
The cause of this problem is very far removed from the point of discovery. It could
The cause of this problem is very far removed from the point of discovery. It would
well be that the problem is not even discovered until after the archives are loaded.
Now we not only have difficult to find and fix program bug, but we have a bunch of
invalid archives and lost data.
@@ -295,7 +295,7 @@ ar &lt;&lt; x
<li>Oh, this trap is suggesting that the default serialization isn't really
what I want. Of course in this particular program it doesn't matter. But
then the code in the trap can't really evaluate code in other modules (which
might not even be written yet). OK, I'll add the following to my
might not even be written yet). OK, I'll at the following to my
construct_from.hpp to solve the problem.
<code style="white-space: normal"><pre>
BOOST_SERIALIZATION_TRACKING(construct_from, track_never)
+15 -19
View File
@@ -27,9 +27,7 @@ http://www.boost.org/LICENSE_1_0.txt)
<hr>
<dl class="index">
<dt><a href="#requirements">Requirements</a></dt>
<dt><a href="#differences_1_32">Differences from version 1.32</a></dt>
<dt><a href="#differences_1_33">Differences from version 1.33</a></dt>
<dt><a href="#differences_1_34">Differences from version 1.34</a></dt>
<dt><a href="#recent_improvements">Differences from version 1.32</a></dt>
<dt><a href="#todo">Pending Issues</a></dt>
</dl>
This is the Boost 1.33 Serialization Library.
@@ -43,17 +41,23 @@ We have found that all tests pass using spirit 1.6x. Spirit 1.8 and higher does
older compilers - specificallly MSVC 6, Borland and GCC < 3.0.
If you are using one of these compilers, you may download a version
of spirit 1.6 <a href="http://spirit.sourceforge.net/index.php?doc=download/index.html">here</a>.
Choose the latest 1.6.x Spirit only version available.
To use this downloaded version rather than the one included with boost,
set an environmental variable SPIRIT_ROOT to be equal to the root
directory where the downloaded copy of spirit has been placed. E. G.
you have two options: either replace the <code style="white-space: normal">boost/spirit</code> and
<code style="white-space: normal">libs/spirit</code> directories, as well as the
<code style="white-space: normal">boost/spirit.hpp</code> header, with those in the downloaded version,
or extract Spirit 1.6 to a different directory and add the corresponding include directive to your
<code style="white-space: normal">tools/build/v2/user-config.jam</code> file for all the
compilers that need it, as in the following example:
<pre><code>
set SPIRIT_ROOT=c:/spirit16
using borland : 5.6.4 : "C:/Program Files/Borland/CBuilder6/Bin/bcc32" :
&lt;cxxflags&gt;-IC:/spirit1.6 ;
</code></pre>
If you're not using bjam and the Jamfile to build the library, be sure that
the directory which contains the version of spirit you plan to use is placed
at the front of the list of include paths.
<h2><a name="differences_1_32"></a>Differences from Boost 1.32</h2>
<h2><a name="recent_improvements"></a>Differences from Boost 1.32</h2>
<ul>
<li>Dynamic Linking Library (DLLs and shared libraries) for platforms which support them. See
<a href="../../../more/getting_started.html#auto-link">Automatic Linking on Windows</a>.
@@ -80,19 +84,10 @@ at the front of the list of include paths.
<li>More compilers tested and supported.
<li>Miscelleanous bug fixes.
</ul>
<h2><a name="differences_1_33"></a>Differences from Boost 1.33</h2>
<h2><a name="recent_improvements"></a>Differences from Boost 1.33</h2>
<ul>
<li>Native Binary archives use the <code style="white-space: normal">std::streambuf</code> interface.
This should result in noticibly faster execution in many cases.
</ul>
<h2><a name="differences_1_34"></a>Differences from Boost 1.34</h2>
<ul>
<li>Ehanced support for fast serialiation for native binary archives. By Mattias Troyer.
<li>Improved implementation of "export" functionality. Removes header ordering
requirement and eliminates the maintainence of a pre-determined list of "known archives"
By David Abrahams.
<li>Improved support for STLPort.
This should result in noticible faster execution in some cases.
</ul>
<h2><a name="todo"></a>Pending issues</h2>
@@ -116,8 +111,9 @@ at the front of the list of include paths.
Aside from the above, there are a number of issus related to specific platforms.
These are listed in <a href="implementation.html#othercompilerissues">Specific Compiler/Library Issues</a>.
<hr>
<p><i>&copy; Copyright <a href="http://www.rrsd.com">Robert Ramey</a> 2002-2007.
<p><i>&copy; Copyright <a href="http://www.rrsd.com">Robert Ramey</a> 2002-2004.
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>
+25 -19
View File
@@ -437,9 +437,6 @@ function guarantees that this is always the case and will minimize the
occurence of hard to find errors related to synchronization of
<code style="white-space: normal">save</code> and <code style="white-space: normal">load</code>
functions.
<p>
Also note that <code style="white-space: normal">BOOST_SERIALIZATION_SPLIT_FREE</code>
must be used outside of any namespace.
<h2><a name="pointeroperators">Pointers</a></h2>
A pointer to any class instance can be serialized with any of the archive
@@ -536,18 +533,14 @@ will have to be overridden. Here is a simple example:
class my_class {
private:
friend class boost::serialization::access;
const int m_attribute; // some immutable aspect of the instance
int m_state; // mutable state of this instance
int member;
template&lt;class Archive&gt;
void serialize(Archive &amp;ar, const unsigned int file_version){
ar &amp; m_state;
ar &amp; member;
}
public:
// no default construct guarentees that no invalid object
// ever exists
my_class(int attribute) :
m_attribute(attribute),
m_state(0)
my_class(int m) :
member(m)
{}
};
</code></pre>
@@ -559,7 +552,7 @@ inline void save_construct_data(
Archive &amp; ar, const my_class * t, const unsigned int file_version
){
// save data required to construct instance
ar &lt;&lt; t-&gt;m_attribute;
ar &lt;&lt; t-&gt;member;
}
template&lt;class Archive&gt;
@@ -567,10 +560,10 @@ inline void load_construct_data(
Archive &amp; ar, my_class * t, const unsigned int file_version
){
// retrieve data from archive required to construct new instance
int attribute;
ar &gt;&gt; attribute;
int m;
ar &gt;&gt; m;
// invoke inplace constructor to initialize instance of my_class
::new(t)my_class(attribute);
::new(t)my_class(m);
}
}} // namespace ...
</code></pre>
@@ -723,6 +716,22 @@ would never be instantiated. So in addition to including export key
strings in an archive, <code style="white-space: normal">BOOST_CLASS_EXPORT_GUID</code> explicitly
instantiates the class serialization code for all archive classes used
by the program.
<p>
In order to do this,
<a href="../../../boost/serialization/export.hpp" target="export_hpp">export.hpp</a>
includes meta programming code to build a <code style="white-space: normal">mpl::list</code>
of all the file types used by the module by checking for definition of the header
inclusion guards.
Using this list,
<code style="white-space: normal">BOOST_CLASS_EXPORT_GUID</code> will explicitly instantiate serialization
code for all exported classes.
For this implementaton to function, the header file
<a href="../../../boost/serialization/export.hpp" target="export_hpp">export.hpp</a>
has to come after all the archive header files. This is enforced
by code at the end of the header file:
<a href="../../../boost/archive/basic_archive.hpp" target="basic_archive_hpp">basic_archive.hpp</a>
which will trip a STATIC_ASSERT if this requirement is violated.
<h4><a name="selectivetracking">Selective Tracking</a></h4>
Whether or not an object is tracked is determined by its
@@ -790,10 +799,7 @@ class derived : public base {
// method 1 : invoke base class serialization
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;base *&gt;(NULL),
static_cast&lt;derived *&gt;(NULL)
)
boost::serialization::void_cast_register&lt;derived, base&gt;();
}
};
+94 -136
View File
@@ -36,9 +36,6 @@ http://www.boost.org/LICENSE_1_0.txt)
</dl>
<dt><a href="#binary_archives">Binary Archives</a>
<dt><a href="#xml_archives">XML Archives</a>
<dt><a href="#dlls">DLLS - Serialization and Runtime Linking</a>
<dt><a href="#multi_threading">Multi-Threading</a>
<dt><a href="#optimizations">Optimizations</a>
<dt><a href="exceptions.html">Archive Exceptions</a>
<dt><a href="exception_safety.html">Exception Safety</a>
</dl>
@@ -157,50 +154,103 @@ BOOST_CLASS_TRACKING(my_virtual_base_class, boost::serialization::track_always)
<a target="detail" href="traits.html#export">Elsewhere</a> in this manual, we have described
<code style="white-space: normal">BOOST_CLASS_EXPORT</code>. This is used to make the serialization library aware
that code should be instantiated for serialization of a given class even though the
class hasn't been otherwise referred to by the program. This functionality
is necessary to implement serialization of pointers through a virtual base
class pointer. That is, a polymorphic pointer.
class hasn't been otherwise referred to by the program.
<p>
This macro specifies a "<b>G</b>lobally <b>U</b>nique <b>ID</b>entifier".
This is an string which identifies the class to be created when data is loaded.
Generally a text representation of the class name is sufficient for this purpose,
but in certain cases it maybe necessary to specify a different string by using
<code style="white-space: normal">BOOST_CLASS_EXPORT_GUID</code>
rather than a simple
<code style="white-space: normal">BOOST_CLASS_EXPORT</code>.
There are several ways <code style="white-space: normal">BOOST_CLASS_EXPORT</code> could have been
implemented.
<p>
<code style="white-space: normal">BOOST_CLASS_EXPORT</code> would usually
be specified in the same header file as the class declaration to which it
corresponds. That is, <code style="white-space: normal">BOOST_CLASS_EXPORT(T)</code>
is a "trait" of the class T. So a program using this class will look
something like:
<pre><code>
#include &lt;boost/archive/xml_oarchive.hpp&gt;
.... // any other archive classes
#include "my_class.hpp" // which contains BOOST_CLASS_EXPORT(my_class)
</code></pre>
These headers can be in any order. (In boost versions 1.34
and earlier, the archive headers had to go before any headers which
contain <code style="white-space: normal">BOOST_CLASS_EXPORT</code>.)
Any code required to serialize types specified
by <code style="white-space: normal">BOOST_CLASS_EXPORT</code> will be
instantiated for each archive whose header is included. (note that the code
is instantiated regardless of whether or not it is actually invoked.)
If no archive headers are included - no code should be instantiated.
This will permit <code style="white-space: normal">BOOST_CLASS_EXPORT</code>
to be a permanent part of the <code style="white-space: normal">my_class.hpp</code> .
One approach would be to instantiate serialization code for all archive classes included in the library.
This would add to each executable a large amount of code that is most likely never called.
Also it would needlessly slow down compilations of any program that uses the library. Finally,
the list of archives would be "built-in" to the library which would compilicate the addition of
new or custom archive classes.
<p>
Note that the implementation of this functionality depends upon vendor
specific extensions to the C++ language. So, there is no guarenteed portability
of programs which use this facility. However, all C++ compilers which
are tested with boost provide the required extensions. The library
includes the extra declarations required by each of these compilers.
It's reasonable to expect that future C++ compilers will support
these extensions or something equivalent.
Another approach would be for the library user to somehow explicitly instantiate which archive classes
code should be instantiated for each class to be serialized. Users would have to include
header files corresponding the archive classes to be instantiated.
The list of instantiated archive classes would have to be manually kept in sync with the
archive class headers actually included. This was considered burdensome and error prone.
<p>
This implementation of <code style="white-space: normal">BOOST_CLASS_EXPORT</code> works in the
following way:
<ul>
<li>All header modules of the form &lt;boost/archive/*archive.hpp&gt; are required to precede
the header module <a href="../../../boost/serialization/export.hpp" target="export_hpp">export.hpp</a>.
<li>The header <a href="../../../boost/serialization/export.hpp" target="export_hpp">export.hpp</a>
builds a list of archive classes whose header modules have been previously included.
It does this by checking to see which inclusion guard constants have been defined.
The header <a href="../../../boost/archive/detail/known_archive_types.hpp" target="known_archive_types_hpp">known_archive_types.hpp</a>
lists the archive header files which whose include guards will be checked. If you create your own
archive class, you probably want to edit this file.
<li><code style="white-space: normal">BOOST_CLASS_EXPORT(my_class)</code> explicitly instantiates
serialization code for <code style="white-space: normal">my_class</code> for each archive in the list.
</ul>
Serialization code will be instantiated for a given archive class
if and only if the module that defines that archive class has been included in the program.
Given this, our program will contain all necessary code instantiations and no other.
<p>
For many styles of code organization this header sequencing requirement presents little problem.
Serialization code organized by class headers that are designed to be independent of archive
implementations will look something like the following:
<code><pre>
// A.hpp
// Note:to preserve independence from any particular archive implementation,
// no headers from &lt;boost/archive/...&gt; are included.
// Headers can be included in any order.
#include &lt;boost/serialization/...&gt;
#include &lt;boost/serialization/export.hpp&gt;
... // include other headers that A depends upon
class A {
...
};
BOOST_CLASS_EXPORT(A) // note: the export name of this class
</pre></code>
This style:
<ul>
<li>permits the header to include all aspects of the serialization implementation.
<li>permits the header to be included anywhere else as part of some other class declaration.
<li>reflects the concept of headers as a "library of types" which
can be used independently in other programs or other parts of the same program.
<li>reflects a fundamental principle of the serialization library design in that the
specification of serialization of any class is independent of any archive implementation.
</ul>
However, it might not always be possible or convenient to conform to the above style. Something
like the following might be required or preferred:
<code><pre>
// A.hpp
// headers can be included in any order
#include &lt;boost/archive/text_oarchive.hpp&gt;
#include &lt;boost/archive/text_iarchive.hpp&gt;
...
#include &lt;boost/serialization/...&gt;
...
// can't do the following because then A.hpp couldn't be included somewhere else
// #include &lt;boost/serialization/export.hpp&gt;
class A {
...
};
// can't do the following because export.hpp is not included !!
//BOOST_CLASS_EXPORT(A) // note: the export name of this class
</pre></code>
As noted in the comments, this would work. But
<code style="white-space: normal">#include &lt;.../export.hpp&gt;</code> can't be used
without conflicting with other modules which use
<code style="white-space: normal">#include &lt;.../*archive.hpp&gt;</code>. In this
case we can move the export to an implementation file:
<code><pre>
// A.cpp
#include "A.hpp"
...
// export.hpp header should be last;
#include &lt;boost/serialization/export.hpp&gt;
...
BOOST_CLASS_EXPORT(A)
...
</pre></code>
<h3><a name="classinfo">Class Information</a></h3>
By default, for each class serialized, class information is written to the archive.
@@ -261,16 +311,6 @@ saved. For example, the gcc compiler reserves 4 bytes to store a variable of ty
So its possible that a value could be written that couldn't be represented by the loading program. This is a
fairly obvious situation and easily handled by using the numeric types in
<a target="cstding" href="../../../boost/cstdint.hpp">&lt;boost/cstdint.hpp&gt;</a>
<P>
A special integral type is <code>std::size_t</code> which is a typedef
of an integral types guaranteed to be large enough
to hold the size of any collection, but its actual size can differ depending
on the platform. The
<a href="wrappers.html#collection_size_type"><code>collection_size_type</code></a>
wrapper exists to enable a portable serialization of collection sizes by an archive.
Recommended choices for a portable serialization of collection sizes are to
use either 64-bit or variable length integer representation.
<h4><a name="traits">Traits</a></h4>
Another potential problem is illustrated by the following example:
@@ -345,88 +385,6 @@ just the value portion of the data is serialized. The name portion is discarded
So by always using <a target="detail" href="wrappers.html#nvp">name-value pairs</a>, it will
be guarenteed that all data can be serialized to all archive classes with maximum efficiency.
<h3><a name="dlls">DLLS - Serialization and Runtime Linking</a></h3>
Serialization code can be placed in libraries to be linked at runtime. That is,
code can be placed in DLLS(Windows) or Shared Libraries(*nix).
Along with the "export" facility, this
permits a program to written without knowledge of the actual types to be serialized.
This package doesn't include an example of this technique - but coding would be
very similar to the example
<a href = "../example/demo_pimpl.cpp" target="demo_pimpl">
<code style="white-space: normal">demo_pimpl.cpp</code>
</a>,
<a href = "../example/demo_pimpl_A.cpp" target="demo_pimpl">
<code style="white-space: normal">demo_pimpl_A.cpp</code>
</a>
and
<a href = "../example/demo_pimpl_A.hpp" target="demo_pimpl">
<code style="white-space: normal">demo_pimpl_A.hpp</code>
</a>
where implementation of serializaton is completely separate
from the main program.
<h3><a name="multi_threading">Multi-Threading</a></h3>
The nature of serialization would conflict with multiple thread concurrently
writing/reading from/to a single open archive. Since each archive is
independent from ever other one, there should be no problem
in having multiple open archives from one or more threads.
<p>
Well, not quite.
<p>
There are a couple of global data structures for holding
information of serializable types. These structures are
used to dispatch to correct code to handle each pair
of serializable types and archive types. Since this
information is shared among all archives, there is
potential for problems. This has been addressed
carefully implementing the library so that these
structures are all initialized before
<code style="white-space: normal">main(...)</code>
is called. From then on they are never altered. So
there SHOULD be no problem having mulitple archives
open simultaneously - be it from the same or different
threads.
<p>
Well, almost.
<p>
With dynamically loaded code - DLLS or Shared Libraries,
these global data structures can be altered when a library
is loaded or unloaded. That is, in this case, these
globa data structures can be altered after
<code style="white-space: normal">main(...)</code>
is called. So if a thread is dynamically loading/unloading
modules which contain serialization code while an
archive is open there could be problems. Also, if
such loading/unloading is happening concurrently
in different threads, there could also be problems.
<p>
It might not be easy to control this. Is possible that
some systems may not actually load modules until they
are actually needed. So even though we think that
there is not dynamic loading/unloading of such code
it could be occurring as "help" to manage resources.
On such systems, access to archive code would have
to be syncronized with some multi-threading construct
in order to be functional.
<h3><a name="optimizations">Optimizations</a></h3>
In performance critical applications that serialize large sets of contiguous data of homogeneous
types one wants to avoid the overhead of serializing each element individually, which is
the motivation for the <a href="wrappers.html#arrays"><code>array</code></a>
wrapper.
Serialization functions for data types containing contiguous arrays of homogeneous
types, such as for <code>std::vector</code>, <code>std::valarray</code> or
<code>boost::multiarray</code> should serialize them using an
<a href="wrappers.html#arrays"><code>array</code></a> wrapper to make use of
these optimizations.
Archive types that can provide optimized serialization for contiguous arrays of
homogeneous types should implement these by overloading the serialization of
the <a href="wrappers.html#arrays"><code>array</code></a> wrapper, as is done
for the binary archives.
<h3><a href="exceptions.html">Archive Exceptions</a></h3>
<h3><a href="exception_safety.html">Exception Safety</a></h3>
+2 -51
View File
@@ -32,7 +32,6 @@ http://www.boost.org/LICENSE_1_0.txt)
<dt><a href="#export">Export Key</a>
<dt><a href="#abstract">Abstract</a>
<dt><a href="#typeinfo">Type Information Implementation</a>
<dt><a href="#wrappers">Wrappers</a>
<dt><a href="#templates">Template Serialization Traits</a>
</dl>
Serialization of data depends on the type of the data. For example, for
@@ -256,8 +255,6 @@ addressable in one over several ways:
<li>use the macro <code style="white-space: normal">BOOST_IS_ABSTRACT(my_class)</code> to indicate
that the class is an abstract base class. This will cause the compiler
to avoid generating code that causes this error.
This macro must be used in the global namespace, with full namespace
qualification of the argument class.
</ul>
<h3><a name="typeinfo">Type Information Implementation</a></h3>
This last trait is also related to the serialization of objects
@@ -314,50 +311,6 @@ This is illustrated by the test program
Other implementations are possible and might be necessary for
certain special cases.
version.hpp</a>.
<h3><a name="wrappers">Wrappers</a></h3>
Archives need to treat wrappers diffently from other types since, for example,
they usually are non-const object while output archives require that any
serialized object (with the exception of a wrapper) be const.
This header file <a href="../../../boost/serialization/wrapper.hpp">wrapper.hpp</a>
includes the following code:
<pre><code>
namespace boost {
namespace serialization {
template&lt;class T&gt;
struct is_wrapper
: public mpl::false_
{};
} // namespace serialization
} // namespace boost
</code></pre>
For any class <code style="white-space: normal">T</code>, The default definition
of <code style="white-space: normal">boost::serialization::is_wrapper&lt;T&gt;::value</code> is thus false.
If we want to declare that a class <code style="white-space: normal">my_class</code>
is a wrapper we specialize the version template:
<pre><code>
namespace boost {
namespace serialization {
struct is_wrapper&lt;my_class&gt;
: mpl::true_
{};
} // namespace serialization
} // namespace boost
</code></pre>
<p>
To diminish typing and enhance readability, a macro is defined
so that instead of the above, we could write:
<pre><code>
BOOST_CLASS_IS_WRAPPER(my_class)
</code></pre>
which expands to the code above.
<h3><a name="templates">Template Serialization Traits</a></h3>
In some instances it might be convenient to assign serialization traits
to a whole group of classes at once. Consider, the name-value pair
@@ -454,8 +407,7 @@ template&lt;
int Level,
int Tracking,
unsigned int Version = 0,
class ETII = BOOST_SERIALIZATION_DEFAULT_TYPE_INFO(T),
class IsWrapper = mpl::false_
class ETII = BOOST_SERIALIZATION_DEFAULT_TYPE_INFO(T)
&gt;
struct traits
</code></pre>
@@ -468,11 +420,10 @@ and template parameters should be assigned according to the following table:
<tr><td><code>Tracking</code></td><td>tracking level</td><td><code>track_never<br>track_selectivly<br>track_always</code></td><td>none</td></tr>
<tr><td><code>Version</code></td><td><code>class version</td><td>unsigned integer</td><td><code>0</code></td></tr>
<tr><td><code>ETTI</code></td><td><code>type_info</code> implementation</td><td><code>extended_type_info_typeid<br>extended_type_info_no_rtti</code></td><td>default <code>type_info implementation</code></td></tr>
<tr><td><code>IsWrapper</code></td><td><code></code>is the type a wrapper?</td><td><code>mpl::false_<br>mpl::true_</code></td><td><code>mpl::false_</code></td></tr>
</table>
<hr>
<p><i>&copy; Copyright <a href="http://www.rrsd.com">Robert Ramey</a> 2002-2004 and Matthias Troyer 2006.
<p><i>&copy; Copyright <a href="http://www.rrsd.com">Robert Ramey</a> 2002-2004.
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>
+2 -5
View File
@@ -539,11 +539,8 @@ This is described later in the manual.
<dt><a href="../example/demo_xml.cpp" target="demo_xml_cpp">demo_xml.cpp</a>
<dd>This is a variation the original demo which supports xml archives in addition
to the others. The extra wrapping macro, BOOST_SERIALIZATION_NVP(name), is
needed to associate a data item name with the corresponding xml
tag. It is importanted that 'name' be a valid xml tag, else it
will be impossible to restore the archive.
For more information see
to the others. The extra wrapping macros are needed to associate a data
item name with the corresponding xml tag. For more information see
<a target="detail" href="wrappers.html#nvp">Name-Value Pairs</a>.
<a href="../example/demo_save.xml" target="demo_save_xml">Here</a>
is what an xml archive looks like.
+4 -71
View File
@@ -27,9 +27,7 @@ http://www.boost.org/LICENSE_1_0.txt)
<hr>
<dl class="page-index">
<dt><a href="#binaryobjects">Binary Objects</a>
<dt><a href="#arrays">Arrays</a>
<dt><a href="#strong_type"><code style="white-space: normal">BOOST_STRONG_TYPEDEF</code></a>
<dt><a href="#collection_size_type">Collection Sizes</a>
<dt><a href="#nvp">Name-Value Pairs</a>
<dt><a href="#composition">Composition</a>
</dl>
@@ -38,9 +36,6 @@ of some underlying data. This permits an archive class to define special
handling of this type. The library includes several such types for varying
purposes.
<p>
Wrappers need to be treated in a special way by some archives, and hence
the <A href="traits.html#wrappers"><code>is_wrapper</code></a> trait for
these wrapper classes is set to true.
<h3><a name="binaryobjects">Binary Objects</a></h3>
A binary object is just an sequence of bytes stored as raw
@@ -61,45 +56,6 @@ Its default serialization is to use archive class primitives
Note that it doesn't allocated any storage or create any objects.
Its sole purpose is to pass the data size and address as pair to the archive class.
<h3><a name="arrays">Arrays</a></h3>
An array is a contiguous sequence of homogeneous data types, such as a builtin
C-array, a <code>boost::array&lt;T></code> or a <code>std::vector&lt;T></code>.
The purpose of this wrapper is to support archive types (such as binary
archives) that provide optimized serialization for contiguous sequences of
objects of the same type.
The header file
<a href="../../../boost/serialization/array.hpp" target="array_hpp">
array.hpp
</a>
includes the function
<pre><code>
template &lt;T>
boost::serialization::make_array(T* t, std::size_t size);
</code></pre>
which will construct a temporary <code>array</code> object
<pre><code>
template<class T>
class array
{
public:
typedef T value_type;
array(value_type* t, std::size_t s);
value_type* address() const;
std::size_t count() const;
};
</code></pre>
that can be serialized just like any other object.
Its default serialization is to use serialize each array element.
Note that it doesn't allocated any storage or create any objects.
Its sole purpose is to pass the data type, size and address to the archive class.
Archive types that can provide optimized implementations for contiguous
arrays of homogeneous data types should overload the serialization of
<code>array</code>.
<h3><a name="strong_type"><code style="white-space: normal">BOOST_STRONG_TYPEDEF</code></h3>
Another example of a serialization wrapper is the
<a href="strong_typedef.html"><code style="white-space: normal">BOOST_STRONG_TYPEDEF</code></a> template.
@@ -111,26 +67,6 @@ as an XML attribute in the form "version=12". In the absence of any specific ov
these types are automatically converted to the underlying integer type so the
special overrides used for XML archives aren't needed for other archives.
<h3><a name="collection_size_type">Collection Sizes</h3>
An example of a strong typedef is the <code>collection_size_type</code> in the
header file
<a href="../../../boost/serialization/collection_size_type.hpp" target="collection_size_type_hpp">
collection_size_type.hpp
</a>. This type should be used for serializaing the size of a C++ collection, so
that the archive can pick the best integral representation for the serialization
of collection sizes. This is necessary since, although <code>std::size_t</code>
is guaranteed to be an integral type large enough to represent the size of
a collection on a specific platform, the archive might want to serialize
the size differently than this type. For example, the <code>collection_size_type</code>
might be serialized as a variable length integer in a portable binary archive.
<h3><a name="nvp">Name-Value Pairs</h3>
XML archives present a somewhat special case. XML format has a nested
structure that maps well to the "recursive class member visitor" pattern used
@@ -184,15 +120,12 @@ Similarly there exists a macro definition that permits us to write:
<pre><code>
BOOST_SERIALIZATION_BASE_OBJECT_NVP(my_base_class)
</code></pre>
Note that these macros must be used in the namespace of the class,
and without qualifying the namespace in the argument.
<p>
<a href="../example/demo_gps.hpp" target="demo_gps_hpp">demo_gps.hpp<a>
includes NVP wrappers or all data members.
Included is
<a href="../example/demo_xml.hpp" target="demo_xml_hpp">demo_xml.hpp<a>
which renders it's data members as <strong>name-value-pair</strong>s and
<a href="../example/demo_xml.cpp" target="demo_xml_cpp">demo_xml.cpp<a>
saves and loads data to an XML archive.
which saves and loads data to an XML archive.
<a href="../example/demo_save.xml" target="demo_save_xml">Here</a>
is example of the XML Archive corresponding to our tutorial example.
-41
View File
@@ -1,41 +0,0 @@
# Boost serialization Library Build Jamfile
# (C) Copyright Robert Ramey 2002-2004.
# Use, modification, and distribution are 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/libs/serialization for the library home page.
subproject libs/serialization/example ;
rule demo-bsl-build ( demo-name )
{
exe $(demo-name)
: # sources
$(demo-name).cpp
<lib>../build/boost_serialization
: # requirements
# copy to a path rooted at BOOST_ROOT:
<locate>$(BOOST_ROOT)
<include>$(BOOST_ROOT)
<sysinclude>$(BOOST_ROOT)
<borland><*><cxxflags>-w-8080
<msvc><release><cxxflags>-Gy
<vc7><release><cxxflags>-Gy
<vc-7_0><release><cxxflags>-Gy
<vc-7_1><release><cxxflags>-Gy
: # default build
debug
;
}
demo-bsl-build demo ;
demo-bsl-build demo_auto_ptr ;
demo-bsl-build demo_exception ;
demo-bsl-build demo_fast_archive ;
demo-bsl-build demo_pimpl ;
demo-bsl-build demo_portable_archive ;
demo-bsl-build demo_shared_ptr ;
demo-bsl-build demo_xml ;
demo-bsl-build demo_xml_save ;
demo-bsl-build demo_xml_load ;
-1
View File
@@ -20,7 +20,6 @@
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/utility.hpp>
#include <boost/serialization/list.hpp>
#include <boost/serialization/is_abstract.hpp>
/////////////////////////////////////////////////////////////
// The intent of this program is to serve as a tutorial for
+14
View File
@@ -133,6 +133,13 @@ int main(int argc, char *argv[])
std::ofstream ofs(filename.c_str());
boost::archive::text_oarchive oa(ofs);
oa.register_type(static_cast<B *>(NULL));
oa.register_type(
static_cast<
boost::detail::sp_counted_base_impl<
B *, boost::checked_deleter<B>
> *
>(NULL)
);
oa << spa;
oa << spa1;
}
@@ -150,6 +157,13 @@ int main(int argc, char *argv[])
// restore the schedule from the archive
ia.register_type(static_cast<B *>(NULL));
ia.register_type(
static_cast<
boost::detail::sp_counted_base_impl<
B *, boost::checked_deleter<B>
> *
>(NULL)
);
ia >> spa;
ia >> spa1;
}
+1 -1
View File
@@ -24,7 +24,7 @@ namespace std{
#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include "demo_gps.hpp"
#include "demo_xml.hpp"
void save_schedule(const bus_schedule &s, const char * filename){
// make an archive
@@ -1,9 +1,9 @@
#ifndef BOOST_SERIALIZATION_EXAMPLE_DEMO_GPS_HPP
#define BOOST_SERIALIZATION_EXAMPLE_DEMO_GPS_HPP
#ifndef BOOST_SERIALIZATION_EXAMPLE_DEMO_XML_HPP
#define BOOST_SERIALIZATION_EXAMPLE_DEMO_XML_HPP
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
//
// demo_gps.hpp
// demo_xml.hpp
//
// (C) Copyright 2002-4 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
@@ -281,4 +281,4 @@ std::ostream & operator<<(std::ostream &os, const bus_schedule &bs)
return os;
}
#endif // BOOST_SERIALIZATION_EXAMPLE_DEMO_GPS_HPP
#endif // BOOST_SERIALIZATION_EXAMPLE_DEMO_XML_HPP
+1 -1
View File
@@ -13,7 +13,7 @@
#include <boost/archive/xml_iarchive.hpp>
#include "demo_gps.hpp"
#include "demo_xml.hpp"
void
restore_schedule(bus_schedule &s, const char * filename)
+1 -1
View File
@@ -13,7 +13,7 @@
#include <boost/archive/xml_oarchive.hpp>
#include "demo_gps.hpp"
#include "demo_xml.hpp"
void save_schedule(const bus_schedule &s, const char * filename){
// make an archive
+1 -17
View File
@@ -55,8 +55,7 @@ class portable_binary_iarchive :
portable_binary_iarchive,
std::istream::char_type,
std::istream::traits_type
>,
public boost::archive::detail::shared_ptr_helper
>
{
typedef boost::archive::binary_iarchive_impl<
portable_binary_iarchive,
@@ -93,27 +92,12 @@ public:
*first = x;
}
#endif
// extend sign if necessary
if((l >> (size - 1) * 8) & 0x80){
l |= (-1 << (size * 8));
}
}
// default fall through for any types not specified here
template<class T>
void load(T & t){
this->primitive_base_t::load(t);
}
void load(unsigned short & t){
long l;
load_impl(l, sizeof(unsigned short));
t = l;
}
void load(short & t){
long l;
load_impl(l, sizeof(short));
t = l;
}
void load(unsigned int & t){
long l;
load_impl(l, sizeof(unsigned int));
+6 -24
View File
@@ -52,25 +52,13 @@ public:
friend class boost::archive::basic_binary_oarchive<portable_binary_oarchive>;
friend class boost::archive::save_access;
#endif
void save_impl(const long l){
void save_impl(long l){
long ll = l;
char size = 0;
if(l < 0){
// make sure that enough of data is output
// to include a high order bit indicating the sign
char x;
do{
x = ll;
ll >>= 8;
++size;
}while(ll != -1 && x < 0);
}
else{
do{
ll >>= 8;
++size;
}while(ll != 0);
}
char size = 0;;
do{
ll >>= 8;
++size;
}while(ll != -1 && ll != 0);
this->archive_base_t::save(size);
@@ -96,12 +84,6 @@ public:
void save(const T & t){
this->primitive_base_t::save(t);
}
void save(const short t){
save_impl(t);
}
void save(const unsigned short t){
save_impl(t);
}
void save(const unsigned int t){
save_impl(t);
}
-132
View File
@@ -1,132 +0,0 @@
#ifndef BOOST_ARCHIVE_ARRAY_IARCHIVE_HPP
#define BOOST_ARCHIVE_ARRAY_IARCHIVE_HPP
// (C) Copyright 2005 Matthias Troyer and Dave Abrahams
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/archive/basic_archive.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/archive/detail/common_iarchive.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/array.hpp>
#include <boost/serialization/collection_size_type.hpp>
#include <boost/serialization/detail/get_data.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/pfto.hpp>
namespace boost { namespace archive { namespace array {
// To conveniently array-optimize an input archive X:
//
// * Derive it from iarchive<X, Impl>, where Impl is an
// archive implementation base class from
// Boost.Serialization
//
// * add a member function template that implements the
// procedure for serializing arrays of T (for appropriate T)
//
// template <class T>
// load_array(serialization::array<T> &, unsigned int)
//
// * add a unary MPL lambda expression member called
// use_array_optimization whose result is convertible to
// mpl::true_ iff array elements of type T can be serialized
// with the load_array member function, and to mpl::false_ if
// the unoptimized procedure must be used.
template <class Archive>
class iarchive
: public archive::detail::common_iarchive<Archive>
{
typedef archive::detail::common_iarchive<Archive> Base;
public:
iarchive(unsigned int flags)
: archive::detail::common_iarchive<Archive>(flags)
{}
// save_override for std::vector and serialization::array dispatches to
// save_optimized with an additional argument.
//
// If that argument is of type mpl::true_, an optimized serialization is provided
// If it is false, we just forward to the default serialization in the base class
//the default version dispatches to the base class
template<class T>
void load_optimized(T &t, unsigned int version, mpl::false_)
{
Base::load_override(t, version);
}
// the optimized implementation for vector uses serialization::array
template<class U, class Allocator>
void load_optimized(
std::vector<U, Allocator> &t, unsigned int version, mpl::true_)
{
t.clear();
// retrieve number of elements
serialization::collection_size_type count;
*this->This() >> BOOST_SERIALIZATION_NVP(count);
t.resize(count);
if (!t.empty())
* this->This() >> serialization::make_array(serialization::detail::get_data(t),t.size());
}
// the optimized implementation for serialization::array uses save_array
template<class ValueType>
void load_optimized(
serialization::array<ValueType> &t, unsigned int version, mpl::true_)
{
this->This()->load_array(t,version);
}
// to load a vector:
// if the value type is trivially constructable or an optimized array save exists,
// then we can use the optimized version
template<class ValueType, class Allocator>
void load_override(std::vector<ValueType,Allocator> &x, unsigned int version)
{
typedef typename mpl::and_<
mpl::not_<is_same<ValueType,bool> >,
mpl::apply1<
BOOST_DEDUCED_TYPENAME Archive::use_array_optimization
, ValueType>
>::type use_optimized;
load_optimized(x,version, use_optimized() );
}
// dispatch loading of arrays to the optimized version where supported
template<class ValueType>
void load_override(serialization::array<ValueType> const& x, unsigned int version)
{
typedef typename mpl::apply1<
BOOST_DEDUCED_TYPENAME Archive::use_array_optimization
, ValueType
>::type use_optimized;
load_optimized(const_cast<serialization::array<ValueType>&>(x),version,use_optimized());
}
// Load everything else in the usual way, forwarding on to the base class
template<class T>
void load_override(T & x, unsigned BOOST_PFTO int version)
{
Base::load_override(x, static_cast<unsigned int>(version));
}
};
} } } // end namespace boost::archive::array
#endif // BOOST_ARCHIVE_ARRAY_OARCHIVE_HPP
-130
View File
@@ -1,130 +0,0 @@
#ifndef BOOST_ARCHIVE_ARRAY_OARCHIVE_HPP
#define BOOST_ARCHIVE_ARRAY_OARCHIVE_HPP
// (C) Copyright 2005 Matthias Troyer and Dave Abrahams
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/archive/basic_archive.hpp>
#include <boost/archive/detail/common_oarchive.hpp>
#include <boost/serialization/array.hpp>
#include <boost/serialization/collection_size_type.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/detail/get_data.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/pfto.hpp>
namespace boost { namespace archive { namespace array {
// To conveniently array-optimize an output archive X:
//
// * Derive it from oarchive<X, Impl>, where Impl is an
// archive implementation base class from
// Boost.Serialization
//
// * add a member function template that implements the
// procedure for serializing arrays of T (for appropriate T)
//
// template <class T>
// save_array(serialization::array<T> const &, unsigned int)
//
// * add a unary MPL lambda expression member called
// use_array_optimization whose result is convertible to
// mpl::true_ iff array elements of type T can be serialized
// with the load_array member function, and to mpl::false_ if
// the unoptimized procedure must be used.
template <class Archive>
class oarchive
: public archive::detail::common_oarchive<Archive>
{
typedef archive::detail::common_oarchive<Archive> Base;
public:
oarchive(unsigned int flags)
: archive::detail::common_oarchive<Archive>(flags)
{}
// save_override for std::vector and serialization::array dispatches to
// save_optimized with an additional argument.
//
// If that argument is of type mpl::true_, an optimized serialization is provided
// If it is false, we just forward to the default serialization in the base class
//the default version dispatches to the base class
template<class T>
void save_optimized(T const &t, unsigned int version, mpl::false_)
{
Base::save_override(t, version);
}
// the optimized implementation for vector uses serialization::array
template<class ValueType, class Allocator>
void save_optimized(
const std::vector<ValueType, Allocator> &t, unsigned int, mpl::true_)
{
const serialization::collection_size_type count(t.size());
* this->This() << BOOST_SERIALIZATION_NVP(count);
if (!t.empty())
* this->This() << serialization::make_array(serialization::detail::get_data(t),t.size());
}
// the optimized implementation for serialization::array uses save_array
template<class ValueType>
void save_optimized(
const serialization::array<ValueType> &t, unsigned int version, mpl::true_)
{
this->This()->save_array(t,version);
}
// to save a vector:
// if the value type is trivially constructable or an optimized array save exists,
// then we can use the optimized version
template<class ValueType, class Allocator>
void save_override(std::vector<ValueType,Allocator> const &x, unsigned int version)
{
typedef BOOST_DEDUCED_TYPENAME remove_const<ValueType>::type value_type;
typedef typename mpl::and_<
mpl::not_<is_same<value_type,bool> >,
mpl::apply1<
BOOST_DEDUCED_TYPENAME Archive::use_array_optimization
, value_type>
>::type use_optimized;
save_optimized(x,version,use_optimized() );
}
// dispatch saving of arrays to the optimized version where supported
template<class ValueType>
void save_override(serialization::array<ValueType> const& x, unsigned int version)
{
typedef typename mpl::apply1<
BOOST_DEDUCED_TYPENAME Archive::use_array_optimization
, BOOST_DEDUCED_TYPENAME remove_const<ValueType>::type
>::type use_optimized;
save_optimized(x,version,use_optimized());
}
// Load everything else in the usual way, forwarding on to the
// Base class
template<class T>
void save_override(T const& x, unsigned BOOST_PFTO int version)
{
Base::save_override(x, static_cast<unsigned int>(version));
}
};
} } } // end namespace boost::archive::array
#endif // BOOST_ARCHIVE_ARRAY_OARCHIVE_HPP
+10
View File
@@ -117,4 +117,14 @@ BOOST_CLASS_IMPLEMENTATION(boost::archive::object_id_type, primitive_type)
BOOST_CLASS_IMPLEMENTATION(boost::archive::object_reference_type, primitive_type)
BOOST_CLASS_IMPLEMENTATION(boost::archive::tracking_type, primitive_type)
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// Make sure that the export.hpp header isn't included before any archive header
// Doing so would inhibit construction of correct mpl list of known archive
// types which in turn would inhibit instantiation of all combinations of
// serialization/archive types.
#ifdef BOOST_SERIALIZATION_EXPORT_HPP
#error "export.hpp must not be included before any archive header"
#endif
#endif //BOOST_ARCHIVE_BASIC_ARCHIVE_HPP
+14 -18
View File
@@ -28,9 +28,9 @@
#include <boost/detail/workaround.hpp>
#include <boost/pfto.hpp>
#include <boost/archive/detail/common_iarchive.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/collection_size_type.hpp>
#include <boost/archive/array/iarchive.hpp>
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
namespace boost {
@@ -40,7 +40,7 @@ namespace archive {
// class basic_binary_iarchive - read serialized objects from a input binary stream
template<class Archive>
class basic_binary_iarchive :
public array::iarchive<Archive>
public detail::common_iarchive<Archive>
{
protected:
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
@@ -56,10 +56,11 @@ public:
// fot templates in the absence of partial function
// template ordering. If we get here pass to base class
// note extra nonsense to sneak it pass the borland compiers
typedef array::iarchive<Archive> array_iarchive;
typedef detail::common_iarchive<Archive> detail_common_iarchive;
template<class T>
void load_override(T & t, BOOST_PFTO int){
this->array_iarchive::load_override(t, 0);
void load_override(T & t, BOOST_PFTO int)
{
this->detail_common_iarchive::load_override(t, 0);
}
// binary files don't include the optional information
void load_override(class_id_optional_type & /* t */, int){}
@@ -68,44 +69,39 @@ public:
// for these pseudo prmitive types.
void load_override(version_type & t, int){
// upto 255 versions
unsigned char x=0;
unsigned char x;
* this->This() >> x;
t = version_type(x);
}
void load_override(class_id_type & t, int){
// upto 32K classes
int_least16_t x=0;
int_least16_t x;
* this->This() >> x;
t = class_id_type(x);
}
void load_override(class_id_reference_type & t, int){
// upto 32K classes
int_least16_t x=0;
int_least16_t x;
* this->This() >> x;
t = class_id_reference_type(x);
}
void load_override(object_id_type & t, int){
// upto 2G objects
uint_least32_t x=0;
uint_least32_t x;
* this->This() >> x;
t = object_id_type(x);
}
void load_override(object_reference_type & t, int){
// upto 2G objects
uint_least32_t x=0;
uint_least32_t x;
* this->This() >> x;
t = object_reference_type(x);
}
void load_override(tracking_type & t, int){
char x=0;
char x;
* this->This() >> x;
t = (0 != x);
}
void load_override(serialization::collection_size_type & t, int){
unsigned int x=0;
* this->This() >> x;
t = serialization::collection_size_type(x);
}
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
load_override(class_name_type & t, int);
@@ -113,7 +109,7 @@ public:
init();
basic_binary_iarchive(unsigned int flags) :
array_iarchive(flags)
detail::common_iarchive<Archive>(flags)
{}
};
@@ -48,9 +48,6 @@ namespace std{
#include <boost/archive/basic_streambuf_locale_saver.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/archive/detail/auto_link_archive.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/type_traits/is_fundamental.hpp>
#include <boost/serialization/array.hpp>
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
namespace boost {
@@ -89,7 +86,6 @@ public:
load_binary(& t, sizeof(t));
int i = t;
assert(0 == i || 1 == i);
(void)i; // warning suppression for release builds.
}
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
load(std::string &s);
@@ -112,16 +108,6 @@ public:
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
~basic_binary_iprimitive();
public:
// we provide an optimized load for all fundamental types
typedef is_fundamental<mpl::_1> use_array_optimization;
// the optimized load_array dispatches to load_binary
template <class ValueType>
void load_array(serialization::array<ValueType>& a, unsigned int)
{
load_binary(a.address(),a.count()*sizeof(ValueType));
}
void
load_binary(void *address, std::size_t count);
};
@@ -160,7 +146,7 @@ basic_binary_iprimitive<Archive, Elem, Tr>::load_binary(
static_cast<Elem *>(address),
s
);
if(scount != static_cast<std::size_t>(s))
if(count != static_cast<std::size_t>(s))
boost::throw_exception(
archive_exception(archive_exception::stream_error)
);
@@ -171,7 +157,7 @@ basic_binary_iprimitive<Archive, Elem, Tr>::load_binary(
// boost::throw_exception(archive_exception(archive_exception::stream_error));
Elem t;
scount = m_sb.sgetn(& t, 1);
if(scount != 1)
if(count != 1)
boost::throw_exception(
archive_exception(archive_exception::stream_error)
);
+13 -22
View File
@@ -27,10 +27,8 @@
#include <boost/pfto.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/archive/array/oarchive.hpp>
#include <boost/archive/detail/common_oarchive.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/collection_size_type.hpp>
#include <boost/archive/array/oarchive.hpp>
namespace boost {
namespace archive {
@@ -43,9 +41,12 @@ namespace archive {
// by a program built with the same tools for the same machne. This class
// 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.
/////////////////////////////////////////////////////////////////////////
// class basic_text_iarchive - read serialized objects from a input text stream
template<class Archive>
class basic_binary_oarchive :
public array::oarchive<Archive>
public detail::common_oarchive<Archive>
{
protected:
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
@@ -58,14 +59,10 @@ public:
friend class detail::interface_oarchive<Archive>;
#endif
// any datatype not specifed below will be handled by base class
typedef array::oarchive<Archive> array_oarchive;
template<class T>
void save_override(const T & t, BOOST_PFTO int){
this->array_oarchive::save_override(t, 0);
}
typedef detail::common_oarchive<Archive> detail_common_oarchive;
template<class T>
void save_override(T & t, BOOST_PFTO int){
this->save_override(const_cast<const T &>(t), 0);
this->detail_common_oarchive::save_override(t, 0);
}
// binary files don't include the optional information
void save_override(const class_id_optional_type & /* t */, int){}
@@ -73,22 +70,22 @@ public:
void save_override(const version_type & t, int){
// upto 255 versions
// note:t.t resolves borland ambguity
const unsigned char x = t.t;
unsigned char x = t.t;
* this->This() << x;
}
void save_override(const class_id_type & t, int){
// upto 32K classes
const int_least16_t x = t.t;
int_least16_t x = t.t;
* this->This() << x;
}
void save_override(const class_id_reference_type & t, int){
// upto 32K classes
const int_least16_t x = t.t;
int_least16_t x = t.t;
* this->This() << x;
}
void save_override(const object_id_type & t, int){
// upto 2G objects
const uint_least32_t x = t.t;
uint_least32_t x = t.t;
* this->This() << x;
}
void save_override(const object_reference_type & t, int){
@@ -97,7 +94,7 @@ public:
* this->This() << x;
}
void save_override(const tracking_type & t, int){
const char x = t.t;
char x = t.t;
* this->This() << x;
}
@@ -107,17 +104,11 @@ public:
* this->This() << s;
}
void save_override(const serialization::collection_size_type & t, int){
// for backward compatibility, 64 bit integer or variable length integer would be preferred
unsigned int x = t.t;
* this->This() << x;
}
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
init();
basic_binary_oarchive(unsigned int flags) :
array_oarchive(flags)
detail::common_oarchive<Archive>(flags)
{}
};
@@ -46,9 +46,6 @@ namespace std{
#include <boost/archive/basic_streambuf_locale_saver.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/archive/detail/auto_link_archive.hpp>
#include <boost/type_traits/is_fundamental.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/serialization/array.hpp>
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
namespace boost {
@@ -104,7 +101,6 @@ public:
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
init();
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
basic_binary_oprimitive(
std::basic_streambuf<Elem, Tr> & sb,
@@ -113,16 +109,6 @@ public:
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
~basic_binary_oprimitive();
public:
// we provide an optimized save for all fundamental types
typedef is_fundamental<mpl::_1> use_array_optimization;
// the optimized save_array dispatches to save_binary
template <class ValueType>
void save_array(serialization::array<ValueType> const& a, unsigned int)
{
save_binary(a.address(),a.count()*sizeof(ValueType));
}
void save_binary(const void *address, std::size_t count);
};
@@ -61,7 +61,7 @@ public:
{
this->detail_common_iarchive::load_override(t, 0);
}
#if 0
// Borland compilers has a problem with strong type. Try to fix this here
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
void load_override(version_type & t, int){
@@ -70,7 +70,7 @@ public:
t.t = version_type(x);
}
#endif
#endif
// text file don't include the optional information
void load_override(class_id_optional_type & /*t*/, int){}
+19 -22
View File
@@ -78,39 +78,36 @@ public:
// start new objects on a new line
void save_override(const object_id_type & t, int){
this->This()->newline();
// note extra .t to funciton with Borland 5.51 compiler
// and invoke prmitive to underlying value
// and and invoke prmitive to underlying value
this->This()->save(t.t);
}
void save_override(const object_reference_type & t, int){
this->This()->newline();
// note extra .t to funciton with Borland 5.51 compiler
// and invoke prmitive to underlying value
// and and invoke prmitive to underlying value
this->This()->save(t.t);
}
// note the following four overrides are necessary for some borland
// compilers(5.51) which don't handle BOOST_STRONG_TYPE properly.
void save_override(const version_type & t, int){
// note:t.t resolves borland ambguity
const unsigned int x = t.t;
* this->This() << x;
}
void save_override(const class_id_type & t, int){
// note:t.t resolves borland ambguity
const int x = t.t;
* this->This() << x;
}
void save_override(const class_id_reference_type & t, int){
// note:t.t resolves borland ambguity
const int x = t.t;
* this->This() << x;
}
// text file don't include the optional information
void save_override(const class_id_optional_type & /* t */, int){}
// note the following four overrides are necessary for some borland
// compilers which don't handle BOOST_STRONG_TYPE properly.
void save_override(const version_type & t, int){
// note:t.t resolves borland ambguity
unsigned int x = t.t;
* this->This() << x;
}
void save_override(const class_id_type & t, int){
// note:t.t resolves borland ambguity
int x = t.t;
* this->This() << x;
}
void save_override(const class_id_reference_type & t, int){
// note:t.t resolves borland ambguity
int x = t.t;
* this->This() << x;
}
void save_override(const class_name_type & t, int){
const std::string s(t);
* this->This() << s;
+6 -9
View File
@@ -9,7 +9,7 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_xml_iarchive.hpp
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// (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)
@@ -25,8 +25,6 @@
#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
namespace boost {
@@ -35,7 +33,7 @@ namespace archive {
/////////////////////////////////////////////////////////////////////////
// class xml_iarchive - read serialized objects from a input text stream
template<class Archive>
class basic_xml_iarchive :
class basic_xml_iarchive :
public detail::common_iarchive<Archive>
{
protected:
@@ -62,8 +60,7 @@ public:
// 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);
BOOST_STATIC_ASSERT(0 == sizeof(T));
}
// Anything not an attribute - see below - should be a name value
@@ -74,7 +71,7 @@ public:
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
const
#endif
boost::serialization::nvp<T> & t,
boost::serialization::nvp<T> & t,
int
){
load_start(t.name());
@@ -104,9 +101,9 @@ public:
// handle this.
// void load_override(class_name_type & t, int);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
basic_xml_iarchive(unsigned int flags);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
~basic_xml_iarchive();
};
+10 -16
View File
@@ -9,7 +9,7 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_xml_oarchive.hpp
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// (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)
@@ -24,18 +24,15 @@
#include <boost/serialization/tracking.hpp>
#include <boost/serialization/string.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
namespace boost {
namespace boost {
namespace archive {
//////////////////////////////////////////////////////////////////////
// class basic_xml_oarchive - write serialized objects to a xml output stream
template<class Archive>
class basic_xml_oarchive :
class basic_xml_oarchive :
public detail::common_oarchive<Archive>
{
protected:
@@ -45,10 +42,8 @@ public:
// for some inexplicable reason insertion of "class" generates compile erro
// on msvc 7.1
friend detail::interface_oarchive<Archive>;
friend class save_access;
#else
friend class detail::interface_oarchive<Archive>;
friend class save_access;
#endif
// special stuff for xml output
unsigned int depth;
@@ -60,13 +55,13 @@ public:
init();
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
write_attribute(
const char *attribute_name,
const char *attribute_name,
int t,
const char *conjunction = "=\""
);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
write_attribute(
const char *attribute_name,
const char *attribute_name,
const char *key
);
// helpers used below
@@ -85,8 +80,7 @@ public:
// 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);
BOOST_STATIC_ASSERT(0 == sizeof(T));
}
// special treatment for name-value pairs.
@@ -96,7 +90,7 @@ public:
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
const
#endif
::boost::serialization::nvp<T> & t,
::boost::serialization::nvp<T> & t,
int
){
save_start(t.name());
@@ -123,9 +117,9 @@ public:
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
save_override(const tracking_type & t, int);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
basic_xml_oarchive(unsigned int flags);
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
~basic_xml_oarchive();
};
+4 -41
View File
@@ -22,43 +22,6 @@
namespace boost {
namespace archive {
// do not derive from the classes below. If you want to extend this functionality
// via inhertance, derived from text_iarchive_impl instead. This will
// preserve correct static polymorphism.
// same as binary_iarchive below - without the shared_ptr_helper
class naked_binary_iarchive :
public binary_iarchive_impl<
boost::archive::naked_binary_iarchive,
std::istream::char_type,
std::istream::traits_type
>
{
public:
naked_binary_iarchive(std::istream & is, unsigned int flags = 0) :
binary_iarchive_impl<
naked_binary_iarchive, std::istream::char_type, std::istream::traits_type
>(is, flags)
{}
naked_binary_iarchive(std::streambuf & bsb, unsigned int flags = 0) :
binary_iarchive_impl<
naked_binary_iarchive, std::istream::char_type, std::istream::traits_type
>(bsb, flags)
{}
};
} // namespace archive
} // namespace boost
// note special treatment of shared_ptr. This type needs a special
// structure associated with every archive. We created a "mix-in"
// class to provide this functionality. Since shared_ptr holds a
// special esteem in the boost library - we included it here by default.
#include <boost/archive/shared_ptr_helper.hpp>
namespace boost {
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.
@@ -67,8 +30,7 @@ class binary_iarchive :
boost::archive::binary_iarchive,
std::istream::char_type,
std::istream::traits_type
>,
public detail::shared_ptr_helper
>
{
public:
binary_iarchive(std::istream & is, unsigned int flags = 0) :
@@ -86,7 +48,8 @@ public:
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_iarchive)
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::binary_iarchive)
#endif // BOOST_ARCHIVE_BINARY_IARCHIVE_HPP
+3 -4
View File
@@ -43,12 +43,11 @@ public:
{}
};
typedef binary_oarchive naked_binary_oarchive;
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_oarchive)
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::binary_oarchive)
#endif // BOOST_ARCHIVE_BINARY_OARCHIVE_HPP
+6 -39
View File
@@ -27,43 +27,9 @@
namespace boost {
namespace archive {
// same as binary_wiarchive below - without the shared_ptr_helper
class naked_binary_wiarchive :
public binary_iarchive_impl<
boost::archive::naked_binary_wiarchive,
std::wistream::char_type,
std::wistream::traits_type
>
{
public:
naked_binary_wiarchive(std::wistream & is, unsigned int flags = 0) :
binary_iarchive_impl<
naked_binary_wiarchive,
std::wistream::char_type,
std::wistream::traits_type
>(is, flags)
{}
naked_binary_wiarchive(std::wstreambuf & bsb, unsigned int flags = 0) :
binary_iarchive_impl<
naked_binary_wiarchive,
std::wistream::char_type,
std::wistream::traits_type
>(bsb, flags)
{}
};
} // namespace archive
} // namespace boost
// note special treatment of shared_ptr. This type needs a special
// structure associated with every archive. We created a "mix-in"
// class to provide this functionality. Since shared_ptr holds a
// special esteem in the boost library - we included it here by default.
#include <boost/archive/shared_ptr_helper.hpp>
namespace boost {
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_wiarchive :
public binary_iarchive_impl<
binary_wiarchive, std::wistream::char_type, std::wistream::traits_type
@@ -85,8 +51,9 @@ public:
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_wiarchive)
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::binary_wiarchive)
#endif // BOOST_NO_STD_WSTREAMBUF
#endif // BOOST_ARCHIVE_BINARY_WIARCHIVE_HPP
+3 -4
View File
@@ -48,13 +48,12 @@ public:
{}
};
typedef binary_woarchive naked_binary_woarchive;
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_woarchive)
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::binary_woarchive)
#endif // BOOST_NO_STD_WSTREAMBUF
#endif // BOOST_ARCHIVE_BINARY_WOARCHIVE_HPP
+2 -4
View File
@@ -25,16 +25,14 @@ namespace std{
#if defined(__LIBCOMO__)
using ::mbstate_t;
#elif defined(__QNXNTO__)
//using std::mbstate_t;
using std::mbstate_t;
#elif defined(BOOST_DINKUMWARE_STDLIB) && BOOST_DINKUMWARE_STDLIB == 1
using ::mbstate_t;
#elif defined(__SGI_STL_PORT)
#elif defined(BOOST_NO_STDC_NAMESPACE)
using ::codecvt;
using ::mbstate_t;
#elif defined(BOOST_RWSTD_VER)
using ::mbstate_t;
#endif
#endif
} // namespace std
namespace boost {
@@ -13,8 +13,3 @@
# pragma warning(push)
# pragma warning(disable : 4251 4231 4660 4275)
#endif
#if defined( __BORLANDC__ )
#pragma nopushoptwarn
#endif
@@ -12,8 +12,3 @@
#pragma warning(pop)
#endif
#include <boost/config/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
#if defined( __BORLANDC__ )
#pragma nopushoptwarn
#endif
@@ -20,6 +20,7 @@
// #include <boost/scoped_ptr.hpp>
#include <set>
#include <boost/shared_ptr.hpp>
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
@@ -34,6 +35,48 @@ namespace detail {
//////////////////////////////////////////////////////////////////////
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_archive_impl
{
//////////////////////////////////////////////////////////////////////
// list of serialization helpers
// at least one compiler sunpro 5.3 erroneously doesn't give access to embedded structs
struct helper_compare;
friend struct helper_compare;
struct helper_type {
shared_ptr<void> m_helper;
const boost::serialization::extended_type_info * m_eti;
helper_type(
shared_ptr<void> h,
const boost::serialization::extended_type_info * const eti
) :
m_helper(h),
m_eti(eti)
{}
};
struct helper_compare {
bool operator()(
const helper_type & lhs,
const helper_type & rhs
) const {
return lhs.m_eti < rhs.m_eti;
}
};
typedef std::set<helper_type, helper_compare> collection;
typedef collection::iterator helper_iterator;
typedef collection::const_iterator helper_const_iterator;
collection m_helpers;
protected:
void
lookup_helper(
const boost::serialization::extended_type_info * const eti,
shared_ptr<void> & sph
);
void
insert_helper(
const boost::serialization::extended_type_info * const eti,
shared_ptr<void> & sph
);
};
} // namespace detail
@@ -65,8 +65,16 @@ protected:
public:
// note: NOT part of the public API.
void next_object_pointer(void *t);
void register_basic_serializer(
const basic_iserializer & bis
void register_basic_serializer(const basic_iserializer & bis);
void
lookup_basic_helper(
const boost::serialization::extended_type_info * const eti,
shared_ptr<void> & sph
);
void
insert_basic_helper(
const boost::serialization::extended_type_info * const eti,
shared_ptr<void> & sph
);
void load_object(
void *t,
@@ -62,7 +62,7 @@ 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);
basic_oarchive(unsigned int flags);
// account for bogus gcc warning
#if defined(__GNUC__)
virtual
@@ -70,17 +70,24 @@ protected:
~basic_oarchive();
public:
// note: NOT part of the public interface
void register_basic_serializer(
const BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oserializer & bos
void register_basic_serializer(const basic_oserializer & bos);
void
lookup_basic_helper(
const boost::serialization::extended_type_info * const eti,
shared_ptr<void> & sph
);
void
insert_basic_helper(
const boost::serialization::extended_type_info * const eti,
shared_ptr<void> & sph
);
void save_object(
const void *x,
const BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oserializer & bos
const basic_oserializer & bos
);
void save_pointer(
const void * t,
const BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
basic_pointer_oserializer * bpos_ptr
const basic_pointer_oserializer * bpos_ptr
);
void save_null_pointer(){
vsave(NULL_POINTER_TAG);
@@ -19,7 +19,6 @@
#include <boost/archive/detail/basic_iarchive.hpp>
#include <boost/archive/detail/interface_iarchive.hpp>
#include <boost/archive/detail/iserializer.hpp>
#include <boost/archive/detail/register_archive.hpp>
#include <boost/pfto.hpp>
namespace boost {
@@ -32,7 +31,6 @@ class common_iarchive :
public basic_iarchive,
public interface_iarchive<Archive>
{
friend class interface_iarchive<Archive>;
private:
virtual void vload(version_type & t){
* this->This() >> t;
@@ -63,7 +61,7 @@ protected:
void load_start(const char *name){}
void load_end(const char *name){}
// default archive initialization
common_iarchive(unsigned int flags = 0) :
common_iarchive(unsigned int flags) :
basic_iarchive(flags),
interface_iarchive<Archive>()
{}
@@ -19,7 +19,6 @@
#include <boost/archive/detail/basic_oarchive.hpp>
#include <boost/archive/detail/interface_oarchive.hpp>
#include <boost/archive/detail/oserializer.hpp>
#include <boost/archive/detail/register_archive.hpp>
namespace boost {
namespace archive {
@@ -31,7 +30,6 @@ class common_oarchive :
public basic_oarchive,
public interface_oarchive<Archive>
{
friend class interface_oarchive<Archive>;
private:
virtual void vsave(const version_type t){
* this->This() << t;
@@ -63,9 +61,10 @@ protected:
void save_override(T & t, BOOST_PFTO int){
archive::save(* this->This(), t);
}
void save_start(const char *name){}
void save_end(const char *name){}
common_oarchive(unsigned int flags = 0) :
common_oarchive(unsigned int flags) :
basic_oarchive(flags),
interface_oarchive<Archive>()
{}
@@ -1,45 +0,0 @@
// Copyright David Abrahams 2006. 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)
#ifndef BOOST_ARCHIVE_DETAIL_DYNAMICALLY_INITIALIZED_DWA2006524_HPP
# define BOOST_ARCHIVE_DETAIL_DYNAMICALLY_INITIALIZED_DWA2006524_HPP
# include <boost/serialization/force_include.hpp>
namespace boost { namespace archive { namespace detail {
//
// Provides a dynamically-initialized (singleton) instance of T in a
// way that avoids LNK1179 on vc6. See http://tinyurl.com/ljdp8 or
// http://lists.boost.org/Archives/boost/2006/05/105286.php for
// details.
//
template <class T>
struct dynamically_initialized
{
protected:
static T& instance;
private:
static T& get_instance();
#if defined(__GNUC__)
// Workaround "warning: all member functions in class `
// boost::archive::detail::dynamically_initialized<T>' are private"
public:
void work_around_gcc_warning();
#endif
};
template <class T>
T& dynamically_initialized<T>::instance
= dynamically_initialized<T>::get_instance();
template <class T>
T& dynamically_initialized<T>::get_instance()
{
static T instance_;
return instance_;
}
}}} // namespace boost::archive::detail
#endif // BOOST_ARCHIVE_DETAIL_DYNAMICALLY_INITIALIZED_DWA2006524_HPP
@@ -28,7 +28,6 @@ class shared_ptr;
namespace serialization {
class extended_type_info;
} // namespace serialization
namespace archive {
namespace detail {
@@ -51,13 +50,28 @@ public:
}
template<class T>
const BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_iserializer *
register_type(T * = NULL){
const BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_iserializer & bpis =
pointer_iserializer<Archive, T>::get_instance();
const basic_pointer_iserializer * register_type(T * = NULL){
const basic_pointer_iserializer & bpis =
instantiate_pointer_iserializer(
static_cast<Archive *>(NULL),
static_cast<T *>(NULL)
);
this->This()->register_basic_serializer(bpis.get_basic_serializer());
return & bpis;
}
void lookup_helper(
const boost::serialization::extended_type_info * const eti,
boost::shared_ptr<void> & sph
){
this->This()->lookup_basic_helper(eti, sph);
}
void insert_helper(
const boost::serialization::extended_type_info * const eti,
shared_ptr<void> & sph
){
this->This()->insert_basic_helper(eti, sph);
}
template<class T>
Archive & operator>>(T & t){
this->This()->load_override(t, 0);
@@ -51,14 +51,29 @@ public:
}
template<class T>
const BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_oserializer *
register_type(const T * = NULL){
const BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_oserializer & bpos =
pointer_oserializer<Archive, T>::get_instance();
const basic_pointer_oserializer * register_type(const T * = NULL){
const basic_pointer_oserializer & bpos =
instantiate_pointer_oserializer(
static_cast<Archive *>(NULL),
static_cast<T *>(NULL)
);
this->This()->register_basic_serializer(bpos.get_basic_serializer());
return & bpos;
}
void lookup_helper(
const boost::serialization::extended_type_info * const eti,
boost::shared_ptr<void> & sph
){
this->This()->lookup_basic_helper(eti, sph);
}
void insert_helper(
const boost::serialization::extended_type_info * const eti,
shared_ptr<void> & sph
){
this->This()->insert_basic_helper(eti, sph);
}
template<class T>
Archive & operator<<(T & t){
this->This()->save_override(t, 0);
+62 -51
View File
@@ -44,7 +44,6 @@ namespace std{
#include <boost/type_traits/is_enum.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/remove_all_extents.hpp>
#include <boost/serialization/is_abstract.hpp>
#include <boost/mpl/eval_if.hpp>
@@ -58,7 +57,6 @@ namespace std{
#include <boost/mpl/list.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/bool.hpp>
#ifndef BOOST_SERIALIZATION_DEFAULT_TYPE_INFO
#include <boost/serialization/extended_type_info_typeid.hpp>
@@ -67,7 +65,7 @@ namespace std{
#include <boost/archive/detail/basic_iarchive.hpp>
#include <boost/archive/detail/basic_iserializer.hpp>
#include <boost/archive/detail/archive_pointer_iserializer.hpp>
#include <boost/archive/detail/dynamically_initialized.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/serialization/force_include.hpp>
#include <boost/serialization/serialization.hpp>
@@ -76,9 +74,9 @@ namespace std{
#include <boost/serialization/tracking.hpp>
#include <boost/serialization/type_info_implementation.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/binary_object.hpp>
#include <boost/serialization/void_cast.hpp>
#include <boost/serialization/array.hpp>
#include <boost/serialization/collection_size_type.hpp>
namespace boost {
namespace serialization {
@@ -123,13 +121,13 @@ public:
return boost::serialization::implementation_level<T>::value
>= boost::serialization::object_class_info;
}
virtual bool tracking(const unsigned int /* flags */) const {
virtual bool tracking(const unsigned int flags) const {
// if(0 != (flags & no_tracking))
// return false;
return boost::serialization::tracking_level<T>::value
== boost::serialization::track_always
|| boost::serialization::tracking_level<T>::value
== boost::serialization::track_selectively
== boost::serialization::track_selectivly
&& serialized_as_pointer();
}
virtual unsigned int version() const {
@@ -142,7 +140,7 @@ public:
>::type::is_polymorphic::type typex;
return typex::value;
}
static iserializer & get_instance(){
static iserializer & instantiate(){
static iserializer instance;
return instance;
}
@@ -164,14 +162,15 @@ BOOST_DLLEXPORT void iserializer<Archive, T>::load_object_data(
);
}
template<class Archive, class T>
class pointer_iserializer
: public archive_pointer_iserializer<Archive>
, public dynamically_initialized<pointer_iserializer<Archive,T> >
// instantiation of this template creates a static object. Note inversion of
// normal argument order to workaround bizarre error in MSVC 6.0 which only
// manifests iftself during compiler time.
template<class T, class Archive>
class pointer_iserializer : public archive_pointer_iserializer<Archive>
{
private:
virtual const basic_iserializer & get_basic_serializer() const {
return iserializer<Archive, T>::get_instance();
return iserializer<Archive, T>::instantiate();
}
virtual BOOST_DLLEXPORT void load_object_ptr(
basic_iarchive & ar,
@@ -183,18 +182,32 @@ public:
#endif
// private constructor to inhibit any existence other than the
// static one. Note GCC doesn't permit constructor to be private
BOOST_DLLEXPORT pointer_iserializer() BOOST_USED;
friend struct dynamically_initialized<pointer_iserializer<Archive,T> >;
explicit BOOST_DLLEXPORT pointer_iserializer() BOOST_USED;
static const pointer_iserializer instance;
public:
// at least one compiler (CW) seems to require that serialize_adl
// be explicitly instantiated. Still under investigation.
#if !defined(__BORLANDC__)
#if ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
void (* const m)(Archive &, T &, const unsigned);
boost::serialization::extended_type_info * (* e)();
#endif
BOOST_DLLEXPORT static const pointer_iserializer & get_instance() BOOST_USED;
static BOOST_DLLEXPORT const pointer_iserializer & instantiate() BOOST_USED;
virtual ~pointer_iserializer(){};
};
template<class T, class Archive>
BOOST_DLLEXPORT const pointer_iserializer<T, Archive> &
pointer_iserializer<T, Archive>::instantiate() {
return instance;
}
// note: instances of this template to be constructed before the main
// is called in order for things to be initialized properly. For this
// reason, hiding the instance in a static function as was done above
// won't work here so we created a free instance here.
template<class T, class Archive>
const pointer_iserializer<T, Archive> pointer_iserializer<T, Archive>::instance;
// note trick to be sure that operator new is using class specific
// version if such exists. Due to Peter Dimov.
// note: the following fails if T has no default constructor.
@@ -265,15 +278,19 @@ private:
T* m_p;
};
template<class Archive, class T>
BOOST_DLLEXPORT void pointer_iserializer<Archive, T>::load_object_ptr(
template<class T, class Archive>
BOOST_DLLEXPORT void pointer_iserializer<T, Archive>::load_object_ptr(
basic_iarchive & ar,
void * & x,
const unsigned int file_version
) const
{
) const {
Archive & ar_impl = boost::smart_cast_reference<Archive &>(ar);
// if(0 != (ar.get_flags() & no_object_creation)){
// ar_impl >> boost::serialization::make_nvp(NULL, * static_cast<T *>(x));
// return;
// }
auto_ptr_with_deleter<T> ap(heap_allocator<T>::invoke());
if(NULL == ap.get())
boost::throw_exception(std::bad_alloc()) ;
@@ -295,7 +312,6 @@ BOOST_DLLEXPORT void pointer_iserializer<Archive, T>::load_object_ptr(
);
}
BOOST_CATCH(...){
ap.release();
BOOST_RETHROW;
}
BOOST_CATCH_END
@@ -304,32 +320,25 @@ BOOST_DLLEXPORT void pointer_iserializer<Archive, T>::load_object_ptr(
ap.release();
}
template<class Archive, class T>
#if !defined(__BORLANDC__)
BOOST_DLLEXPORT pointer_iserializer<Archive, T>::pointer_iserializer() :
template<class T, class Archive>
#if ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
BOOST_DLLEXPORT pointer_iserializer<T, Archive>::pointer_iserializer() :
archive_pointer_iserializer<Archive>(
* boost::serialization::type_info_implementation<T>::type::get_instance()
),
m(boost::serialization::serialize_adl<Archive, T>),
e(boost::serialization::type_info_implementation<T>::type::get_instance)
#else
BOOST_DLLEXPORT pointer_iserializer<Archive, T>::pointer_iserializer() :
BOOST_DLLEXPORT pointer_iserializer<T, Archive>::pointer_iserializer() :
archive_pointer_iserializer<Archive>(
* boost::serialization::type_info_implementation<T>::type::get_instance()
)
#endif
{
iserializer<Archive, T> & bis = iserializer<Archive, T>::get_instance();
iserializer<Archive, T> & bis = iserializer<Archive, T>::instantiate();
bis.set_bpis(this);
}
template<class Archive, class T>
BOOST_DLLEXPORT const pointer_iserializer<Archive, T> &
pointer_iserializer<Archive, T>::get_instance() {
// note: comeau complains without full qualification
return dynamically_initialized<pointer_iserializer<Archive,T> >::instance;
}
template<class Archive, class T>
struct load_non_pointer_type {
// note this bounces the call right back to the archive
@@ -361,7 +370,7 @@ struct load_non_pointer_type {
// its not called that way - so fix it her
typedef BOOST_DEDUCED_TYPENAME boost::remove_const<T>::type typex;
void * x = & const_cast<typex &>(t);
ar.load_object(x, iserializer<Archive, T>::get_instance());
ar.load_object(x, iserializer<Archive, T>::instantiate());
}
};
@@ -497,8 +506,6 @@ struct load_enum_type {
template<class Archive, class T>
struct load_array_type {
static void invoke(Archive &ar, T &t){
typedef typename remove_all_extents<T>::type value_type;
// convert integers to correct enum to load
int current_count = sizeof(t) / (
static_cast<char *>(static_cast<void *>(&t[1]))
@@ -510,11 +517,12 @@ struct load_array_type {
boost::throw_exception(archive::archive_exception(
boost::archive::archive_exception::array_size_too_short
));
ar >> serialization::make_array(static_cast<value_type*>(&t[0]),count);
int i;
for(i = 0; i < count; ++i)
ar >> boost::serialization::make_nvp("item", t[i]);
}
};
#if 0
// note bogus arguments to workaround msvc 6 silent runtime failure
template<class Archive, class T>
BOOST_DLLEXPORT
@@ -531,9 +539,10 @@ instantiate_pointer_iserializer(
Archive * /* ar = NULL */,
T * /* t = NULL */
){
return pointer_iserializer<Archive,T>::instance;
// note: reversal of order of arguments to work around msvc 6.0 bug
// that manifests itself while trying to link.
return pointer_iserializer<T, Archive>::instantiate();
}
#endif
} // detail
@@ -563,7 +572,7 @@ inline void load(Archive &ar, T &t){
// BORLAND
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560))
// borland has a couple of problems
// borland has a couple fo problems
// a) if function is partiall specialized - see below
// const paramters are transformed to non-const ones
// b) implementation of base_object can't be made to work
@@ -576,19 +585,21 @@ inline void load(Archive &ar, const T & t){
}
#endif
// let wrappers through.
// let wrappers through. (Someday implement is_wrapper)
#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));
inline void load(Archive &ar, const serialization::nvp<T> &t){
boost::archive::load(ar, const_cast<serialization::nvp<T> &>(t));
}
template<class Archive>
inline void load(Archive &ar, const serialization::binary_object &t){
boost::archive::load(ar, const_cast<serialization::binary_object &>(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
//template<class Archive, class T>
//inline void load(Archive &ar, const serialization::binary_object &t){
// load(ar, const_cast<binary_object &>(t));
//}
#endif
} // namespace archive
@@ -0,0 +1,93 @@
#ifndef BOOST_ARCHIVE_KNOWN_ARCHIVE_TYPES_HPP
#define BOOST_ARCHIVE_KNOWN_ARCHIVE_TYPES_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// known_archive_types.hpp: set traits of classes to be serialized
// (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.
// list of archive type shipped with the serialization system
#include <boost/mpl/list.hpp>
#include <boost/mpl/pop_front.hpp>
namespace boost {
namespace archive {
// class text_oarchive;
namespace detail {
class null_type;
struct known_archive_types {
typedef
mpl::pop_front<
mpl::list<
null_type
#if defined(BOOST_ARCHIVE_TEXT_OARCHIVE_HPP)
, boost::archive::text_oarchive
#endif
#if defined(BOOST_ARCHIVE_TEXT_IARCHIVE_HPP)
, boost::archive::text_iarchive
#endif
#if defined(BOOST_ARCHIVE_TEXT_WOARCHIVE_HPP)
, boost::archive::text_woarchive
#endif
#if defined(BOOST_ARCHIVE_TEXT_WIARCHIVE_HPP)
, boost::archive::text_wiarchive
#endif
#if defined(BOOST_ARCHIVE_BINARY_OARCHIVE_HPP)
, boost::archive::binary_oarchive
#endif
#if defined(BOOST_ARCHIVE_BINARY_IARCHIVE_HPP)
, boost::archive::binary_iarchive
#endif
#if defined(BOOST_ARCHIVE_BINARY_WOARCHIVE_HPP)
, boost::archive::binary_woarchive
#endif
#if defined(BOOST_ARCHIVE_BINARY_WIARCHIVE_HPP)
, boost::archive::binary_wiarchive
#endif
#if defined(BOOST_ARCHIVE_XML_OARCHIVE_HPP)
, boost::archive::xml_oarchive
#endif
#if defined(BOOST_ARCHIVE_XML_IARCHIVE_HPP)
, boost::archive::xml_iarchive
#endif
#if defined(BOOST_ARCHIVE_XML_WOARCHIVE_HPP)
, boost::archive::xml_woarchive
#endif
#if defined(BOOST_ARCHIVE_XML_WIARCHIVE_HPP)
, boost::archive::xml_wiarchive
#endif
#if defined(BOOST_ARCHIVE_POLYMORPHIC_OARCHIVE_HPP)
, boost::archive::polymorphic_oarchive
#endif
#if defined(BOOST_ARCHIVE_POLYMORPHIC_IARCHIVE_HPP)
, boost::archive::polymorphic_iarchive
#endif
#if defined(BOOST_ARCHIVE_CUSTOM_IARCHIVE_TYPES)
, BOOST_ARCHIVE_CUSTOM_IARCHIVE_TYPES
#endif
#if defined(BOOST_ARCHIVE_CUSTOM_OARCHIVE_TYPES)
, BOOST_ARCHIVE_CUSTOM_OARCHIVE_TYPES
#endif
>::type
>::type type;
};
} // namespace detail
} // namespace archive
} // namespace boost
#endif // BOOST_ARCHIVE_KNOWN_ARCHIVE_TYPES_HPP
@@ -0,0 +1,39 @@
#ifndef BOOST_ARCHIVE_KNOWN_ARCHIVE_TYPES_FWD_HPP
#define BOOST_ARCHIVE_KNOWN_ARCHIVE_TYPES_FWD_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// known_archive_types_fwd.hpp: set traits of classes to be serialized
// (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.
// list of archive type shipped with the serialization system
#include <boost/mpl/list.hpp>
namespace boost {
namespace archive {
namespace detail {
// default implementation of known_archive_types list - 0 elements
// used to generate warning when a polymporhic pointer is serialized
// to an unknown archive - export would otherwise fail silently
template<bool>
struct known_archive_types {
typedef mpl::list<> type;
};
} // namespace detail
} // namespace archive
} // namespace boost
#endif // BOOST_ARCHIVE_KNOWN_ARCHIVE_TYPES_FWD
+43 -41
View File
@@ -37,7 +37,6 @@
#include <boost/type_traits/is_volatile.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_all_extents.hpp>
#include <boost/serialization/is_abstract.hpp>
#include <boost/mpl/eval_if.hpp>
@@ -58,7 +57,6 @@
#include <boost/archive/detail/basic_oarchive.hpp>
#include <boost/archive/detail/basic_oserializer.hpp>
#include <boost/archive/detail/archive_pointer_oserializer.hpp>
#include <boost/archive/detail/dynamically_initialized.hpp>
#include <boost/serialization/force_include.hpp>
#include <boost/serialization/serialization.hpp>
@@ -68,8 +66,6 @@
#include <boost/serialization/type_info_implementation.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/void_cast.hpp>
#include <boost/serialization/array.hpp>
#include <boost/serialization/collection_size_type.hpp>
#include <boost/archive/archive_exception.hpp>
@@ -104,7 +100,7 @@ class oserializer : public basic_oserializer
private:
// private constructor to inhibit any existence other than the
// static one
explicit BOOST_DLLEXPORT oserializer() :
explicit oserializer() :
basic_oserializer(
* boost::serialization::type_info_implementation<T>::type::get_instance()
)
@@ -118,11 +114,11 @@ public:
return boost::serialization::implementation_level<T>::value
>= boost::serialization::object_class_info;
}
virtual bool tracking(const unsigned int /* flags */) const {
virtual bool tracking(const unsigned int flags) const {
// if(0 != (flags & no_tracking))
// return false;
return boost::serialization::tracking_level<T>::value == boost::serialization::track_always
|| boost::serialization::tracking_level<T>::value == boost::serialization::track_selectively
|| boost::serialization::tracking_level<T>::value == boost::serialization::track_selectivly
&& serialized_as_pointer();
}
virtual unsigned int version() const {
@@ -134,7 +130,7 @@ public:
>::type::is_polymorphic::type typex;
return typex::value;
}
static oserializer & get_instance(){
static oserializer & instantiate(){
static oserializer instance;
return instance;
}
@@ -155,14 +151,15 @@ BOOST_DLLEXPORT void oserializer<Archive, T>::save_object_data(
);
}
template<class Archive, class T>
class pointer_oserializer
: public archive_pointer_oserializer<Archive>
, public dynamically_initialized<pointer_oserializer<Archive,T> >
// instantiation of this template creates a static object. Note inversion of
// normal argument order to workaround bizarre error in MSVC 6.0 which only
// manifests iftself during compiler time.
template<class T, class Archive>
class pointer_oserializer : public archive_pointer_oserializer<Archive>
{
private:
virtual const basic_oserializer & get_basic_serializer() const {
return oserializer<Archive, T>::get_instance();
return oserializer<Archive, T>::instantiate();
}
virtual BOOST_DLLEXPORT void save_object_ptr(
basic_oarchive & ar,
@@ -174,19 +171,33 @@ public:
// private constructor to inhibit any existence other than the
// static one. Note GCC doesn't permit constructor to be private
explicit BOOST_DLLEXPORT pointer_oserializer() BOOST_USED;
friend struct dynamically_initialized<pointer_oserializer<Archive,T> >;
static const pointer_oserializer instance;
public:
#if !defined(__BORLANDC__)
#if ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
// at least one compiler (CW) seems to require that serialize_adl
// be explicitly instantiated. Still under investigation.
void (* const m)(Archive &, T &, const unsigned);
boost::serialization::extended_type_info * (* e)();
#endif
BOOST_DLLEXPORT static const pointer_oserializer & get_instance() BOOST_USED;
static BOOST_DLLEXPORT const pointer_oserializer & instantiate() BOOST_USED;
virtual ~pointer_oserializer(){}
};
template<class Archive, class T>
BOOST_DLLEXPORT void pointer_oserializer<Archive, T>::save_object_ptr(
template<class T, class Archive>
BOOST_DLLEXPORT const pointer_oserializer<T, Archive> &
pointer_oserializer<T, Archive>::instantiate(){
return instance;
}
// note: instances of this template to be constructed before the main
// is called in order for things to be initialized properly. For this
// reason, hiding the instance in a static function as was done above
// won't work here so we created a free instance here.
template<class T, class Archive>
const pointer_oserializer<T, Archive> pointer_oserializer<T, Archive>::instance;
template<class T, class Archive>
BOOST_DLLEXPORT void pointer_oserializer<T, Archive>::save_object_ptr(
basic_oarchive & ar,
const void * x
) const {
@@ -204,33 +215,26 @@ BOOST_DLLEXPORT void pointer_oserializer<Archive, T>::save_object_ptr(
ar_impl << boost::serialization::make_nvp(NULL, * t);
}
template<class Archive, class T>
#if !defined(__BORLANDC__)
BOOST_DLLEXPORT pointer_oserializer<Archive, T>::pointer_oserializer() :
template<class T, class Archive>
#if ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
BOOST_DLLEXPORT pointer_oserializer<T, Archive>::pointer_oserializer() :
archive_pointer_oserializer<Archive>(
* boost::serialization::type_info_implementation<T>::type::get_instance()
),
m(boost::serialization::serialize_adl<Archive, T>),
e(boost::serialization::type_info_implementation<T>::type::get_instance)
#else
BOOST_DLLEXPORT pointer_oserializer<Archive, T>::pointer_oserializer() :
BOOST_DLLEXPORT pointer_oserializer<T, Archive>::pointer_oserializer() :
archive_pointer_oserializer<Archive>(
* boost::serialization::type_info_implementation<T>::type::get_instance()
)
#endif
{
// make sure appropriate member function is instantiated
oserializer<Archive, T> & bos = oserializer<Archive, T>::get_instance();
oserializer<Archive, T> & bos = oserializer<Archive, T>::instantiate();
bos.set_bpos(this);
}
template<class Archive, class T>
BOOST_DLLEXPORT const pointer_oserializer<Archive, T> &
pointer_oserializer<Archive, T>::get_instance() {
// note: comeau complains without full qualification
return dynamically_initialized<pointer_oserializer<Archive,T> >::instance;
}
template<class Archive, class T>
struct save_non_pointer_type {
// note this bounces the call right back to the archive
@@ -256,7 +260,7 @@ struct save_non_pointer_type {
// serialization level and class version
struct save_standard {
static void invoke(Archive &ar, const T & t){
ar.save_object(& t, oserializer<Archive, T>::get_instance());
ar.save_object(& t, oserializer<Archive, T>::instantiate());
}
};
@@ -477,8 +481,6 @@ template<class Archive, class T>
struct save_array_type
{
static void invoke(Archive &ar, const T &t){
typedef typename remove_all_extents<T>::type value_type;
save_access::end_preamble(ar);
// consider alignment
int count = sizeof(t) / (
@@ -486,12 +488,12 @@ struct save_array_type
- static_cast<const char *>(static_cast<const void *>(&t[0]))
);
ar << BOOST_SERIALIZATION_NVP(count);
ar << serialization::make_array(static_cast<value_type const*>(&t[0]),count);
int i;
for(i = 0; i < count; ++i)
ar << boost::serialization::make_nvp("item", t[i]);
}
};
#if 0
// note bogus arguments to workaround msvc 6 silent runtime failure
// declaration to satisfy gcc
template<class Archive, class T>
@@ -507,9 +509,10 @@ instantiate_pointer_oserializer(
Archive * /* ar = NULL */,
T * /* t = NULL */
){
return pointer_oserializer<Archive, T>::instance;
// note: reversal of order of arguments to work around msvc 6.0 bug
// that manifests itself while trying to link.
return pointer_oserializer<T, Archive>::instantiate();
}
#endif
} // detail
@@ -554,13 +557,12 @@ struct check_tracking {
template<class Archive, class T>
inline void save(Archive & ar, T &t){
// if your program traps here, it indicates that your doing one of the following:
// if your program traps here, it indicates taht your doing one of the following:
// a) serializing an object of a type marked "track_never" through a pointer.
// b) saving an non-const object of a type not markd "track_never)
// Either of these conditions may be an indicator of an error usage of the
// serialization library and should be double checked. See documentation on
// object tracking. Also, see the "rationale" section of the documenation
// for motivation for this checking.
// object tracking.
BOOST_STATIC_ASSERT(check_tracking<T>::value);
save(ar, const_cast<const T &>(t));
}
@@ -1,5 +1,5 @@
#ifndef BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_DISPATCH_HPP
#define BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_DISPATCH_HPP
#ifndef BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_IMPL_HPP
#define BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_IMPL_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
@@ -7,7 +7,7 @@
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// polymorphic_iarchive_dispatch.hpp
// polymorphic_iarchive_impl.hpp
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
@@ -45,7 +45,7 @@ class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iserializer;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_iserializer;
template<class ArchiveImplementation>
class polymorphic_iarchive_dispatch :
class polymorphic_iarchive_impl :
public polymorphic_iarchive,
// note: gcc dynamic cross cast fails if the the derivation below is
// not public. I think this is a mistake.
@@ -161,8 +161,20 @@ private:
virtual void register_basic_serializer(const basic_iserializer & bis){
ArchiveImplementation::register_basic_serializer(bis);
}
virtual void lookup_basic_helper(
const boost::serialization::extended_type_info * const eti,
boost::shared_ptr<void> & sph
){
ArchiveImplementation::lookup_basic_helper(eti, sph);
}
virtual void insert_basic_helper(
const boost::serialization::extended_type_info * const eti,
boost::shared_ptr<void> & sph
){
ArchiveImplementation::insert_basic_helper(eti, sph);
}
public:
// this can't be inheriteded because they appear in mulitple
// this can't be inherited because they appear in mulitple
// parents
typedef mpl::bool_<true> is_loading;
typedef mpl::bool_<false> is_saving;
@@ -180,7 +192,7 @@ public:
// all current archives take a stream as constructor argument
template <class _Elem, class _Tr>
polymorphic_iarchive_dispatch(
polymorphic_iarchive_impl(
std::basic_istream<_Elem, _Tr> & is,
unsigned int flags = 0
) :
@@ -194,4 +206,4 @@ public:
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
#endif // BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_DISPATCH_HPP
#endif // BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_IMPL_HPP
@@ -1,5 +1,5 @@
#ifndef BOOST_ARCHIVE_DETAIL_POLYMORPHIC_OARCHIVE_DISPATCH_HPP
#define BOOST_ARCHIVE_DETAIL_POLYMORPHIC_OARCHIVE_DISPATCH_HPP
#ifndef BOOST_ARCHIVE_DETAIL_POLYMORPHIC_OARCHIVE_IMPL_HPP
#define BOOST_ARCHIVE_DETAIL_POLYMORPHIC_OARCHIVE_IMPL_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
@@ -7,7 +7,7 @@
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// polymorphic_oarchive_dispatch.hpp
// polymorphic_oarchive_impl.hpp
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
@@ -45,7 +45,7 @@ class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oserializer;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_oserializer;
template<class ArchiveImplementation>
class polymorphic_oarchive_dispatch :
class polymorphic_oarchive_impl :
public polymorphic_oarchive,
// note: gcc dynamic cross cast fails if the the derivation below is
// not public. I think this is a mistake.
@@ -151,8 +151,20 @@ private:
virtual void register_basic_serializer(const detail::basic_oserializer & bos){
ArchiveImplementation::register_basic_serializer(bos);
}
virtual void lookup_basic_helper(
const boost::serialization::extended_type_info * const eti,
shared_ptr<void> & sph
){
ArchiveImplementation::lookup_basic_helper(eti, sph);
}
virtual void insert_basic_helper(
const boost::serialization::extended_type_info * const eti,
shared_ptr<void> & sph
){
ArchiveImplementation::insert_basic_helper(eti, sph);
}
public:
// this can't be inheriteded because they appear in mulitple
// this can't be inherited because they appear in mulitple
// parents
typedef mpl::bool_<false> is_loading;
typedef mpl::bool_<true> is_saving;
@@ -168,7 +180,7 @@ public:
}
// all current archives take a stream as constructor argument
template <class _Elem, class _Tr>
polymorphic_oarchive_dispatch(
polymorphic_oarchive_impl(
std::basic_ostream<_Elem, _Tr> & os,
unsigned int flags = 0
) :
@@ -182,4 +194,4 @@ public:
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
#endif // BOOST_ARCHIVE_DETAIL_POLYMORPHIC_OARCHIVE_DISPATCH_HPP
#endif // BOOST_ARCHIVE_DETAIL_POLYMORPHIC_OARCHIVE_IMPL_HPP
@@ -1,47 +0,0 @@
// Copyright David Abrahams 2006. 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)
#ifndef BOOST_ARCHIVE_DETAIL_REGISTER_ARCHIVE_DWA2006521_HPP
# define BOOST_ARCHIVE_DETAIL_REGISTER_ARCHIVE_DWA2006521_HPP
# include <boost/type_traits/add_pointer.hpp>
namespace boost { namespace archive { namespace detail {
template <class Archive, class Serializable>
struct ptr_serialization_support;
// We could've just used ptr_serialization_support, above, but using
// it with only a forward declaration causes vc6/7 to complain about a
// missing instantiate member, even if it has one. This is just a
// friendly layer of indirection.
template <class Archive, class Serializable>
struct _ptr_serialization_support
: ptr_serialization_support<Archive,Serializable>
{
typedef int type;
};
// This function gets called, but its only purpose is to participate
// in overload resolution with the functions declared by
// BOOST_SERIALIZATION_REGISTER_ARCHIVE, below.
template <class Serializable>
void instantiate_ptr_serialization(Serializable*, int) {}
// The function declaration generated by this macro never actually
// gets called, but its return type gets instantiated, and that's
// enough to cause registration of serialization functions between
// Archive and any exported Serializable type. See also:
// boost/serialization/export.hpp
# define BOOST_SERIALIZATION_REGISTER_ARCHIVE(Archive) \
namespace boost { namespace archive { namespace detail { \
\
template <class Serializable> \
typename _ptr_serialization_support<Archive, Serializable>::type \
instantiate_ptr_serialization( Serializable*, Archive* ); \
\
}}}
}}} // namespace boost::archive::detail
#endif // BOOST_ARCHIVE_DETAIL_INSTANTIATE_SERIALIZE_DWA2006521_HPP
@@ -79,7 +79,7 @@ basic_binary_iprimitive<Archive, Elem, Tr>::load(wchar_t * ws)
{
std::size_t l;
this->This()->load(l);
load_binary(ws, l * sizeof(wchar_t) / sizeof(char));
load_binary(ws, l);
ws[l / sizeof(wchar_t)] = L'\0';
}
@@ -144,7 +144,7 @@ basic_xml_oarchive<Archive>::end_preamble(){
pending_preamble = false;
}
}
#if 0
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_xml_oarchive<Archive>::save_override(const object_id_type & t, int)
@@ -168,29 +168,6 @@ basic_xml_oarchive<Archive>::save_override(const version_type & t, int)
int i = t.t; // extra .t is for borland
write_attribute(VERSION(), i);
}
#endif
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_xml_oarchive<Archive>::save_override(const object_id_type & t, int)
{
write_attribute(OBJECT_ID(), t, "=\"_");
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_xml_oarchive<Archive>::save_override(
const object_reference_type & t,
int
){
write_attribute(OBJECT_REFERENCE(), t, "=\"_");
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_xml_oarchive<Archive>::save_override(const version_type & t, int)
{
write_attribute(VERSION(), t);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_xml_oarchive<Archive>::save_override(const class_id_type & t, int)
@@ -222,12 +199,11 @@ basic_xml_oarchive<Archive>::save_override(const class_name_type & t, int)
return;
write_attribute(CLASS_NAME(), key);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
basic_xml_oarchive<Archive>::save_override(const tracking_type & t, int)
{
write_attribute(TRACKING(), t.t);
write_attribute(TRACKING(), t.t); // extra .t is for borland
}
template<class Archive>
@@ -18,26 +18,23 @@
#include <boost/config.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/detail/polymorphic_iarchive_dispatch.hpp>
#include <boost/archive/detail/polymorphic_iarchive_impl.hpp>
namespace boost {
namespace archive {
class polymorphic_binary_iarchive :
public detail::polymorphic_iarchive_dispatch<naked_binary_iarchive>
{
public:
polymorphic_binary_iarchive(std::istream & is, unsigned int flags = 0) :
detail::polymorphic_iarchive_dispatch<naked_binary_iarchive>(is, flags)
{}
~polymorphic_binary_iarchive(){}
};
typedef detail::polymorphic_iarchive_impl<
binary_iarchive_impl<
binary_iarchive, std::istream::char_type, std::istream::traits_type
>
> polymorphic_binary_iarchive;
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
boost::archive::polymorphic_binary_iarchive
)
@@ -18,24 +18,23 @@
#include <boost/config.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/detail/polymorphic_oarchive_dispatch.hpp>
#include <boost/archive/detail/polymorphic_oarchive_impl.hpp>
namespace boost {
namespace archive {
typedef detail::polymorphic_oarchive_dispatch<
typedef detail::polymorphic_oarchive_impl<
binary_oarchive_impl<
naked_binary_oarchive,
std::ostream::char_type,
std::ostream::traits_type
binary_oarchive, std::ostream::char_type, std::ostream::traits_type
>
> polymorphic_binary_oarchive;
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
boost::archive::polymorphic_binary_oarchive
)
+14 -27
View File
@@ -32,7 +32,6 @@ namespace std{
#include <boost/archive/detail/iserializer.hpp>
#include <boost/archive/detail/interface_iarchive.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/archive/detail/register_archive.hpp>
// determine if its necessary to handle (u)int64_t specifically
// i.e. that its not a synonym for (unsigned) long
@@ -55,9 +54,7 @@ namespace detail {
class basic_iserializer;
}
class polymorphic_iarchive;
class polymorphic_iarchive_impl :
class polymorphic_iarchive :
public detail::interface_iarchive<polymorphic_iarchive>
{
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
@@ -101,13 +98,21 @@ 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 void lookup_basic_helper(
const boost::serialization::extended_type_info * const eti,
boost::shared_ptr<void> & sph
) = 0;
virtual void insert_basic_helper(
const boost::serialization::extended_type_info * const eti,
boost::shared_ptr<void> & sph
) = 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)
{
archive::load(* this->This(), t);
archive::load(* this, t);
}
// special treatment for name-value pairs.
template<class T>
@@ -119,11 +124,9 @@ public:
int
){
load_start(t.name());
archive::load(* this->This(), t.value());
archive::load(* this, t.value());
load_end(t.name());
}
protected:
virtual ~polymorphic_iarchive_impl(){}
public:
// utility function implemented by all legal archives
virtual void set_library_version(unsigned int archive_library_version) = 0;
@@ -154,24 +157,8 @@ public:
} // namespace archive
} // namespace boost
// note special treatment of shared_ptr. This type needs a special
// structure associated with every archive. We created a "mix-in"
// class to provide this functionality. Since shared_ptr holds a
// special esteem in the boost library - we included it here by default.
#include <boost/archive/shared_ptr_helper.hpp>
namespace boost {
namespace archive {
class polymorphic_iarchive :
public polymorphic_iarchive_impl,
public detail::shared_ptr_helper
{};
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::polymorphic_iarchive)
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::polymorphic_iarchive)
#endif // BOOST_ARCHIVE_POLYMORPHIC_IARCHIVE_HPP
+14 -15
View File
@@ -31,7 +31,6 @@ namespace std{
#include <boost/archive/detail/oserializer.hpp>
#include <boost/archive/detail/interface_oarchive.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/archive/detail/register_archive.hpp>
// determine if its necessary to handle (u)int64_t specifically
// i.e. that its not a synonym for (unsigned) long
@@ -54,9 +53,7 @@ namespace detail {
class basic_oserializer;
}
class polymorphic_oarchive;
class polymorphic_oarchive_impl :
class polymorphic_oarchive :
public detail::interface_oarchive<polymorphic_oarchive>
{
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
@@ -100,6 +97,14 @@ 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 void lookup_basic_helper(
const boost::serialization::extended_type_info * const eti,
boost::shared_ptr<void> & sph
) = 0;
virtual void insert_basic_helper(
const boost::serialization::extended_type_info * const eti,
shared_ptr<void> & sph
) = 0;
virtual void end_preamble() = 0;
@@ -108,7 +113,7 @@ public:
template<class T>
void save_override(T & t, BOOST_PFTO int)
{
archive::save(* this->This(), t);
archive::save(* this, t);
}
// special treatment for name-value pairs.
template<class T>
@@ -119,11 +124,9 @@ public:
::boost::serialization::nvp<T> & t, int
){
save_start(t.name());
archive::save(* this->This(), t.const_value());
archive::save(* this, t.const_value());
save_end(t.name());
}
protected:
virtual ~polymorphic_oarchive_impl(){}
public:
// utility functions implemented by all legal archives
virtual unsigned int get_flags() const = 0;
@@ -140,15 +143,11 @@ public:
) = 0;
};
// note: preserve naming symmetry
class polymorphic_oarchive :
public polymorphic_oarchive_impl
{};
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::polymorphic_oarchive)
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::polymorphic_oarchive)
#endif // BOOST_ARCHIVE_POLYMORPHIC_OARCHIVE_HPP
@@ -18,26 +18,21 @@
#include <boost/config.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/detail/polymorphic_iarchive_dispatch.hpp>
#include <boost/archive/detail/polymorphic_iarchive_impl.hpp>
namespace boost {
namespace archive {
class polymorphic_text_iarchive :
public detail::polymorphic_iarchive_dispatch<naked_text_iarchive>
{
public:
polymorphic_text_iarchive(std::istream & is, unsigned int flags = 0) :
detail::polymorphic_iarchive_dispatch<naked_text_iarchive>(is, flags)
{}
~polymorphic_text_iarchive(){}
};
typedef detail::polymorphic_iarchive_impl<
text_iarchive_impl<text_iarchive>
> polymorphic_text_iarchive;
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
boost::archive::polymorphic_text_iarchive
)
@@ -18,20 +18,21 @@
#include <boost/config.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/detail/polymorphic_oarchive_dispatch.hpp>
#include <boost/archive/detail/polymorphic_oarchive_impl.hpp>
namespace boost {
namespace archive {
typedef detail::polymorphic_oarchive_dispatch<
text_oarchive_impl<naked_text_oarchive>
typedef detail::polymorphic_oarchive_impl<
text_oarchive_impl<text_oarchive>
> polymorphic_text_oarchive;
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
boost::archive::polymorphic_text_oarchive
)
@@ -22,20 +22,21 @@
#else
#include <boost/archive/text_wiarchive.hpp>
#include <boost/archive/detail/polymorphic_iarchive_dispatch.hpp>
#include <boost/archive/detail/polymorphic_iarchive_impl.hpp>
namespace boost {
namespace archive {
typedef detail::polymorphic_iarchive_dispatch<
text_wiarchive_impl<naked_text_wiarchive>
typedef detail::polymorphic_iarchive_impl<
text_wiarchive_impl<text_wiarchive>
> polymorphic_text_wiarchive;
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
boost::archive::polymorphic_text_wiarchive
)
@@ -22,20 +22,21 @@
#else
#include <boost/archive/text_woarchive.hpp>
#include <boost/archive/detail/polymorphic_oarchive_dispatch.hpp>
#include <boost/archive/detail/polymorphic_oarchive_impl.hpp>
namespace boost {
namespace archive {
typedef detail::polymorphic_oarchive_dispatch<
text_woarchive_impl<naked_text_woarchive>
typedef detail::polymorphic_oarchive_impl<
text_woarchive_impl<text_woarchive>
> polymorphic_text_woarchive;
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
boost::archive::polymorphic_text_woarchive
)
@@ -18,26 +18,21 @@
#include <boost/config.hpp>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/detail/polymorphic_iarchive_dispatch.hpp>
#include <boost/archive/detail/polymorphic_iarchive_impl.hpp>
namespace boost {
namespace archive {
class polymorphic_xml_iarchive :
public detail::polymorphic_iarchive_dispatch<naked_xml_iarchive>
{
public:
polymorphic_xml_iarchive(std::istream & is, unsigned int flags = 0) :
detail::polymorphic_iarchive_dispatch<naked_xml_iarchive>(is, flags)
{}
~polymorphic_xml_iarchive(){}
};
typedef detail::polymorphic_iarchive_impl<
xml_iarchive_impl<xml_iarchive>
> polymorphic_xml_iarchive;
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
boost::archive::polymorphic_xml_iarchive
)
@@ -18,20 +18,21 @@
#include <boost/config.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/detail/polymorphic_oarchive_dispatch.hpp>
#include <boost/archive/detail/polymorphic_oarchive_impl.hpp>
namespace boost {
namespace archive {
typedef detail::polymorphic_oarchive_dispatch<
xml_oarchive_impl<naked_xml_oarchive>
typedef detail::polymorphic_oarchive_impl<
xml_oarchive_impl<xml_oarchive>
> polymorphic_xml_oarchive;
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
boost::archive::polymorphic_xml_oarchive
)
@@ -22,20 +22,21 @@
#else
#include <boost/archive/xml_wiarchive.hpp>
#include <boost/archive/detail/polymorphic_iarchive_dispatch.hpp>
#include <boost/archive/detail/polymorphic_iarchive_impl.hpp>
namespace boost {
namespace archive {
typedef detail::polymorphic_iarchive_dispatch<
xml_wiarchive_impl<naked_xml_wiarchive>
typedef detail::polymorphic_iarchive_impl<
xml_wiarchive_impl<xml_wiarchive>
> polymorphic_xml_wiarchive;
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
boost::archive::polymorphic_xml_wiarchive
)
@@ -22,20 +22,21 @@
#else
#include <boost/archive/xml_woarchive.hpp>
#include <boost/archive/detail/polymorphic_oarchive_dispatch.hpp>
#include <boost/archive/detail/polymorphic_oarchive_impl.hpp>
namespace boost {
namespace archive {
typedef detail::polymorphic_oarchive_dispatch<
xml_woarchive_impl<naked_xml_woarchive>
typedef detail::polymorphic_oarchive_impl<
xml_woarchive_impl<xml_woarchive>
> polymorphic_xml_woarchive;
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
boost::archive::polymorphic_xml_woarchive
)
-149
View File
@@ -1,149 +0,0 @@
#ifndef BOOST_ARCHIVE_SHARED_PTR_HELPER_HPP
#define BOOST_ARCHIVE_SHARED_PTR_HELPER_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// shared_ptr.hpp: serialization for boost shared pointer
// (C) Copyright 2004 Robert Ramey and Martin Ecker
// 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 <map>
#include <list>
#include <boost/config.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/serialization/shared_ptr_132.hpp>
#include <boost/throw_exception.hpp>
#include <boost/archive/archive_exception.hpp>
namespace boost_132 {
template<class T> class shared_ptr;
}
namespace boost {
template<class T> class shared_ptr;
namespace serialization {
class extended_type_info;
template<class Archive, class T>
inline void load(
Archive & ar,
boost::shared_ptr<T> &t,
const unsigned int file_version
);
}
namespace archive{
namespace detail {
struct null_deleter {
void operator()(void const *) const {}
};
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// a common class for holding various types of shared pointers
class shared_ptr_helper {
typedef std::map<void*, shared_ptr<void> > collection_type;
typedef collection_type::const_iterator iterator_type;
// list of shared_pointers create accessable by raw pointer. This
// is used to "match up" shared pointers loaded at different
// points in the archive. Note, we delay construction until
// it is actually used since this is by default included as
// a "mix-in" even if shared_ptr isn't used.
collection_type * m_pointers;
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
public:
#else
template<class Archive, class T>
friend inline void boost::serialization::load(
Archive & ar,
boost::shared_ptr<T> &t,
const unsigned int file_version
);
#endif
// list of loaded pointers. This is used to be sure that the pointers
// stay around long enough to be "matched" with other pointers loaded
// by the same archive. These are created with a "null_deleter" so that
// when this list is destroyed - the underlaying raw pointers are not
// destroyed. This has to be done because the pointers are also held by
// new system which is disjoint from this set. This is implemented
// by a change in load_construct_data below. It makes this file suitable
// only for loading pointers into a 1.33 or later boost system.
std::list<boost_132::shared_ptr<void> > * m_pointers_132;
// return a void pointer to the most derived type
template<class T>
void * object_identifier(T * t) const {
const boost::serialization::extended_type_info * true_type
= boost::serialization::type_info_implementation<T>::type
::get_derived_extended_type_info(*t);
// note:if this exception is thrown, be sure that derived pointer
// is either registered or exported.
if(NULL == true_type)
boost::throw_exception(
boost::archive::archive_exception(
boost::archive::archive_exception::unregistered_class
)
);
const boost::serialization::extended_type_info * this_type
= boost::serialization::type_info_implementation<T>::type::get_instance();
void * vp = void_downcast(*true_type, *this_type, t);
return vp;
}
template<class T>
void reset(shared_ptr<T> & s, T * r){
if(NULL == r){
s.reset();
return;
}
// get pointer to the most derived object. This is effectively
// the object identifer
void * od = object_identifier(r);
if(NULL == m_pointers)
m_pointers = new collection_type;
iterator_type it = m_pointers->find(od);
if(it == m_pointers->end()){
s.reset(r);
m_pointers->insert(collection_type::value_type(od,s));
}
else{
s = static_pointer_cast<T>((*it).second);
}
}
void append(const boost_132::shared_ptr<void> & t){
if(NULL == m_pointers_132)
m_pointers_132 = new std::list<boost_132::shared_ptr<void> >;
m_pointers_132->push_back(t);
}
public:
shared_ptr_helper() :
m_pointers(NULL),
m_pointers_132(NULL)
{}
~shared_ptr_helper(){
if(NULL != m_pointers)
delete m_pointers;
if(NULL != m_pointers_132)
delete m_pointers_132;
}
};
} // namespace detail
} // namespace serialization
} // namespace boost
#endif // BOOST_ARCHIVE_SHARED_PTR_HELPER_HPP
+6 -30
View File
@@ -21,7 +21,6 @@
#include <boost/archive/detail/auto_link_archive.hpp>
#include <boost/archive/basic_text_iprimitive.hpp>
#include <boost/archive/basic_text_iarchive.hpp>
#include <boost/config.hpp>
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
@@ -74,38 +73,14 @@ protected:
~text_iarchive_impl(){};
};
// do not derive from the classes below. If you want to extend this functionality
// do not derive from this class. If you want to extend this functionality
// via inhertance, derived from text_iarchive_impl instead. This will
// preserve correct static polymorphism.
// same as text_iarchive below - without the shared_ptr_helper
class naked_text_iarchive :
public text_iarchive_impl<naked_text_iarchive>
{
public:
naked_text_iarchive(std::istream & is, unsigned int flags = 0) :
text_iarchive_impl<naked_text_iarchive>(is, flags)
{}
~naked_text_iarchive(){}
};
} // namespace archive
} // namespace boost
// note special treatment of shared_ptr. This type needs a special
// structure associated with every archive. We created a "mix-in"
// class to provide this functionality. Since shared_ptr holds a
// special esteem in the boost library - we included it here by default.
#include <boost/archive/shared_ptr_helper.hpp>
namespace boost {
namespace archive {
class text_iarchive :
public text_iarchive_impl<text_iarchive>,
public detail::shared_ptr_helper
public text_iarchive_impl<text_iarchive>
{
public:
text_iarchive(std::istream & is, unsigned int flags = 0) :
text_iarchive_impl<text_iarchive>(is, flags)
{}
@@ -115,8 +90,9 @@ public:
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_iarchive)
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::text_iarchive)
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
+3 -4
View File
@@ -88,13 +88,12 @@ public:
~text_oarchive(){}
};
typedef text_oarchive naked_text_oarchive;
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_oarchive)
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::text_oarchive)
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
+6 -30
View File
@@ -72,36 +72,11 @@ protected:
~text_wiarchive_impl(){};
};
// do not derive from the classes below. If you want to extend this functionality
// via inhertance, derived from text_iarchive_impl instead. This will
// do not derive from this class. If you want to extend this functionality
// via inhertance, derived from text_wiarchive_impl instead. This will
// preserve correct static polymorphism.
// same as text_wiarchive below - without the shared_ptr_helper
class naked_text_wiarchive :
public text_wiarchive_impl<naked_text_wiarchive>
{
public:
naked_text_wiarchive(std::wistream & is, unsigned int flags = 0) :
text_wiarchive_impl<naked_text_wiarchive>(is, flags)
{}
~naked_text_wiarchive(){}
};
} // namespace archive
} // namespace boost
// note special treatment of shared_ptr. This type needs a special
// structure associated with every archive. We created a "mix-in"
// class to provide this functionality. Since shared_ptr holds a
// special esteem in the boost library - we included it here by default.
#include <boost/archive/shared_ptr_helper.hpp>
namespace boost {
namespace archive {
class text_wiarchive :
public text_wiarchive_impl<text_wiarchive>,
public detail::shared_ptr_helper
public text_wiarchive_impl<text_wiarchive>
{
public:
text_wiarchive(std::wistream & is, unsigned int flags = 0) :
@@ -113,8 +88,9 @@ public:
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_wiarchive)
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::text_wiarchive)
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
+3 -4
View File
@@ -114,13 +114,12 @@ public:
~text_woarchive(){}
};
typedef text_woarchive naked_text_woarchive;
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_woarchive)
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::text_woarchive)
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
+9 -30
View File
@@ -83,36 +83,14 @@ protected:
~xml_iarchive_impl();
};
// do not derive from the classes below. If you want to extend this functionality
// via inhertance, derived from text_iarchive_impl instead. This will
// we use the following because we can't use
// typedef xml_iarchive_impl<xml_iarchive_impl<...> > xml_iarchive;
// do not derive from this class. If you want to extend this functionality
// via inhertance, derived from xml_iarchive_impl instead. This will
// preserve correct static polymorphism.
// same as xml_iarchive below - without the shared_ptr_helper
class naked_xml_iarchive :
public xml_iarchive_impl<naked_xml_iarchive>
{
public:
naked_xml_iarchive(std::istream & is, unsigned int flags = 0) :
xml_iarchive_impl<naked_xml_iarchive>(is, flags)
{}
~naked_xml_iarchive(){}
};
} // namespace archive
} // namespace boost
// note special treatment of shared_ptr. This type needs a special
// structure associated with every archive. We created a "mix-in"
// class to provide this functionality. Since shared_ptr holds a
// special esteem in the boost library - we included it here by default.
#include <boost/archive/shared_ptr_helper.hpp>
namespace boost {
namespace archive {
class xml_iarchive :
public xml_iarchive_impl<xml_iarchive>,
public detail::shared_ptr_helper
public xml_iarchive_impl<xml_iarchive>
{
public:
xml_iarchive(std::istream & is, unsigned int flags = 0) :
@@ -124,8 +102,9 @@ public:
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_iarchive)
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::xml_iarchive)
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
+6 -7
View File
@@ -48,9 +48,9 @@ public:
friend class save_access;
protected:
#endif
//void end_preamble(){
// basic_xml_oarchive<Archive>::end_preamble();
//}
void end_preamble(){
basic_xml_oarchive<Archive>::end_preamble();
}
template<class T>
void save(const T & t){
basic_text_oprimitive<std::ostream>::save(t);
@@ -101,13 +101,12 @@ public:
~xml_oarchive(){}
};
typedef xml_oarchive naked_xml_oarchive;
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_oarchive)
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::xml_oarchive)
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
+9 -30
View File
@@ -87,36 +87,14 @@ protected:
~xml_wiarchive_impl();
};
// do not derive from the classes below. If you want to extend this functionality
// via inhertance, derived from text_iarchive_impl instead. This will
// we use the following because we can't use
// typedef xml_wiarchive_impl<xml_wiarchive_impl<...> > xml_wiarchive;
// do not derive from this class. If you want to extend this functionality
// via inhertance, derived from xml_wiarchive_impl instead. This will
// preserve correct static polymorphism.
// same as xml_wiarchive below - without the shared_ptr_helper
class naked_xml_wiarchive :
public xml_wiarchive_impl<naked_xml_wiarchive>
{
public:
naked_xml_wiarchive(std::wistream & is, unsigned int flags = 0) :
xml_wiarchive_impl<naked_xml_wiarchive>(is, flags)
{}
~naked_xml_wiarchive(){}
};
} // namespace archive
} // namespace boost
// note special treatment of shared_ptr. This type needs a special
// structure associated with every archive. We created a "mix-in"
// class to provide this functionality. Since shared_ptr holds a
// special esteem in the boost library - we included it here by default.
#include <boost/archive/shared_ptr_helper.hpp>
namespace boost {
namespace archive {
class xml_wiarchive :
public xml_wiarchive_impl<xml_wiarchive>,
public detail::shared_ptr_helper
public xml_wiarchive_impl<xml_wiarchive>
{
public:
xml_wiarchive(std::wistream & is, unsigned int flags = 0) :
@@ -128,8 +106,9 @@ public:
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_wiarchive)
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::xml_wiarchive)
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
+6 -7
View File
@@ -58,9 +58,9 @@ public:
friend class save_access;
protected:
#endif
//void end_preamble(){
// basic_xml_oarchive<Archive>::end_preamble();
//}
void end_preamble(){
basic_xml_oarchive<Archive>::end_preamble();
}
template<class T>
void
save(const T & t){
@@ -113,13 +113,12 @@ public:
~xml_woarchive(){}
};
typedef xml_woarchive naked_xml_woarchive;
} // namespace archive
} // namespace boost
// required by export
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_woarchive)
// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::xml_woarchive)
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
-107
View File
@@ -1,107 +0,0 @@
#ifndef BOOST_SERIALIZATION_ARRAY_HPP
#define BOOST_SERIALIZATION_ARRAY_HPP
// (C) Copyright 2005 Matthias Troyer and Dave Abrahams
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/split_free.hpp>
#include <boost/serialization/wrapper.hpp>
#include <boost/serialization/collection_size_type.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/throw_exception.hpp>
#include <iostream>
namespace boost { namespace serialization {
template<class T>
class array
: public wrapper_traits<array<T> >
{
public:
typedef T value_type;
array(value_type* t, std::size_t s) :
m_t(t),
m_element_count(s)
{}
// default implementation
template<class Archive>
void serialize(Archive &ar, const unsigned int) const
{
// default implemention does the loop
std::size_t c = count();
value_type * t = address();
while(0 < c--)
ar & make_nvp("item", *t++);
}
value_type* address() const
{
return m_t;
}
std::size_t count() const
{
return m_element_count;
}
private:
value_type* m_t;
std::size_t const m_element_count;
};
template<class T>
inline
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
const
#endif
array<T> make_array( T* t, std::size_t s){
return array<T>(t, s);
}
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// T[N]
/*
template<class Archive, class U, std::size_t N>
void save( Archive & ar, U const (& t)[N], const unsigned int file_version )
{
const serialization::collection_size_type count(N);
ar << BOOST_SERIALIZATION_NVP(count);
if (N)
ar << serialization::make_array(&t[0],N);
}
template<class Archive, class U, std::size_t N>
void load( Archive & ar, U (& t)[N], const unsigned int file_version )
{
serialization::collection_size_type count;
ar >> BOOST_SERIALIZATION_NVP(count);
if(count > N)
boost::throw_exception(archive::archive_exception(
boost::archive::archive_exception::array_size_too_short
));
if (N)
ar >> serialization::make_array(&t[0],count);
}
// split non-intrusive serialization function member into separate
// non intrusive save/load member functions
template<class Archive, class U, std::size_t N>
inline void serialize( Archive & ar, U (& t)[N], const unsigned int file_version)
{
boost::serialization::split_free(ar, t, file_version);
}
*/
} } // end namespace boost::serialization
#endif //BOOST_SERIALIZATION_ARRAY_HPP
+104 -35
View File
@@ -37,45 +37,114 @@
namespace boost {
namespace serialization {
namespace detail
{
// only register void casts if the types are polymorphic
template<class Base, class Derived>
struct base_register
{
static void const* execute(mpl::false_) { return 0; }
namespace detail {
// metrowerks CodeWarrior
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206))
// only register void casts if the types are polymorphic
template<class Base, class Derived>
struct base_register{
struct nothing {
static const void_cast_detail::void_caster & invoke(){
return static_cast<const void_cast_detail::void_caster &>(
* static_cast<const void_cast_detail::void_caster *>(NULL)
);
}
};
static void const* execute(mpl::true_)
{
return &void_cast_register((Derived const*)0, (Base const*)0);
}
static void const* invoke()
{
typedef mpl::bool_<
type_info_implementation<Base>::type::is_polymorphic::value
> is_polymorphic;
return execute(is_polymorphic());
}
};
// hold a reference to the void_cast_register and void_caster in the hope of
// ensuring code instantiation for some compilers with over-zealous link time
// optimiser. The compiler that demanded this was CW
struct reg{
typedef const void_cast_detail::void_caster & (* t_vcr)(
const Derived *,
const Base *
);
t_vcr m_vcr;
static const void_cast_detail::void_caster & invoke(){
return void_cast_register<const Derived, const Base>(
static_cast<const Derived *>(NULL),
static_cast<const Base *>(NULL)
);
}
reg() :
m_vcr(static_cast<t_vcr>(void_cast_register))
{
}
} m_reg;
// get the base type for a given derived type
// preserving the const-ness
template<class B, class D>
struct base_cast
{
typedef BOOST_DEDUCED_TYPENAME
mpl::if_<
is_const<D>,
const B,
B
>::type type;
BOOST_STATIC_ASSERT(is_const<type>::value == is_const<D>::value);
};
static const void_cast_detail::void_caster & invoke(){
typedef BOOST_DEDUCED_TYPENAME mpl::eval_if<
BOOST_DEDUCED_TYPENAME type_info_implementation<Base>::type::is_polymorphic,
mpl::identity<reg>,
mpl::identity<nothing>
>::type typex;
return typex::invoke();
}
const void_cast_detail::void_caster & m_vc;
Derived & m_d;
base_register(Derived & d) :
m_vc(invoke()),
m_d(d)
{}
Base & get_base() const {
return m_d;
}
};
#else
// only register void casts if the types are polymorphic
template<class Base, class Derived>
struct base_register{
struct nothing {
static void invoke(){}
};
struct reg{
static void invoke(){
void_cast_register<const Derived, const Base>(
static_cast<const Derived *>(NULL),
static_cast<const Base *>(NULL)
);
}
};
static void invoke(){
typedef BOOST_DEDUCED_TYPENAME mpl::eval_if<
BOOST_DEDUCED_TYPENAME type_info_implementation<Base>::type::is_polymorphic,
mpl::identity<reg>,
mpl::identity<nothing>
>::type typex;
typex::invoke();
}
};
#endif
// get the base type for a given derived type
// preserving the const-ness
template<class B, class D>
struct base_cast
{
typedef BOOST_DEDUCED_TYPENAME
mpl::if_<
is_const<D>,
const B,
B
>::type type;
BOOST_STATIC_ASSERT(is_const<type>::value == is_const<D>::value);
};
} // namespace detail
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560))
// metrowerks CodeWarrior
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206))
template<class Base, class Derived>
BOOST_DEDUCED_TYPENAME detail::base_cast<Base, Derived>::type &
base_object(Derived &d)
{
BOOST_STATIC_ASSERT(( is_base_and_derived<Base,Derived>::value));
BOOST_STATIC_ASSERT(! is_pointer<Derived>::value);
typedef BOOST_DEDUCED_TYPENAME detail::base_cast<Base, Derived>::type type;
return detail::base_register<type, Derived>(d).get_base();
}
// BORLAND
#elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560))
template<class Base, class Derived>
const Base &
base_object(const Derived & d)
@@ -31,7 +31,6 @@ namespace std{
#include <boost/serialization/level.hpp>
#include <boost/serialization/split_member.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/wrapper.hpp>
namespace boost {
namespace serialization {
@@ -69,15 +68,6 @@ make_binary_object(/* const */ void * t, std::size_t size){
return binary_object(t, size);
}
// this is a wrapper
template <>
struct is_wrapper<binary_object>
: public mpl::true_
{};
} // namespace serialization
} // boost
@@ -1,20 +0,0 @@
#ifndef BOOST_SERIALIZATION_COLLECTION_SIZE_TYPE_HPP
#define BOOST_SERIALIZATION_COLLECTION_SIZE_TYPE_HPP
// (C) Copyright 2005 Matthias Troyer
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/strong_typedef.hpp>
#include <boost/serialization/level.hpp>
namespace boost { namespace serialization {
BOOST_STRONG_TYPEDEF(std::size_t, collection_size_type)
} } // end namespace boost::serialization
BOOST_CLASS_IMPLEMENTATION(boost::serialization::collection_size_type, primitive_type)
#endif //BOOST_SERIALIZATION_COLLECTION_SIZE_TYPE_HPP
@@ -31,7 +31,6 @@
#include <boost/serialization/access.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/detail/stack_constructor.hpp>
#include <boost/serialization/collection_size_type.hpp>
namespace boost{
namespace serialization {
@@ -102,7 +101,7 @@ template<class Container>
class reserve_imp
{
public:
void operator()(Container &s, std::size_t count) const {
void operator()(Container &s, unsigned int count) const {
s.reserve(count);
}
};
@@ -111,7 +110,7 @@ template<class Container>
class no_reserve_imp
{
public:
void operator()(Container & /* s */, std::size_t /* count */) const{}
void operator()(Container & /* s */, unsigned int /* count */) const{}
};
template<class Archive, class Container, class InputFunction, class R>
@@ -119,18 +118,16 @@ inline void load_collection(Archive & ar, Container &s)
{
s.clear();
// retrieve number of elements
collection_size_type count;
unsigned int item_version;
unsigned int count;
unsigned int item_version(0);
ar >> BOOST_SERIALIZATION_NVP(count);
if(3 < ar.get_library_version())
if(3 < ar.get_library_version()){
ar >> BOOST_SERIALIZATION_NVP(item_version);
else
item_version = 0;
}
R rx;
rx(s, count);
std::size_t c = count;
InputFunction ifunc;
while(c-- > 0){
while(count-- > 0){
ifunc(ar, s, item_version);
}
}
@@ -22,7 +22,6 @@
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/version.hpp>
#include <boost/serialization/collection_size_type.hpp>
namespace boost{
namespace serialization {
@@ -36,7 +35,7 @@ template<class Archive, class Container>
inline void save_collection(Archive & ar, const Container &s)
{
// record number of elements
collection_size_type const count(s.size());
unsigned int count = s.size();
ar << BOOST_SERIALIZATION_NVP(count);
// make sure the target type is registered so we can retrieve
// the version when we load
@@ -47,8 +46,7 @@ inline void save_collection(Archive & ar, const Container &s)
ar << BOOST_SERIALIZATION_NVP(item_version);
}
BOOST_DEDUCED_TYPENAME Container::const_iterator it = s.begin();
std::size_t c=count;
while(c-- > 0){
while(count-- > 0){
// note borland emits a no-op without the explicit namespace
boost::serialization::save_construct_data_adl(
ar,
@@ -1,55 +0,0 @@
// (C) Copyright 2005 Matthias Troyer
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#ifndef BOOST_SERIALIZATION_DETAIL_GET_DATA_HPP
#define BOOST_SERIALIZATION_DETAIL_GET_DATA_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
#define STD _STLP_STD
#else
#define STD std
#endif
#include <vector>
#include <valarray>
namespace boost { namespace serialization { namespace detail {
template <class T, class Allocator>
T* get_data(STD::vector<T,Allocator>& v)
{
return v.empty() ? 0 : &(v[0]);
}
template <class T, class Allocator>
T* get_data(STD::vector<T,Allocator> const & v)
{
return get_data(const_cast<STD::vector<T,Allocator>&>(v));
}
template <class T>
T* get_data(STD::valarray<T>& v)
{
return v.size()==0 ? 0 : &(v[0]);
}
template <class T>
const T* get_data(STD::valarray<T> const& v)
{
return get_data(const_cast<STD::valarray<T>&>(v));
}
} } } //namespace boost::serialization::detail
#endif // BOOST_SERIALIZATION_DETAIL_GET_DATA_HPP
-79
View File
@@ -1,79 +0,0 @@
#ifndef BOOST_SERIALIZATION_EPHEMERAL_HPP
#define BOOST_SERIALIZATION_EPHEMERAL_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// ephemeral_object.hpp: interface for serialization system.
// (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 <utility>
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
// supress noise
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#include <boost/mpl/integral_c.hpp>
#include <boost/mpl/integral_c_tag.hpp>
#include <boost/serialization/level.hpp>
#include <boost/serialization/tracking.hpp>
#include <boost/serialization/split_member.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/traits.hpp>
#include <boost/serialization/wrapper.hpp>
namespace boost {
namespace serialization {
template<class T>
struct ephemeral_object :
public wrapper_traits<ephemeral_object<T> >
{
explicit ephemeral_object(T& t) :
val(t)
{}
T & value() const {
return val;
}
const T & const_value() const {
return val;
}
template<class Archive>
void serialize(Archive &ar, const unsigned int) const
{
ar & val;
}
private:
T & val;
};
template<class T>
inline
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
const
#endif
ephemeral_object<T> ephemeral(const char * name, T & t){
return ephemeral_object<T>(name, t);
}
} // seralization
} // boost
#endif // BOOST_SERIALIZATION_EPHEMERAL_HPP
+198 -125
View File
@@ -16,7 +16,6 @@
// See http://www.boost.org for updates, documentation, and revision history.
// (C) Copyright 2006 David Abrahams - http://www.boost.org.
// implementation of class export functionality. This is an alternative to
// "forward declaration" method to provoke instantiation of derived classes
// that are to be serialized through pointers.
@@ -24,165 +23,226 @@
#include <utility>
#include <boost/config.hpp>
// if no archive headers have been included this is a no op
// this is to permit BOOST_EXPORT etc to be included in a
// file declaration header
#if ! defined(BOOST_ARCHIVE_BASIC_ARCHIVE_HPP)
#define BOOST_CLASS_EXPORT_GUID_ARCHIVE_LIST(T, K, ASEQ)
#else
#include <boost/static_assert.hpp>
#include <boost/preprocessor/stringize.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/or.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/void.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/archive/detail/dynamically_initialized.hpp>
#include <boost/archive/detail/known_archive_types.hpp>
#include <boost/serialization/force_include.hpp>
#include <boost/serialization/type_info_implementation.hpp>
#include <boost/serialization/is_abstract.hpp>
#include <boost/serialization/force_include.hpp>
#include <boost/archive/detail/register_archive.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/not.hpp>
#include <iostream>
namespace boost {
namespace archive {
namespace detail {
// forward template declarations
class basic_pointer_iserializer;
template<class Archive, class T>
BOOST_DLLEXPORT const basic_pointer_iserializer &
instantiate_pointer_iserializer(Archive * ar, T *) BOOST_USED;
class basic_pointer_oserializer;
template<class Archive, class T>
class pointer_iserializer;
template<class Archive, class T>
class pointer_oserializer;
BOOST_DLLEXPORT const basic_pointer_oserializer &
instantiate_pointer_oserializer(Archive * ar, T *) BOOST_USED;
template <class Archive, class Serializable>
struct export_impl
namespace export_impl
{
static const basic_pointer_iserializer &
enable_load(mpl::true_){
return pointer_iserializer<Archive, Serializable>::get_instance();
}
struct nothing{
static void instantiate(){}
};
static const basic_pointer_oserializer &
enable_save(mpl::true_){
return pointer_oserializer<Archive, Serializable>::get_instance();
}
template<class Archive, class T>
struct archive {
struct i {
static void invoke(){
instantiate_pointer_iserializer(
static_cast<Archive *>(NULL),
static_cast<T *>(NULL)
);
}
};
struct o {
static void invoke(){
instantiate_pointer_oserializer(
static_cast<Archive *>(NULL),
static_cast<T *>(NULL)
);
}
};
static void instantiate(){
#if defined(__GNUC__) && (__GNUC__ >= 3)
BOOST_STATIC_ASSERT(
Archive::is_loading::value || Archive::is_saving::value
);
#endif
typedef BOOST_DEDUCED_TYPENAME mpl::eval_if<
BOOST_DEDUCED_TYPENAME Archive::is_saving,
mpl::identity<o>,
// else
BOOST_DEDUCED_TYPENAME mpl::eval_if<
BOOST_DEDUCED_TYPENAME Archive::is_loading,
mpl::identity<i>,
// else
mpl::identity<nothing>
> >::type typex;
typex::invoke();
}
};
inline static void enable_load(mpl::false_) {}
inline static void enable_save(mpl::false_) {}
template<class ASeq, class T>
struct for_each_archive {
private:
typedef BOOST_DEDUCED_TYPENAME mpl::pop_front<ASeq>::type tail;
typedef BOOST_DEDUCED_TYPENAME mpl::front<ASeq>::type head;
public:
static void instantiate(){
archive<head, T>::instantiate();
typedef BOOST_DEDUCED_TYPENAME mpl::eval_if<
mpl::empty<tail>,
mpl::identity<nothing>,
mpl::identity<for_each_archive<tail, T> >
>::type typex;
typex::instantiate();
}
};
} // namespace export_impl
// strictly conforming
template<class T, class ASeq>
struct export_generator {
export_generator(){
export_impl::for_each_archive<ASeq, T>::instantiate();
}
static const export_generator instance;
};
template<class T, class ASeq>
const export_generator<T, ASeq>
export_generator<T, ASeq>::instance;
// instantiation of this template creates a static object.
template<class T>
struct guid_initializer
{
typedef typename
boost::serialization::type_info_implementation<T>::type eti_type;
static void export_register(const char *key)
{
struct guid_initializer {
typedef BOOST_DEDUCED_TYPENAME boost::serialization::type_info_implementation<T>::type eti_type;
static void export_register(const char *key){
eti_type::export_register(key);
}
static const guid_initializer& get_instance(char const* key)
{
static guid_initializer const instance(key);
return instance;
}
BOOST_DLLEXPORT guid_initializer(const char *key = 0) BOOST_USED ;
static const guid_initializer instance;
guid_initializer(const char *key = 0) BOOST_USED ;
};
template<class T>
BOOST_DLLEXPORT guid_initializer<T>::guid_initializer(const char *key)
{
guid_initializer<T>::guid_initializer(const char *key){
if(0 != key)
export_register(key);
// generates the statically-initialized objects whose constructors
// register the information allowing serialization of T objects
// through pointers to their base classes.
instantiate_ptr_serialization((T*)0, 0);
}
// On many platforms, naming a specialization of this template is
// enough to cause its argument to be instantiated.
template <void(*)()>
struct instantiate_function {};
template<class T>
const guid_initializer<T> guid_initializer<T>::instance;
template <class Archive, class Serializable>
struct ptr_serialization_support
{
# ifdef BOOST_MSVC
virtual BOOST_DLLEXPORT void instantiate() BOOST_USED;
# elif defined(__BORLANDC__)
static void instantiate();
enum { x = sizeof(instantiate(),3) };
# else
static void instantiate();
typedef instantiate_function<
&ptr_serialization_support::instantiate
> x;
// only gcc seems to be able to explicitly instantiate a static instance.
// but all can instantiate a function that refers to a static instance
# endif
// the following optimization - inhibiting explicit instantiation for abstract
// classes breaks msvc compliles
template<class T, class ASeq>
struct export_instance {
struct abstract {
static const export_generator<T, ASeq> *
invoke(){
return 0;
}
};
struct not_abstract {
static const export_generator<T, ASeq> *
invoke(){
return & export_generator<T, ASeq>::instance;
}
};
};
template <class Archive, class Serializable>
BOOST_DLLEXPORT void ptr_serialization_support<Archive,Serializable>::instantiate()
{
typedef mpl::not_<serialization::is_abstract<Serializable> > concrete;
export_impl<Archive,Serializable>::enable_save(
mpl::and_<concrete, BOOST_DEDUCED_TYPENAME Archive::is_saving>());
template<class T, class ASeq>
BOOST_DLLEXPORT
std::pair<const export_generator<T, ASeq> *, const guid_initializer<T> *>
export_instance_invoke() {
typedef BOOST_DEDUCED_TYPENAME mpl::eval_if<
serialization::is_abstract<T>,
mpl::identity<BOOST_DEDUCED_TYPENAME export_instance<T, ASeq>::abstract>,
mpl::identity<BOOST_DEDUCED_TYPENAME export_instance<T, ASeq>::not_abstract>
>::type typex;
return std::pair<const export_generator<T, ASeq> *, const guid_initializer<T> *>(
typex::invoke(),
& guid_initializer<T>::instance
);
}
export_impl<Archive,Serializable>::enable_load(
mpl::and_<concrete, BOOST_DEDUCED_TYPENAME Archive::is_loading>());
template<class T, class ASeq>
struct export_archives {
struct empty_archive_list {
static BOOST_DLLEXPORT
std::pair<const export_generator<T, ASeq> *, const guid_initializer<T> *>
invoke(){
return std::pair<const export_generator<T, ASeq> *,
const guid_initializer<T> *>(0, 0);
}
};
struct non_empty_archive_list {
static BOOST_DLLEXPORT
std::pair<const export_generator<T, ASeq> *, const guid_initializer<T> *>
invoke(){
return export_instance_invoke<T, ASeq>();
}
};
};
template<class T, class ASeq>
BOOST_DLLEXPORT
std::pair<const export_generator<T, ASeq> *, const guid_initializer<T> *>
export_archives_invoke(T &, ASeq &){
typedef BOOST_DEDUCED_TYPENAME mpl::eval_if<
mpl::empty<ASeq>,
mpl::identity<BOOST_DEDUCED_TYPENAME export_archives<T, ASeq>::empty_archive_list>,
mpl::identity<BOOST_DEDUCED_TYPENAME export_archives<T, ASeq>::non_empty_archive_list>
>::type typex;
return typex::invoke();
}
} // namespace detail
} // namespace archive
} // namespace boost
#define BOOST_CLASS_EXPORT_GUID(T, K) \
namespace \
{ \
::boost::archive::detail::guid_initializer< T > const& \
BOOST_PP_CAT(boost_serialization_guid_initializer_, __LINE__) \
= ::boost::archive::detail::guid_initializer< T >::get_instance(K); \
}
#define BOOST_CLASS_EXPORT_GUID_ARCHIVE_LIST(T, K, ASEQ) \
namespace boost { \
namespace archive { \
namespace detail { \
template<> \
const guid_initializer< T > \
guid_initializer< T >::instance(K); \
template \
BOOST_DLLEXPORT \
std::pair<const export_generator<T, ASEQ> *, const guid_initializer< T > *> \
export_archives_invoke<T, ASEQ>(T &, ASEQ &); \
} } } \
/**/
// the following is solely to support de-serialization of pointers serialized
// under 1.32
#define BOOST_CLASS_EXPORT_GUID_1(T, K) \
namespace \
{ \
::boost::archive::detail::guid_initializer< T > const& \
BOOST_PP_CAT(boost_serialization_guid_initializer_, __LINE__ ## _1) \
= ::boost::archive::detail::guid_initializer< T >::get_instance(K); \
}
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
// CodeWarrior fails to construct static members of class templates
// when they are instantiated from within templates, so on that
// compiler we ask users to specifically register base/derived class
// relationships for exported classes. On all other compilers, use of
// this macro is entirely optional.
# define BOOST_SERIALIZATION_MWERKS_BASE_AND_DERIVED(Base,Derived) \
namespace \
{ \
int BOOST_PP_CAT(boost_serialization_mwerks_init_, __LINE__) = \
(::boost::archive::detail::instantiate_ptr_serialization((Derived*)0,0), 3); \
int BOOST_PP_CAT(boost_serialization_mwerks_init2_, __LINE__) = ( \
::boost::serialization::void_cast_register((Derived*)0,(Base*)0) \
, 3); \
}
#else
# define BOOST_SERIALIZATION_MWERKS_BASE_AND_DERIVED(Base,Derived)
#endif
#endif
// check for unnecessary export. T isn't polymorphic so there is no
// need to export it.
@@ -193,15 +253,28 @@ namespace
); \
/**/
// the default list of archives types for which code id generated
#define BOOST_CLASS_EXPORT_GUID(T, K) \
BOOST_CLASS_EXPORT_GUID_ARCHIVE_LIST( \
T, \
K, \
boost::archive::detail::known_archive_types::type \
) \
/**/
// the default exportable class identifier is the class name
#define BOOST_CLASS_EXPORT_ARCHIVE_LIST(T, ASEQ) \
BOOST_CLASS_EXPORT_GUID_ARCHIVE_LIST(T, BOOST_PP_STRINGIZE(T), A)
// the default exportable class identifier is the class name
// the default list of archives types for which code id generated
// are the originally included with this serialization system
#define BOOST_CLASS_EXPORT(T) \
BOOST_CLASS_EXPORT_GUID( \
T, \
BOOST_PP_STRINGIZE(T) \
) \
#define BOOST_CLASS_EXPORT(T) \
BOOST_CLASS_EXPORT_GUID_ARCHIVE_LIST( \
T, \
BOOST_PP_STRINGIZE(T), \
boost::archive::detail::known_archive_types::type \
) \
/**/
#endif // BOOST_SERIALIZATION_EXPORT_HPP
@@ -42,7 +42,7 @@
# endif
#elif ! defined(_WIN32) && ! defined(_WIN64)
# if defined(__MWERKS__)
# define BOOST_DLLEXPORT __declspec(dllexport)
# // define BOOST_USED __attribute__ ((used))
# elif defined(__GNUC__) && (__GNUC__ >= 3)
# define BOOST_USED __attribute__ ((used))
# elif defined(__INTEL_COMPILER) && (BOOST_INTEL_CXX_VERSION >= 800)
+16 -9
View File
@@ -23,13 +23,16 @@
namespace boost {
namespace serialization {
template<class T>
struct is_abstract
#ifdef BOOST_NO_IS_ABSTRACT
: mpl::false_
#else
: boost::is_abstract<T>
#endif
{};
struct is_abstract {
// default to false if not supported
#ifdef BOOST_NO_IS_ABSTRACT
typedef BOOST_DEDUCED_TYPENAME mpl::bool_<false> type;
BOOST_STATIC_CONSTANT(bool, value = false);
#else
typedef BOOST_DEDUCED_TYPENAME boost::is_abstract<T>::type type;
BOOST_STATIC_CONSTANT(bool, value = type::value);
#endif
};
} // namespace serialization
} // namespace boost
@@ -38,8 +41,12 @@ namespace serialization {
namespace boost { \
namespace serialization { \
template<> \
struct is_abstract< T > : mpl::true_ {}; \
}} \
struct is_abstract< T > { \
typedef mpl::bool_<true> type; \
BOOST_STATIC_CONSTANT(bool, value = true); \
}; \
} \
} \
/**/
#endif //BOOST_SERIALIZATION_IS_ABSTRACT_CLASS_HPP
+1 -2
View File
@@ -33,7 +33,6 @@
#include <boost/serialization/split_member.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/traits.hpp>
#include <boost/serialization/wrapper.hpp>
namespace boost {
namespace serialization {
@@ -41,7 +40,7 @@ namespace serialization {
template<class T>
struct nvp :
public std::pair<const char *, T *>,
public wrapper_traits<nvp<T> >
public traits<nvp<T>, object_serializable, track_never>
{
explicit nvp(const char * name, T & t) :
// note: redundant cast works around borland issue
+101 -18
View File
@@ -24,11 +24,18 @@
#include <boost/detail/workaround.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/throw_exception.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/serialization/type_info_implementation.hpp>
#include <boost/serialization/split_free.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/version.hpp>
#include <boost/serialization/tracking.hpp>
#include <boost/static_assert.hpp>
#include <boost/serialization/void_cast_fwd.hpp>
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// shared_ptr serialization traits
@@ -41,31 +48,31 @@
template<class T>
struct version< ::boost::shared_ptr<T> > {
typedef mpl::integral_c_tag tag;
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206))
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206))
typedef BOOST_DEDUCED_TYPENAME mpl::int_<1> type;
#else
#else
typedef mpl::int_<1> type;
#endif
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570))
#endif
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570))
BOOST_STATIC_CONSTANT(unsigned int, value = 1);
#else
#else
BOOST_STATIC_CONSTANT(unsigned int, value = type::value);
#endif
#endif
};
// don't track shared pointers
template<class T>
struct tracking_level< ::boost::shared_ptr<T> > {
typedef mpl::integral_c_tag tag;
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206))
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206))
typedef BOOST_DEDUCED_TYPENAME mpl::int_< ::boost::serialization::track_never> type;
#else
#else
typedef mpl::int_< ::boost::serialization::track_never> type;
#endif
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570))
#endif
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570))
BOOST_STATIC_CONSTANT(int, value = ::boost::serialization::track_never);
#else
#else
BOOST_STATIC_CONSTANT(int, value = type::value);
#endif
#endif
};
}}
#define BOOST_SERIALIZATION_SHARED_PTR(T)
@@ -86,6 +93,85 @@
namespace boost {
namespace serialization{
class extended_type_info;
namespace detail {
struct null_deleter {
void operator()(void const *) const {}
};
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// a common class for holding various types of shared pointers
class shared_ptr_helper {
typedef std::map<void*, shared_ptr<void> > collection_type;
typedef collection_type::const_iterator iterator_type;
// list of shared_pointers create accessable by raw pointer. This
// is used to "match up" shared pointers loaded at diferent
// points in the archive
collection_type m_pointers;
// return a void pointer to the most derived type
template<class T>
void * object_identifier(T * t) const {
const extended_type_info * true_type
= type_info_implementation<T>::type::get_derived_extended_type_info(*t);
// note:if this exception is thrown, be sure that derived pointer
// is either regsitered or exported.
if(NULL == true_type)
boost::throw_exception(
boost::archive::archive_exception(
boost::archive::archive_exception::unregistered_class
)
);
const boost::serialization::extended_type_info * this_type
= boost::serialization::type_info_implementation<T>::type::get_instance();
void * vp = void_downcast(*true_type, *this_type, t);
return vp;
}
public:
template<class T>
void reset(shared_ptr<T> & s, T * r){
if(NULL == r){
s.reset();
return;
}
// get pointer to the most derived object. This is effectively
// the object identifer
void * od = object_identifier(r);
iterator_type it = m_pointers.find(od);
if(it == m_pointers.end()){
s.reset(r);
m_pointers.insert(collection_type::value_type(od,s));
}
else{
s = static_pointer_cast<T>((*it).second);
}
}
virtual ~shared_ptr_helper(){}
};
} // namespace detail
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// utility function for creating/getting a helper - could be useful in general
// but shared_ptr is the only class (so far that needs it) and I don't have a
// convenient header to place it into.
template<class Archive, class H>
H &
get_helper(Archive & ar){
extended_type_info * eti = type_info_implementation<H>::type::get_instance();
shared_ptr<void> sph;
ar.lookup_helper(eti, sph);
if(NULL == sph.get()){
sph = shared_ptr<H>(new H);
ar.insert_helper(eti, sph);
}
return * static_cast<H *>(sph.get());
}
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// serialization for shared_ptr
@@ -116,17 +202,14 @@ inline void load(
T* r;
#ifdef BOOST_SERIALIZATION_SHARED_PTR_132_HPP
if(file_version < 1){
//ar.register_type(static_cast<
// boost_132::detail::sp_counted_base_impl<T *, boost::checked_deleter<T> > *
//>(NULL));
ar.register_type(static_cast<
boost_132::detail::sp_counted_base_impl<T *, boost::archive::detail::null_deleter > *
boost_132::detail::sp_counted_base_impl<T *, boost::checked_deleter<T> > *
>(NULL));
boost_132::shared_ptr<T> sp;
ar >> boost::serialization::make_nvp("px", sp.px);
ar >> boost::serialization::make_nvp("pn", sp.pn);
// got to keep the sps around so the sp.pns don't disappear
ar.append(sp);
get_helper<Archive, boost_132::serialization::detail::shared_ptr_helper>(ar).append(sp);
r = sp.get();
}
else
@@ -134,7 +217,7 @@ inline void load(
{
ar >> boost::serialization::make_nvp("px", r);
}
ar.reset(t,r);
get_helper<Archive, detail::shared_ptr_helper >(ar).reset(t,r);
}
template<class Archive, class T>
+21 -3
View File
@@ -47,6 +47,25 @@ struct null_deleter {
void operator()(void const *) const {}
};
class shared_ptr_helper{
typedef std::list<shared_ptr<void> > collection_type;
typedef collection_type::iterator iterator_type;
// list of loaded pointers. This is used to be sure that the pointers
// stay around long enough to be "matched" with other pointers loaded
// by the same archive. These are created with a "null_deleter" so that
// when this list is destroyed - the underlaying raw pointers are not
// destroyed. This has to be done because the pointers are also held by
// new system which is disjoint from this set. This is implemented
// by a change in load_construct_data below. It makes this file suitable
// only for loading pointers into a 1.33 or later boost system.
collection_type m_pointers;
public:
void append(const boost_132::shared_ptr<void> & t){
m_pointers.push_back(t);
}
virtual ~shared_ptr_helper(){}
};
} // namespace detail
} // namespace serialization
} // namespace boost_132
@@ -92,8 +111,7 @@ inline void load_construct_data(
){
P ptr_;
ar >> boost::serialization::make_nvp("ptr", ptr_);
// ::new(t)boost_132::detail::sp_counted_base_impl<P, D>(ptr_, D());
// placement
// ::new(t)boost_132::detail::sp_counted_base_impl<P, D>(ptr_, D()); // placement
// note: the original ::new... above is replaced by the one here. This one
// creates all new objects with a null_deleter so that after the archive
// is finished loading and the shared_ptrs are destroyed - the underlying
@@ -209,7 +227,7 @@ inline void serialize(
boost::checked_deleter< T > \
> __shared_ptr_ ## T; \
BOOST_CLASS_EXPORT_GUID(__shared_ptr_ ## T, "__shared_ptr_" K) \
BOOST_CLASS_EXPORT_GUID_1(T, K) \
BOOST_CLASS_EXPORT_GUID(T, K) \
/**/
#define BOOST_SHARED_POINTER_EXPORT(T) \
+3 -4
View File
@@ -49,9 +49,9 @@ inline void load(
// retrieve number of elements
t.clear();
// retrieve number of elements
collection_size_type count;
unsigned int count;
ar >> BOOST_SERIALIZATION_NVP(count);
if(std::size_t(0) == count)
if(0 == count)
return;
unsigned int v;
if(3 < ar.get_library_version()){
@@ -62,8 +62,7 @@ inline void load(
t.push_front(u.reference());
BOOST_DEDUCED_TYPENAME BOOST_STD_EXTENSION_NAMESPACE::slist<U, Allocator>::iterator last;
last = t.begin();
std::size_t c = count;
while(--c > 0){
while(--count > 0){
boost::serialization::detail::stack_construct<Archive, U>
u(ar, file_version);
ar >> boost::serialization::make_nvp("item", u.reference());
+2 -1
View File
@@ -29,6 +29,7 @@
#include <boost/type_traits/is_pointer.hpp>
#include <boost/serialization/level.hpp>
#include <boost/serialization/tracking_enum.hpp>
//#include <boost/serialization/traits.hpp>
namespace boost {
namespace serialization {
@@ -64,7 +65,7 @@ struct tracking_level {
// is never
mpl::int_<track_never>,
// otherwise its selective
mpl::int_<track_selectively>
mpl::int_<track_selectivly>
> > >::type type;
BOOST_STATIC_CONSTANT(int, value = tracking_level::type::value);
};
@@ -30,7 +30,7 @@ enum tracking_type
track_never = 0,
// track objects of this type if the object is serialized through a
// pointer.
track_selectively = 1,
track_selectivly = 1,
// always track this type
track_always = 2
};
+1 -4
View File
@@ -28,7 +28,6 @@
#include <boost/static_assert.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/serialization/level_enum.hpp>
#include <boost/serialization/tracking_enum.hpp>
@@ -46,8 +45,7 @@ template<
int Level,
int Tracking,
unsigned int Version = 0,
class ETII = extended_type_info_impl< T >,
class Wrapper = mpl::false_
class ETII = extended_type_info_impl< T >
>
struct traits : public basic_traits {
BOOST_STATIC_ASSERT(Version == 0 || Level >= object_class_info);
@@ -56,7 +54,6 @@ struct traits : public basic_traits {
typedef BOOST_DEDUCED_TYPENAME mpl::int_<Tracking> tracking;
typedef BOOST_DEDUCED_TYPENAME mpl::int_<Version> version;
typedef ETII type_info_implementation;
typedef Wrapper is_wrapper;
};
} // namespace serialization

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