mirror of
https://github.com/boostorg/serialization.git
synced 2026-07-24 13:57:51 +00:00
Compare commits
128 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 96fe06322f | |||
| 30e6e9dcba | |||
| 5df2c12166 | |||
| 831203f981 | |||
| d2cdb8e73c | |||
| 48f60529ab | |||
| a790233141 | |||
| 1aeba3c035 | |||
| add7159a85 | |||
| c35f7b34e2 | |||
| 752acdafee | |||
| 6f6ccc2e44 | |||
| b0e384ec1a | |||
| c51325635f | |||
| 7f00638dfb | |||
| 0c5bb1d032 | |||
| 268e85f5c1 | |||
| 08a364878c | |||
| e3c144e09a | |||
| 3f5938f35b | |||
| 0986103ceb | |||
| 806db58269 | |||
| 52411aaff4 | |||
| 35dc8ceebf | |||
| 10a5027b29 | |||
| 1e7f3d4b9d | |||
| e26ebab471 | |||
| 727a372834 | |||
| 4609f2c6fb | |||
| 0eefcbe3bd | |||
| 09ef207293 | |||
| dcccc51327 | |||
| 23db071843 | |||
| eda61aea60 | |||
| 099e0fd257 | |||
| e4f0a979e7 | |||
| 5c43de71cf | |||
| 9979fad749 | |||
| 65f7cade32 | |||
| e66fef7d07 | |||
| 3053878538 | |||
| 9be8f7c2ee | |||
| 4488fddadf | |||
| 9c3179680d | |||
| a26e8dc9be | |||
| b56f059ef3 | |||
| 57ee259098 | |||
| 9183c84f38 | |||
| b933c57ea4 | |||
| 06377e7ca9 | |||
| 1ef7246322 | |||
| 92f636b6ed | |||
| abd6e3c3d7 | |||
| 96338cc37e | |||
| d8e47b3a1f | |||
| 13f72ef7c4 | |||
| 6c7b3c7d61 | |||
| 898ca1b294 | |||
| 03fbead691 | |||
| 9cff60d2e8 | |||
| ed522ce134 | |||
| 33814c1296 | |||
| 21e3e4d452 | |||
| ecdcc90ede | |||
| d447c038ef | |||
| 7367a517fb | |||
| f939ebee1a | |||
| fadadb37c9 | |||
| 0a82da5e09 | |||
| 685d1aea26 | |||
| 71e5d4bc98 | |||
| 479977daeb | |||
| 14f0f8271d | |||
| f3cf6293e5 | |||
| 7d9bd7871d | |||
| 1e802d9677 | |||
| 7910677c3a | |||
| 9377f754b0 | |||
| deba15f9b5 | |||
| 080e666ec2 | |||
| f2cf93b688 | |||
| 91770338cd | |||
| 5624bc552a | |||
| 3c64171df1 | |||
| 666100d27e | |||
| 0edcefcdda | |||
| 49a9a29140 | |||
| 320ebce20f | |||
| 9db5b5005c | |||
| ec4e5124f4 | |||
| 5a29bca85c | |||
| 01752ec977 | |||
| 9011c6833d | |||
| fba3d86b5d | |||
| e4d0d3d61e | |||
| 4103202f8d | |||
| 4ebe6da43c | |||
| c3c306214e | |||
| c9f8099931 | |||
| af63fcc0be | |||
| 88ee3bb76c | |||
| 092843d04d | |||
| 3eade6147a | |||
| c9a0dfe045 | |||
| 1a7b698181 | |||
| 3303bd4c3e | |||
| cd709fdba5 | |||
| 625c97e63b | |||
| 32804edc06 | |||
| c496f8441f | |||
| a37379fadb | |||
| 951ab1abca | |||
| 3acfb736d6 | |||
| 0b13678ee0 | |||
| 60e977b85f | |||
| b930154408 | |||
| 3b585d5049 | |||
| 4e5e1e8120 | |||
| 72e8ea4f06 | |||
| a013adf37c | |||
| 846e2d4fa3 | |||
| e9b9eb61db | |||
| 3af3d629bf | |||
| f2f7b5eb64 | |||
| 7459fe85b2 | |||
| 1bebf9f64d | |||
| 88b081a37c | |||
| 1c58902378 |
+28
-11
@@ -10,12 +10,31 @@ 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_oarchive
|
||||
basic_iserializer
|
||||
basic_oarchive
|
||||
basic_oserializer
|
||||
basic_pointer_iserializer
|
||||
basic_pointer_oserializer
|
||||
@@ -25,6 +44,7 @@ SOURCES =
|
||||
basic_xml_archive
|
||||
binary_iarchive
|
||||
binary_oarchive
|
||||
codecvt_null
|
||||
extended_type_info
|
||||
extended_type_info_no_rtti
|
||||
extended_type_info_typeid
|
||||
@@ -40,14 +60,13 @@ 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
|
||||
@@ -56,15 +75,13 @@ WSOURCES =
|
||||
lib boost_serialization
|
||||
: $(SOURCES).cpp
|
||||
: <toolset>msvc:<cxxflags>/Gy
|
||||
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
|
||||
:
|
||||
: <link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
|
||||
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
|
||||
<conditional>@include-spirit
|
||||
;
|
||||
|
||||
lib boost_wserialization
|
||||
: $(WSOURCES).cpp boost_serialization
|
||||
: <toolset>msvc:<cxxflags>/Gy
|
||||
<link>shared:<define>BOOST_WSERIALIZATION_DYN_LINK=1
|
||||
:
|
||||
: <link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
|
||||
: <toolset>msvc:<cxxflags>/Gy
|
||||
<link>shared:<define>BOOST_SERIALIZATION_DYN_LINK=1
|
||||
<conditional>@include-spirit
|
||||
;
|
||||
|
||||
@@ -27,6 +27,12 @@ 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
|
||||
|
||||
@@ -43,8 +43,7 @@ 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>.
|
||||
In order to diminish code repetition, input archives included with this library
|
||||
have all been derived from the following template:
|
||||
All input archives should be derived from the following template:
|
||||
<pre><code>
|
||||
template<class Archive>
|
||||
detail::common_iarchive;
|
||||
@@ -368,9 +367,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_impl_hpp href="../../../boost/archive/detail/polymorphic_iarchive_impl.hpp"><code style="white-space: normal">polymorphic_iarchive_impl.hpp</code></a>
|
||||
<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>
|
||||
and
|
||||
<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>.
|
||||
<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>.
|
||||
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>
|
||||
|
||||
@@ -20,7 +20,7 @@ http://www.boost.org/LICENSE_1_0.txt)
|
||||
</td>
|
||||
<td valign="top">
|
||||
<h1 align="center">Serialization</h1>
|
||||
<h2 align="center">Archive Class Diagram</h2>
|
||||
<h2 align="center">Text Archive Class Diagram</h2>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -59,7 +59,7 @@ common_iarchive<text_iarchive> <a href="../../../boost/archive/detail/comm
|
||||
| \ /
|
||||
| \ /
|
||||
| \ /
|
||||
<font color="red">text_iarchive</font> <a href="../../../boost/archive/text_iarchive.hpp">-></a> polymorphic_iarchive_impl<text_iarchive_impl<text_iarchive> > <a href="../../../boost/archive/detail/polymorphic_iarchive_impl.hpp">-></a>
|
||||
<font color="red">text_iarchive</font> <a href="../../../boost/archive/text_iarchive.hpp">-></a> polymorphic_iarchive_dispatch<text_iarchive_impl<text_iarchive> > <a href="../../../boost/archive/detail/polymorphic_iarchive_dispatch.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 implment the library and should
|
||||
type of archive. Other classes whose names are in black implement 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_impl.hpp">polymorphic_iarchive_impl<text_iarchive_impl<text_iarchive> ></a>
|
||||
<a href="../../../boost/archive/detail/polymorphic_iarchive_dispatch.hpp">polymorphic_iarchive_dispatch<text_iarchive_impl<text_iarchive> ></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 impelenting class would be text_iarchive_impl.
|
||||
that implementing 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_impl<text_iarchive_impl<text_iarchive> ></code>
|
||||
<code style="white-space: normal">polymorphic_iarchive_dispatch<text_iarchive_impl<text_iarchive> ></code>
|
||||
|
||||
</dl>
|
||||
<hr>
|
||||
|
||||
+9
-1
@@ -87,7 +87,9 @@ 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#recent_improvements">Differences from version 1.32</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#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>
|
||||
@@ -155,7 +157,9 @@ 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>
|
||||
@@ -167,6 +171,7 @@ 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>
|
||||
@@ -183,6 +188,9 @@ 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>
|
||||
|
||||
@@ -30,6 +30,7 @@ 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>
|
||||
|
||||
|
||||
@@ -93,7 +94,7 @@ following features:
|
||||
</ul>
|
||||
The serialization system maintains two global tables.
|
||||
<ul>
|
||||
<li>The first is a global type table. it and has with an entry for each type used.
|
||||
<li>The first is a global type table. it has 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>
|
||||
@@ -310,7 +311,9 @@ 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. 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.
|
||||
<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>
|
||||
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.
|
||||
|
||||
+12
-1
@@ -257,7 +257,18 @@ 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
@@ -235,9 +235,9 @@ BOOST_SERIALIZATION_TRACKING(construct_from, track_never)
|
||||
<li><code style="white-space: normal">shared_ptr<construct_from></code>
|
||||
is not going to have a single raw pointer shared amongst the instances. Each loaded
|
||||
<code style="white-space: normal">shared_ptr<construct_from></code> is going to
|
||||
have its own distince raw pointer. This will break
|
||||
have its own distinct 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 would
|
||||
The cause of this problem is very far removed from the point of discovery. It could
|
||||
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 << 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 at the following to my
|
||||
might not even be written yet). OK, I'll add the following to my
|
||||
construct_from.hpp to solve the problem.
|
||||
<code style="white-space: normal"><pre>
|
||||
BOOST_SERIALIZATION_TRACKING(construct_from, track_never)
|
||||
|
||||
+19
-15
@@ -27,7 +27,9 @@ http://www.boost.org/LICENSE_1_0.txt)
|
||||
<hr>
|
||||
<dl class="index">
|
||||
<dt><a href="#requirements">Requirements</a></dt>
|
||||
<dt><a href="#recent_improvements">Differences from version 1.32</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="#todo">Pending Issues</a></dt>
|
||||
</dl>
|
||||
This is the Boost 1.33 Serialization Library.
|
||||
@@ -41,23 +43,17 @@ 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,
|
||||
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:
|
||||
set an environmental variable SPIRIT_ROOT to be equal to the root
|
||||
directory where the downloaded copy of spirit has been placed. E. G.
|
||||
<pre><code>
|
||||
using borland : 5.6.4 : "C:/Program Files/Borland/CBuilder6/Bin/bcc32" :
|
||||
<cxxflags>-IC:/spirit1.6 ;
|
||||
set SPIRIT_ROOT=c:/spirit16
|
||||
</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="recent_improvements"></a>Differences from Boost 1.32</h2>
|
||||
<h2><a name="differences_1_32"></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>.
|
||||
@@ -84,10 +80,19 @@ at the front of the list of include paths.
|
||||
<li>More compilers tested and supported.
|
||||
<li>Miscelleanous bug fixes.
|
||||
</ul>
|
||||
<h2><a name="recent_improvements"></a>Differences from Boost 1.33</h2>
|
||||
<h2><a name="differences_1_33"></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 noticible faster execution in some cases.
|
||||
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.
|
||||
</ul>
|
||||
|
||||
<h2><a name="todo"></a>Pending issues</h2>
|
||||
@@ -111,9 +116,8 @@ 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>© Copyright <a href="http://www.rrsd.com">Robert Ramey</a> 2002-2004.
|
||||
<p><i>© Copyright <a href="http://www.rrsd.com">Robert Ramey</a> 2002-2007.
|
||||
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>
|
||||
|
||||
+19
-25
@@ -437,6 +437,9 @@ 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
|
||||
@@ -533,14 +536,18 @@ will have to be overridden. Here is a simple example:
|
||||
class my_class {
|
||||
private:
|
||||
friend class boost::serialization::access;
|
||||
int member;
|
||||
const int m_attribute; // some immutable aspect of the instance
|
||||
int m_state; // mutable state of this instance
|
||||
template<class Archive>
|
||||
void serialize(Archive &ar, const unsigned int file_version){
|
||||
ar & member;
|
||||
ar & m_state;
|
||||
}
|
||||
public:
|
||||
my_class(int m) :
|
||||
member(m)
|
||||
// no default construct guarentees that no invalid object
|
||||
// ever exists
|
||||
my_class(int attribute) :
|
||||
m_attribute(attribute),
|
||||
m_state(0)
|
||||
{}
|
||||
};
|
||||
</code></pre>
|
||||
@@ -552,7 +559,7 @@ inline void save_construct_data(
|
||||
Archive & ar, const my_class * t, const unsigned int file_version
|
||||
){
|
||||
// save data required to construct instance
|
||||
ar << t->member;
|
||||
ar << t->m_attribute;
|
||||
}
|
||||
|
||||
template<class Archive>
|
||||
@@ -560,10 +567,10 @@ inline void load_construct_data(
|
||||
Archive & ar, my_class * t, const unsigned int file_version
|
||||
){
|
||||
// retrieve data from archive required to construct new instance
|
||||
int m;
|
||||
ar >> m;
|
||||
int attribute;
|
||||
ar >> attribute;
|
||||
// invoke inplace constructor to initialize instance of my_class
|
||||
::new(t)my_class(m);
|
||||
::new(t)my_class(attribute);
|
||||
}
|
||||
}} // namespace ...
|
||||
</code></pre>
|
||||
@@ -716,22 +723,6 @@ 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
|
||||
@@ -799,7 +790,10 @@ class derived : public base {
|
||||
// method 1 : invoke base class serialization
|
||||
boost::serialization::base_object<base>(*this);
|
||||
// method 2 : explicitly register base/derived relationship
|
||||
boost::serialization::void_cast_register<derived, base>();
|
||||
boost::serialization::void_cast_register<derived, base>(
|
||||
static_cast<base *>(NULL),
|
||||
static_cast<derived *>(NULL)
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+135
-93
@@ -36,6 +36,9 @@ 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>
|
||||
@@ -154,103 +157,50 @@ 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.
|
||||
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.
|
||||
<p>
|
||||
There are several ways <code style="white-space: normal">BOOST_CLASS_EXPORT</code> could have been
|
||||
implemented.
|
||||
<p>
|
||||
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>
|
||||
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 <boost/archive/*archive.hpp> 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 <boost/archive/...> are included.
|
||||
// Headers can be included in any order.
|
||||
#include <boost/serialization/...>
|
||||
#include <boost/serialization/export.hpp>
|
||||
... // include other headers that A depends upon
|
||||
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>.
|
||||
|
||||
class A {
|
||||
...
|
||||
};
|
||||
<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:
|
||||
|
||||
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 <boost/archive/text_oarchive.hpp>
|
||||
#include <boost/archive/text_iarchive.hpp>
|
||||
...
|
||||
#include <boost/serialization/...>
|
||||
...
|
||||
// can't do the following because then A.hpp couldn't be included somewhere else
|
||||
// #include <boost/serialization/export.hpp>
|
||||
<pre><code>
|
||||
#include <boost/archive/xml_oarchive.hpp>
|
||||
.... // any other archive classes
|
||||
#include "my_class.hpp" // which contains BOOST_CLASS_EXPORT(my_class)
|
||||
</code></pre>
|
||||
|
||||
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 <.../export.hpp></code> can't be used
|
||||
without conflicting with other modules which use
|
||||
<code style="white-space: normal">#include <.../*archive.hpp></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 <boost/serialization/export.hpp>
|
||||
...
|
||||
BOOST_CLASS_EXPORT(A)
|
||||
...
|
||||
</pre></code>
|
||||
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> .
|
||||
|
||||
<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.
|
||||
|
||||
<h3><a name="classinfo">Class Information</a></h3>
|
||||
By default, for each class serialized, class information is written to the archive.
|
||||
@@ -311,6 +261,16 @@ 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"><boost/cstdint.hpp></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:
|
||||
@@ -385,6 +345,88 @@ 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>
|
||||
|
||||
|
||||
+51
-2
@@ -32,6 +32,7 @@ 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
|
||||
@@ -255,6 +256,8 @@ 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
|
||||
@@ -311,6 +314,50 @@ 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<class T>
|
||||
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<T>::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<my_class>
|
||||
: 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
|
||||
@@ -407,7 +454,8 @@ template<
|
||||
int Level,
|
||||
int Tracking,
|
||||
unsigned int Version = 0,
|
||||
class ETII = BOOST_SERIALIZATION_DEFAULT_TYPE_INFO(T)
|
||||
class ETII = BOOST_SERIALIZATION_DEFAULT_TYPE_INFO(T),
|
||||
class IsWrapper = mpl::false_
|
||||
>
|
||||
struct traits
|
||||
</code></pre>
|
||||
@@ -420,10 +468,11 @@ 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>© Copyright <a href="http://www.rrsd.com">Robert Ramey</a> 2002-2004.
|
||||
<p><i>© Copyright <a href="http://www.rrsd.com">Robert Ramey</a> 2002-2004 and Matthias Troyer 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)
|
||||
</i></p>
|
||||
|
||||
+5
-2
@@ -539,8 +539,11 @@ 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 macros are needed to associate a data
|
||||
item name with the corresponding xml tag. For more information see
|
||||
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
|
||||
<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.
|
||||
|
||||
+71
-4
@@ -27,7 +27,9 @@ 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>
|
||||
@@ -36,6 +38,9 @@ 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
|
||||
@@ -56,6 +61,45 @@ 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<T></code> or a <code>std::vector<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 <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.
|
||||
@@ -67,6 +111,26 @@ 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
|
||||
@@ -120,12 +184,15 @@ 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>
|
||||
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_gps.hpp" target="demo_gps_hpp">demo_gps.hpp<a>
|
||||
includes NVP wrappers or all data members.
|
||||
<a href="../example/demo_xml.cpp" target="demo_xml_cpp">demo_xml.cpp<a>
|
||||
which saves and loads data to an XML archive.
|
||||
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.
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
# 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 ;
|
||||
@@ -20,6 +20,7 @@
|
||||
#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
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef BOOST_SERIALIZATION_EXAMPLE_DEMO_XML_HPP
|
||||
#define BOOST_SERIALIZATION_EXAMPLE_DEMO_XML_HPP
|
||||
#ifndef BOOST_SERIALIZATION_EXAMPLE_DEMO_GPS_HPP
|
||||
#define BOOST_SERIALIZATION_EXAMPLE_DEMO_GPS_HPP
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
//
|
||||
// demo_xml.hpp
|
||||
// demo_gps.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_XML_HPP
|
||||
#endif // BOOST_SERIALIZATION_EXAMPLE_DEMO_GPS_HPP
|
||||
@@ -133,13 +133,6 @@ 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;
|
||||
}
|
||||
@@ -157,13 +150,6 @@ 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;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace std{
|
||||
#include <boost/archive/xml_iarchive.hpp>
|
||||
#include <boost/archive/xml_oarchive.hpp>
|
||||
|
||||
#include "demo_xml.hpp"
|
||||
#include "demo_gps.hpp"
|
||||
|
||||
void save_schedule(const bus_schedule &s, const char * filename){
|
||||
// make an archive
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include <boost/archive/xml_iarchive.hpp>
|
||||
|
||||
#include "demo_xml.hpp"
|
||||
#include "demo_gps.hpp"
|
||||
|
||||
void
|
||||
restore_schedule(bus_schedule &s, const char * filename)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include <boost/archive/xml_oarchive.hpp>
|
||||
|
||||
#include "demo_xml.hpp"
|
||||
#include "demo_gps.hpp"
|
||||
|
||||
void save_schedule(const bus_schedule &s, const char * filename){
|
||||
// make an archive
|
||||
|
||||
@@ -55,7 +55,8 @@ 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,
|
||||
@@ -92,12 +93,27 @@ 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));
|
||||
|
||||
@@ -52,13 +52,25 @@ public:
|
||||
friend class boost::archive::basic_binary_oarchive<portable_binary_oarchive>;
|
||||
friend class boost::archive::save_access;
|
||||
#endif
|
||||
void save_impl(long l){
|
||||
void save_impl(const long l){
|
||||
long ll = l;
|
||||
char size = 0;;
|
||||
do{
|
||||
ll >>= 8;
|
||||
++size;
|
||||
}while(ll != -1 && ll != 0);
|
||||
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);
|
||||
}
|
||||
|
||||
this->archive_base_t::save(size);
|
||||
|
||||
@@ -84,6 +96,12 @@ 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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
#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
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
#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
|
||||
|
||||
@@ -117,14 +117,4 @@ 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
|
||||
|
||||
@@ -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 detail::common_iarchive<Archive>
|
||||
public array::iarchive<Archive>
|
||||
{
|
||||
protected:
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
@@ -56,11 +56,10 @@ 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 detail::common_iarchive<Archive> detail_common_iarchive;
|
||||
typedef array::iarchive<Archive> array_iarchive;
|
||||
template<class T>
|
||||
void load_override(T & t, BOOST_PFTO int)
|
||||
{
|
||||
this->detail_common_iarchive::load_override(t, 0);
|
||||
void load_override(T & t, BOOST_PFTO int){
|
||||
this->array_iarchive::load_override(t, 0);
|
||||
}
|
||||
// binary files don't include the optional information
|
||||
void load_override(class_id_optional_type & /* t */, int){}
|
||||
@@ -69,39 +68,44 @@ public:
|
||||
// for these pseudo prmitive types.
|
||||
void load_override(version_type & t, int){
|
||||
// upto 255 versions
|
||||
unsigned char x;
|
||||
unsigned char x=0;
|
||||
* this->This() >> x;
|
||||
t = version_type(x);
|
||||
}
|
||||
void load_override(class_id_type & t, int){
|
||||
// upto 32K classes
|
||||
int_least16_t x;
|
||||
int_least16_t x=0;
|
||||
* this->This() >> x;
|
||||
t = class_id_type(x);
|
||||
}
|
||||
void load_override(class_id_reference_type & t, int){
|
||||
// upto 32K classes
|
||||
int_least16_t x;
|
||||
int_least16_t x=0;
|
||||
* this->This() >> x;
|
||||
t = class_id_reference_type(x);
|
||||
}
|
||||
void load_override(object_id_type & t, int){
|
||||
// upto 2G objects
|
||||
uint_least32_t x;
|
||||
uint_least32_t x=0;
|
||||
* this->This() >> x;
|
||||
t = object_id_type(x);
|
||||
}
|
||||
void load_override(object_reference_type & t, int){
|
||||
// upto 2G objects
|
||||
uint_least32_t x;
|
||||
uint_least32_t x=0;
|
||||
* this->This() >> x;
|
||||
t = object_reference_type(x);
|
||||
}
|
||||
void load_override(tracking_type & t, int){
|
||||
char x;
|
||||
char x=0;
|
||||
* 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);
|
||||
@@ -109,7 +113,7 @@ public:
|
||||
init();
|
||||
|
||||
basic_binary_iarchive(unsigned int flags) :
|
||||
detail::common_iarchive<Archive>(flags)
|
||||
array_iarchive(flags)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
@@ -48,6 +48,9 @@ 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 {
|
||||
@@ -86,6 +89,7 @@ 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);
|
||||
@@ -108,6 +112,16 @@ 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);
|
||||
};
|
||||
@@ -146,7 +160,7 @@ basic_binary_iprimitive<Archive, Elem, Tr>::load_binary(
|
||||
static_cast<Elem *>(address),
|
||||
s
|
||||
);
|
||||
if(count != static_cast<std::size_t>(s))
|
||||
if(scount != static_cast<std::size_t>(s))
|
||||
boost::throw_exception(
|
||||
archive_exception(archive_exception::stream_error)
|
||||
);
|
||||
@@ -157,7 +171,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(count != 1)
|
||||
if(scount != 1)
|
||||
boost::throw_exception(
|
||||
archive_exception(archive_exception::stream_error)
|
||||
);
|
||||
|
||||
@@ -27,8 +27,10 @@
|
||||
#include <boost/pfto.hpp>
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/archive/detail/common_oarchive.hpp>
|
||||
#include <boost/archive/array/oarchive.hpp>
|
||||
#include <boost/serialization/string.hpp>
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
#include <boost/archive/array/oarchive.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
@@ -41,12 +43,9 @@ 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 detail::common_oarchive<Archive>
|
||||
public array::oarchive<Archive>
|
||||
{
|
||||
protected:
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
@@ -59,10 +58,14 @@ public:
|
||||
friend class detail::interface_oarchive<Archive>;
|
||||
#endif
|
||||
// any datatype not specifed below will be handled by base class
|
||||
typedef detail::common_oarchive<Archive> detail_common_oarchive;
|
||||
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);
|
||||
}
|
||||
template<class T>
|
||||
void save_override(T & t, BOOST_PFTO int){
|
||||
this->detail_common_oarchive::save_override(t, 0);
|
||||
this->save_override(const_cast<const T &>(t), 0);
|
||||
}
|
||||
// binary files don't include the optional information
|
||||
void save_override(const class_id_optional_type & /* t */, int){}
|
||||
@@ -70,22 +73,22 @@ public:
|
||||
void save_override(const version_type & t, int){
|
||||
// upto 255 versions
|
||||
// note:t.t resolves borland ambguity
|
||||
unsigned char x = t.t;
|
||||
const unsigned char x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const class_id_type & t, int){
|
||||
// upto 32K classes
|
||||
int_least16_t x = t.t;
|
||||
const int_least16_t x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const class_id_reference_type & t, int){
|
||||
// upto 32K classes
|
||||
int_least16_t x = t.t;
|
||||
const int_least16_t x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const object_id_type & t, int){
|
||||
// upto 2G objects
|
||||
uint_least32_t x = t.t;
|
||||
const uint_least32_t x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const object_reference_type & t, int){
|
||||
@@ -94,7 +97,7 @@ public:
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const tracking_type & t, int){
|
||||
char x = t.t;
|
||||
const char x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
|
||||
@@ -104,11 +107,17 @@ 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) :
|
||||
detail::common_oarchive<Archive>(flags)
|
||||
array_oarchive(flags)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
@@ -46,6 +46,9 @@ 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 {
|
||||
@@ -101,6 +104,7 @@ 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,
|
||||
@@ -109,6 +113,16 @@ 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){}
|
||||
|
||||
|
||||
@@ -78,36 +78,39 @@ public:
|
||||
// start new objects on a new line
|
||||
void save_override(const object_id_type & t, int){
|
||||
this->This()->newline();
|
||||
// and and invoke prmitive to underlying value
|
||||
// note extra .t to funciton with Borland 5.51 compiler
|
||||
// and invoke prmitive to underlying value
|
||||
this->This()->save(t.t);
|
||||
}
|
||||
|
||||
void save_override(const object_reference_type & t, int){
|
||||
this->This()->newline();
|
||||
// and and invoke prmitive to underlying value
|
||||
// note extra .t to funciton with Borland 5.51 compiler
|
||||
// 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;
|
||||
|
||||
@@ -89,10 +89,8 @@ public:
|
||||
void save(const bool t){
|
||||
// trap usage of invalid uninitialized boolean which would
|
||||
// otherwise crash on load.
|
||||
#ifndef NDEBUG
|
||||
int i = t;
|
||||
assert(0 == i || 1 == i);
|
||||
#endif
|
||||
if(os.fail())
|
||||
boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
os << t;
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
xml_archive_tag_mismatch,
|
||||
xml_archive_tag_name_error
|
||||
} exception_code;
|
||||
xml_archive_exception(exception_code /* c */)
|
||||
xml_archive_exception(exception_code c)
|
||||
{}
|
||||
virtual const char *what( ) const throw( )
|
||||
{
|
||||
|
||||
@@ -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,6 +25,8 @@
|
||||
#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 {
|
||||
@@ -33,7 +35,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:
|
||||
@@ -60,7 +62,8 @@ 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_STATIC_ASSERT(0 == sizeof(T));
|
||||
BOOST_MPL_ASSERT((serialization::is_wrapper<T>));
|
||||
this->detail_common_iarchive::load_override(t, 0);
|
||||
}
|
||||
|
||||
// Anything not an attribute - see below - should be a name value
|
||||
@@ -71,7 +74,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());
|
||||
@@ -101,9 +104,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();
|
||||
};
|
||||
|
||||
|
||||
@@ -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,15 +24,18 @@
|
||||
#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:
|
||||
@@ -42,8 +45,10 @@ 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;
|
||||
@@ -55,13 +60,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
|
||||
@@ -80,7 +85,8 @@ 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_STATIC_ASSERT(0 == sizeof(T));
|
||||
BOOST_MPL_ASSERT((serialization::is_wrapper<T>));
|
||||
this->detail_common_oarchive::save_override(t, 0);
|
||||
}
|
||||
|
||||
// special treatment for name-value pairs.
|
||||
@@ -90,7 +96,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());
|
||||
@@ -117,9 +123,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();
|
||||
};
|
||||
|
||||
|
||||
@@ -22,6 +22,43 @@
|
||||
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.
|
||||
@@ -30,7 +67,8 @@ 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) :
|
||||
@@ -48,8 +86,7 @@ public:
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::binary_iarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_iarchive)
|
||||
|
||||
#endif // BOOST_ARCHIVE_BINARY_IARCHIVE_HPP
|
||||
|
||||
@@ -43,11 +43,12 @@ public:
|
||||
{}
|
||||
};
|
||||
|
||||
typedef binary_oarchive naked_binary_oarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::binary_oarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_oarchive)
|
||||
|
||||
#endif // BOOST_ARCHIVE_BINARY_OARCHIVE_HPP
|
||||
|
||||
@@ -27,9 +27,43 @@
|
||||
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.
|
||||
// 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 {
|
||||
|
||||
class binary_wiarchive :
|
||||
public binary_iarchive_impl<
|
||||
binary_wiarchive, std::wistream::char_type, std::wistream::traits_type
|
||||
@@ -51,9 +85,8 @@ public:
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::binary_wiarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_wiarchive)
|
||||
|
||||
#endif // BOOST_NO_STD_WSTREAMBUF
|
||||
#endif // BOOST_ARCHIVE_BINARY_WIARCHIVE_HPP
|
||||
|
||||
@@ -48,12 +48,13 @@ public:
|
||||
{}
|
||||
};
|
||||
|
||||
typedef binary_woarchive naked_binary_woarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::binary_woarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_woarchive)
|
||||
|
||||
#endif // BOOST_NO_STD_WSTREAMBUF
|
||||
#endif // BOOST_ARCHIVE_BINARY_WOARCHIVE_HPP
|
||||
|
||||
@@ -25,14 +25,16 @@ 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;
|
||||
#endif
|
||||
#elif defined(BOOST_RWSTD_VER)
|
||||
using ::mbstate_t;
|
||||
#endif
|
||||
} // namespace std
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -13,3 +13,8 @@
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4251 4231 4660 4275)
|
||||
#endif
|
||||
|
||||
#if defined( __BORLANDC__ )
|
||||
#pragma nopushoptwarn
|
||||
#endif
|
||||
|
||||
|
||||
@@ -12,3 +12,8 @@
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
#include <boost/config/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#if defined( __BORLANDC__ )
|
||||
#pragma nopushoptwarn
|
||||
#endif
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
// #include <boost/scoped_ptr.hpp>
|
||||
|
||||
#include <set>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
@@ -35,48 +34,6 @@ 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,16 +65,8 @@ protected:
|
||||
public:
|
||||
// note: NOT part of the public API.
|
||||
void next_object_pointer(void *t);
|
||||
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 register_basic_serializer(
|
||||
const basic_iserializer & bis
|
||||
);
|
||||
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);
|
||||
basic_oarchive(unsigned int flags = 0);
|
||||
// account for bogus gcc warning
|
||||
#if defined(__GNUC__)
|
||||
virtual
|
||||
@@ -70,24 +70,17 @@ protected:
|
||||
~basic_oarchive();
|
||||
public:
|
||||
// note: NOT part of the public interface
|
||||
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 register_basic_serializer(
|
||||
const BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oserializer & bos
|
||||
);
|
||||
void save_object(
|
||||
const void *x,
|
||||
const basic_oserializer & bos
|
||||
const BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oserializer & bos
|
||||
);
|
||||
void save_pointer(
|
||||
const void * t,
|
||||
const basic_pointer_oserializer * bpos_ptr
|
||||
const BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
basic_pointer_oserializer * bpos_ptr
|
||||
);
|
||||
void save_null_pointer(){
|
||||
vsave(NULL_POINTER_TAG);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#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 {
|
||||
@@ -31,6 +32,7 @@ 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;
|
||||
@@ -61,7 +63,7 @@ protected:
|
||||
void load_start(const char *name){}
|
||||
void load_end(const char *name){}
|
||||
// default archive initialization
|
||||
common_iarchive(unsigned int flags) :
|
||||
common_iarchive(unsigned int flags = 0) :
|
||||
basic_iarchive(flags),
|
||||
interface_iarchive<Archive>()
|
||||
{}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#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 {
|
||||
@@ -30,6 +31,7 @@ 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;
|
||||
@@ -61,10 +63,9 @@ 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) :
|
||||
common_oarchive(unsigned int flags = 0) :
|
||||
basic_oarchive(flags),
|
||||
interface_oarchive<Archive>()
|
||||
{}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
// 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,6 +28,7 @@ class shared_ptr;
|
||||
namespace serialization {
|
||||
class extended_type_info;
|
||||
} // namespace serialization
|
||||
|
||||
namespace archive {
|
||||
namespace detail {
|
||||
|
||||
@@ -50,28 +51,13 @@ public:
|
||||
}
|
||||
|
||||
template<class T>
|
||||
const basic_pointer_iserializer * register_type(T * = NULL){
|
||||
const basic_pointer_iserializer & bpis =
|
||||
instantiate_pointer_iserializer(
|
||||
static_cast<Archive *>(NULL),
|
||||
static_cast<T *>(NULL)
|
||||
);
|
||||
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();
|
||||
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,29 +51,14 @@ public:
|
||||
}
|
||||
|
||||
template<class T>
|
||||
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)
|
||||
);
|
||||
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();
|
||||
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);
|
||||
|
||||
@@ -44,6 +44,7 @@ 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>
|
||||
@@ -57,6 +58,7 @@ 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>
|
||||
@@ -65,7 +67,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/archive_exception.hpp>
|
||||
#include <boost/archive/detail/dynamically_initialized.hpp>
|
||||
|
||||
#include <boost/serialization/force_include.hpp>
|
||||
#include <boost/serialization/serialization.hpp>
|
||||
@@ -74,9 +76,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 {
|
||||
@@ -127,7 +129,7 @@ public:
|
||||
return boost::serialization::tracking_level<T>::value
|
||||
== boost::serialization::track_always
|
||||
|| boost::serialization::tracking_level<T>::value
|
||||
== boost::serialization::track_selectivly
|
||||
== boost::serialization::track_selectively
|
||||
&& serialized_as_pointer();
|
||||
}
|
||||
virtual unsigned int version() const {
|
||||
@@ -140,7 +142,7 @@ public:
|
||||
>::type::is_polymorphic::type typex;
|
||||
return typex::value;
|
||||
}
|
||||
static iserializer & instantiate(){
|
||||
static iserializer & get_instance(){
|
||||
static iserializer instance;
|
||||
return instance;
|
||||
}
|
||||
@@ -162,15 +164,14 @@ BOOST_DLLEXPORT void iserializer<Archive, T>::load_object_data(
|
||||
);
|
||||
}
|
||||
|
||||
// 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>
|
||||
template<class Archive, class T>
|
||||
class pointer_iserializer
|
||||
: public archive_pointer_iserializer<Archive>
|
||||
, public dynamically_initialized<pointer_iserializer<Archive,T> >
|
||||
{
|
||||
private:
|
||||
virtual const basic_iserializer & get_basic_serializer() const {
|
||||
return iserializer<Archive, T>::instantiate();
|
||||
return iserializer<Archive, T>::get_instance();
|
||||
}
|
||||
virtual BOOST_DLLEXPORT void load_object_ptr(
|
||||
basic_iarchive & ar,
|
||||
@@ -182,32 +183,18 @@ public:
|
||||
#endif
|
||||
// private constructor to inhibit any existence other than the
|
||||
// static one. Note GCC doesn't permit constructor to be private
|
||||
explicit BOOST_DLLEXPORT pointer_iserializer() BOOST_USED;
|
||||
static const pointer_iserializer instance;
|
||||
BOOST_DLLEXPORT pointer_iserializer() BOOST_USED;
|
||||
friend struct dynamically_initialized<pointer_iserializer<Archive,T> >;
|
||||
public:
|
||||
// at least one compiler (CW) seems to require that serialize_adl
|
||||
// be explicitly instantiated. Still under investigation.
|
||||
#if ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
|
||||
#if !defined(__BORLANDC__)
|
||||
void (* const m)(Archive &, T &, const unsigned);
|
||||
boost::serialization::extended_type_info * (* e)();
|
||||
#endif
|
||||
static BOOST_DLLEXPORT const pointer_iserializer & instantiate() BOOST_USED;
|
||||
virtual ~pointer_iserializer(){};
|
||||
BOOST_DLLEXPORT static const pointer_iserializer & get_instance() BOOST_USED;
|
||||
};
|
||||
|
||||
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.
|
||||
@@ -278,19 +265,15 @@ private:
|
||||
T* m_p;
|
||||
};
|
||||
|
||||
template<class T, class Archive>
|
||||
BOOST_DLLEXPORT void pointer_iserializer<T, Archive>::load_object_ptr(
|
||||
template<class Archive, class T>
|
||||
BOOST_DLLEXPORT void pointer_iserializer<Archive, T>::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()) ;
|
||||
@@ -312,6 +295,7 @@ BOOST_DLLEXPORT void pointer_iserializer<T, Archive>::load_object_ptr(
|
||||
);
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
ap.release();
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
@@ -320,25 +304,32 @@ BOOST_DLLEXPORT void pointer_iserializer<T, Archive>::load_object_ptr(
|
||||
ap.release();
|
||||
}
|
||||
|
||||
template<class T, class Archive>
|
||||
#if ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
|
||||
BOOST_DLLEXPORT pointer_iserializer<T, Archive>::pointer_iserializer() :
|
||||
template<class Archive, class T>
|
||||
#if !defined(__BORLANDC__)
|
||||
BOOST_DLLEXPORT pointer_iserializer<Archive, T>::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<T, Archive>::pointer_iserializer() :
|
||||
BOOST_DLLEXPORT pointer_iserializer<Archive, T>::pointer_iserializer() :
|
||||
archive_pointer_iserializer<Archive>(
|
||||
* boost::serialization::type_info_implementation<T>::type::get_instance()
|
||||
)
|
||||
#endif
|
||||
{
|
||||
iserializer<Archive, T> & bis = iserializer<Archive, T>::instantiate();
|
||||
iserializer<Archive, T> & bis = iserializer<Archive, T>::get_instance();
|
||||
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
|
||||
@@ -370,7 +361,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>::instantiate());
|
||||
ar.load_object(x, iserializer<Archive, T>::get_instance());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -506,6 +497,8 @@ 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]))
|
||||
@@ -517,12 +510,11 @@ struct load_array_type {
|
||||
boost::throw_exception(archive::archive_exception(
|
||||
boost::archive::archive_exception::array_size_too_short
|
||||
));
|
||||
int i;
|
||||
for(i = 0; i < count; ++i)
|
||||
ar >> boost::serialization::make_nvp("item", t[i]);
|
||||
ar >> serialization::make_array(static_cast<value_type*>(&t[0]),count);
|
||||
}
|
||||
};
|
||||
|
||||
#if 0
|
||||
// note bogus arguments to workaround msvc 6 silent runtime failure
|
||||
template<class Archive, class T>
|
||||
BOOST_DLLEXPORT
|
||||
@@ -539,10 +531,9 @@ instantiate_pointer_iserializer(
|
||||
Archive * /* ar = NULL */,
|
||||
T * /* t = NULL */
|
||||
){
|
||||
// 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();
|
||||
return pointer_iserializer<Archive,T>::instance;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // detail
|
||||
|
||||
@@ -572,7 +563,7 @@ inline void load(Archive &ar, T &t){
|
||||
|
||||
// BORLAND
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560))
|
||||
// borland has a couple fo problems
|
||||
// borland has a couple of 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
|
||||
@@ -585,21 +576,19 @@ inline void load(Archive &ar, const T & t){
|
||||
}
|
||||
#endif
|
||||
|
||||
// let wrappers through. (Someday implement is_wrapper)
|
||||
// let wrappers through.
|
||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
template<class Archive, class 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));
|
||||
inline void load_wrapper(Archive &ar, const T&t, mpl::true_){
|
||||
boost::archive::load(ar, const_cast<T&>(t));
|
||||
}
|
||||
|
||||
//template<class Archive, class T>
|
||||
//inline void load(Archive &ar, const serialization::binary_object &t){
|
||||
// load(ar, const_cast<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
|
||||
#endif
|
||||
|
||||
} // namespace archive
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
#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
|
||||
@@ -1,39 +0,0 @@
|
||||
#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
|
||||
@@ -37,6 +37,7 @@
|
||||
#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>
|
||||
@@ -57,6 +58,7 @@
|
||||
#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>
|
||||
@@ -66,6 +68,8 @@
|
||||
#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>
|
||||
|
||||
@@ -100,7 +104,7 @@ class oserializer : public basic_oserializer
|
||||
private:
|
||||
// private constructor to inhibit any existence other than the
|
||||
// static one
|
||||
explicit oserializer() :
|
||||
explicit BOOST_DLLEXPORT oserializer() :
|
||||
basic_oserializer(
|
||||
* boost::serialization::type_info_implementation<T>::type::get_instance()
|
||||
)
|
||||
@@ -118,7 +122,7 @@ public:
|
||||
// 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_selectivly
|
||||
|| boost::serialization::tracking_level<T>::value == boost::serialization::track_selectively
|
||||
&& serialized_as_pointer();
|
||||
}
|
||||
virtual unsigned int version() const {
|
||||
@@ -130,7 +134,7 @@ public:
|
||||
>::type::is_polymorphic::type typex;
|
||||
return typex::value;
|
||||
}
|
||||
static oserializer & instantiate(){
|
||||
static oserializer & get_instance(){
|
||||
static oserializer instance;
|
||||
return instance;
|
||||
}
|
||||
@@ -151,15 +155,14 @@ BOOST_DLLEXPORT void oserializer<Archive, T>::save_object_data(
|
||||
);
|
||||
}
|
||||
|
||||
// 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>
|
||||
template<class Archive, class T>
|
||||
class pointer_oserializer
|
||||
: public archive_pointer_oserializer<Archive>
|
||||
, public dynamically_initialized<pointer_oserializer<Archive,T> >
|
||||
{
|
||||
private:
|
||||
virtual const basic_oserializer & get_basic_serializer() const {
|
||||
return oserializer<Archive, T>::instantiate();
|
||||
return oserializer<Archive, T>::get_instance();
|
||||
}
|
||||
virtual BOOST_DLLEXPORT void save_object_ptr(
|
||||
basic_oarchive & ar,
|
||||
@@ -171,33 +174,19 @@ 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;
|
||||
static const pointer_oserializer instance;
|
||||
friend struct dynamically_initialized<pointer_oserializer<Archive,T> >;
|
||||
public:
|
||||
#if ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
|
||||
#if !defined(__BORLANDC__)
|
||||
// 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
|
||||
static BOOST_DLLEXPORT const pointer_oserializer & instantiate() BOOST_USED;
|
||||
virtual ~pointer_oserializer(){}
|
||||
BOOST_DLLEXPORT static const pointer_oserializer & get_instance() BOOST_USED;
|
||||
};
|
||||
|
||||
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(
|
||||
template<class Archive, class T>
|
||||
BOOST_DLLEXPORT void pointer_oserializer<Archive, T>::save_object_ptr(
|
||||
basic_oarchive & ar,
|
||||
const void * x
|
||||
) const {
|
||||
@@ -215,26 +204,33 @@ BOOST_DLLEXPORT void pointer_oserializer<T, Archive>::save_object_ptr(
|
||||
ar_impl << boost::serialization::make_nvp(NULL, * t);
|
||||
}
|
||||
|
||||
template<class T, class Archive>
|
||||
#if ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
|
||||
BOOST_DLLEXPORT pointer_oserializer<T, Archive>::pointer_oserializer() :
|
||||
template<class Archive, class T>
|
||||
#if !defined(__BORLANDC__)
|
||||
BOOST_DLLEXPORT pointer_oserializer<Archive, T>::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<T, Archive>::pointer_oserializer() :
|
||||
BOOST_DLLEXPORT pointer_oserializer<Archive, T>::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>::instantiate();
|
||||
oserializer<Archive, T> & bos = oserializer<Archive, T>::get_instance();
|
||||
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
|
||||
@@ -260,7 +256,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>::instantiate());
|
||||
ar.save_object(& t, oserializer<Archive, T>::get_instance());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -481,6 +477,8 @@ 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) / (
|
||||
@@ -488,12 +486,12 @@ struct save_array_type
|
||||
- static_cast<const char *>(static_cast<const void *>(&t[0]))
|
||||
);
|
||||
ar << BOOST_SERIALIZATION_NVP(count);
|
||||
int i;
|
||||
for(i = 0; i < count; ++i)
|
||||
ar << boost::serialization::make_nvp("item", t[i]);
|
||||
ar << serialization::make_array(static_cast<value_type const*>(&t[0]),count);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#if 0
|
||||
// note bogus arguments to workaround msvc 6 silent runtime failure
|
||||
// declaration to satisfy gcc
|
||||
template<class Archive, class T>
|
||||
@@ -509,10 +507,9 @@ instantiate_pointer_oserializer(
|
||||
Archive * /* ar = NULL */,
|
||||
T * /* t = NULL */
|
||||
){
|
||||
// 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();
|
||||
return pointer_oserializer<Archive, T>::instance;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // detail
|
||||
|
||||
@@ -557,12 +554,13 @@ struct check_tracking {
|
||||
|
||||
template<class Archive, class T>
|
||||
inline void save(Archive & ar, T &t){
|
||||
// if your program traps here, it indicates taht your doing one of the following:
|
||||
// if your program traps here, it indicates that 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.
|
||||
// object tracking. Also, see the "rationale" section of the documenation
|
||||
// for motivation for this checking.
|
||||
BOOST_STATIC_ASSERT(check_tracking<T>::value);
|
||||
save(ar, const_cast<const T &>(t));
|
||||
}
|
||||
|
||||
+7
-19
@@ -1,5 +1,5 @@
|
||||
#ifndef BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_IMPL_HPP
|
||||
#define BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_IMPL_HPP
|
||||
#ifndef BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_DISPATCH_HPP
|
||||
#define BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_DISPATCH_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_impl.hpp
|
||||
// polymorphic_iarchive_dispatch.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_impl :
|
||||
class polymorphic_iarchive_dispatch :
|
||||
public polymorphic_iarchive,
|
||||
// note: gcc dynamic cross cast fails if the the derivation below is
|
||||
// not public. I think this is a mistake.
|
||||
@@ -161,20 +161,8 @@ 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 inherited because they appear in mulitple
|
||||
// this can't be inheriteded because they appear in mulitple
|
||||
// parents
|
||||
typedef mpl::bool_<true> is_loading;
|
||||
typedef mpl::bool_<false> is_saving;
|
||||
@@ -192,7 +180,7 @@ public:
|
||||
|
||||
// all current archives take a stream as constructor argument
|
||||
template <class _Elem, class _Tr>
|
||||
polymorphic_iarchive_impl(
|
||||
polymorphic_iarchive_dispatch(
|
||||
std::basic_istream<_Elem, _Tr> & is,
|
||||
unsigned int flags = 0
|
||||
) :
|
||||
@@ -206,4 +194,4 @@ public:
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#endif // BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_IMPL_HPP
|
||||
#endif // BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_DISPATCH_HPP
|
||||
+7
-19
@@ -1,5 +1,5 @@
|
||||
#ifndef BOOST_ARCHIVE_DETAIL_POLYMORPHIC_OARCHIVE_IMPL_HPP
|
||||
#define BOOST_ARCHIVE_DETAIL_POLYMORPHIC_OARCHIVE_IMPL_HPP
|
||||
#ifndef BOOST_ARCHIVE_DETAIL_POLYMORPHIC_OARCHIVE_DISPATCH_HPP
|
||||
#define BOOST_ARCHIVE_DETAIL_POLYMORPHIC_OARCHIVE_DISPATCH_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_impl.hpp
|
||||
// polymorphic_oarchive_dispatch.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_impl :
|
||||
class polymorphic_oarchive_dispatch :
|
||||
public polymorphic_oarchive,
|
||||
// note: gcc dynamic cross cast fails if the the derivation below is
|
||||
// not public. I think this is a mistake.
|
||||
@@ -151,20 +151,8 @@ 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 inherited because they appear in mulitple
|
||||
// this can't be inheriteded because they appear in mulitple
|
||||
// parents
|
||||
typedef mpl::bool_<false> is_loading;
|
||||
typedef mpl::bool_<true> is_saving;
|
||||
@@ -180,7 +168,7 @@ public:
|
||||
}
|
||||
// all current archives take a stream as constructor argument
|
||||
template <class _Elem, class _Tr>
|
||||
polymorphic_oarchive_impl(
|
||||
polymorphic_oarchive_dispatch(
|
||||
std::basic_ostream<_Elem, _Tr> & os,
|
||||
unsigned int flags = 0
|
||||
) :
|
||||
@@ -194,4 +182,4 @@ public:
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#endif // BOOST_ARCHIVE_DETAIL_POLYMORPHIC_OARCHIVE_IMPL_HPP
|
||||
#endif // BOOST_ARCHIVE_DETAIL_POLYMORPHIC_OARCHIVE_DISPATCH_HPP
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
// 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);
|
||||
load_binary(ws, l * sizeof(wchar_t) / sizeof(char));
|
||||
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,6 +168,29 @@ 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)
|
||||
@@ -199,11 +222,12 @@ 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); // extra .t is for borland
|
||||
write_attribute(TRACKING(), t.t);
|
||||
}
|
||||
|
||||
template<class Archive>
|
||||
|
||||
@@ -18,23 +18,26 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/archive/binary_iarchive.hpp>
|
||||
#include <boost/archive/detail/polymorphic_iarchive_impl.hpp>
|
||||
#include <boost/archive/detail/polymorphic_iarchive_dispatch.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
typedef detail::polymorphic_iarchive_impl<
|
||||
binary_iarchive_impl<
|
||||
binary_iarchive, std::istream::char_type, std::istream::traits_type
|
||||
>
|
||||
> polymorphic_binary_iarchive;
|
||||
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(){}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
|
||||
boost::archive::polymorphic_binary_iarchive
|
||||
)
|
||||
|
||||
|
||||
@@ -18,23 +18,24 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/archive/binary_oarchive.hpp>
|
||||
#include <boost/archive/detail/polymorphic_oarchive_impl.hpp>
|
||||
#include <boost/archive/detail/polymorphic_oarchive_dispatch.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
typedef detail::polymorphic_oarchive_impl<
|
||||
typedef detail::polymorphic_oarchive_dispatch<
|
||||
binary_oarchive_impl<
|
||||
binary_oarchive, std::ostream::char_type, std::ostream::traits_type
|
||||
naked_binary_oarchive,
|
||||
std::ostream::char_type,
|
||||
std::ostream::traits_type
|
||||
>
|
||||
> polymorphic_binary_oarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
|
||||
boost::archive::polymorphic_binary_oarchive
|
||||
)
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ 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
|
||||
@@ -54,7 +55,9 @@ namespace detail {
|
||||
class basic_iserializer;
|
||||
}
|
||||
|
||||
class polymorphic_iarchive :
|
||||
class polymorphic_iarchive;
|
||||
|
||||
class polymorphic_iarchive_impl :
|
||||
public detail::interface_iarchive<polymorphic_iarchive>
|
||||
{
|
||||
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
@@ -98,21 +101,13 @@ 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, t);
|
||||
archive::load(* this->This(), t);
|
||||
}
|
||||
// special treatment for name-value pairs.
|
||||
template<class T>
|
||||
@@ -124,9 +119,11 @@ public:
|
||||
int
|
||||
){
|
||||
load_start(t.name());
|
||||
archive::load(* this, t.value());
|
||||
archive::load(* this->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;
|
||||
@@ -157,8 +154,24 @@ public:
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::polymorphic_iarchive)
|
||||
// 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)
|
||||
|
||||
#endif // BOOST_ARCHIVE_POLYMORPHIC_IARCHIVE_HPP
|
||||
|
||||
@@ -31,6 +31,7 @@ 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
|
||||
@@ -53,7 +54,9 @@ namespace detail {
|
||||
class basic_oserializer;
|
||||
}
|
||||
|
||||
class polymorphic_oarchive :
|
||||
class polymorphic_oarchive;
|
||||
|
||||
class polymorphic_oarchive_impl :
|
||||
public detail::interface_oarchive<polymorphic_oarchive>
|
||||
{
|
||||
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
@@ -97,14 +100,6 @@ 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;
|
||||
|
||||
@@ -113,7 +108,7 @@ public:
|
||||
template<class T>
|
||||
void save_override(T & t, BOOST_PFTO int)
|
||||
{
|
||||
archive::save(* this, t);
|
||||
archive::save(* this->This(), t);
|
||||
}
|
||||
// special treatment for name-value pairs.
|
||||
template<class T>
|
||||
@@ -124,9 +119,11 @@ public:
|
||||
::boost::serialization::nvp<T> & t, int
|
||||
){
|
||||
save_start(t.name());
|
||||
archive::save(* this, t.const_value());
|
||||
archive::save(* this->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;
|
||||
@@ -143,11 +140,15 @@ public:
|
||||
) = 0;
|
||||
};
|
||||
|
||||
// note: preserve naming symmetry
|
||||
class polymorphic_oarchive :
|
||||
public polymorphic_oarchive_impl
|
||||
{};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::polymorphic_oarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::polymorphic_oarchive)
|
||||
|
||||
#endif // BOOST_ARCHIVE_POLYMORPHIC_OARCHIVE_HPP
|
||||
|
||||
@@ -18,21 +18,26 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/archive/text_iarchive.hpp>
|
||||
#include <boost/archive/detail/polymorphic_iarchive_impl.hpp>
|
||||
#include <boost/archive/detail/polymorphic_iarchive_dispatch.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
typedef detail::polymorphic_iarchive_impl<
|
||||
text_iarchive_impl<text_iarchive>
|
||||
> polymorphic_text_iarchive;
|
||||
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(){}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
|
||||
boost::archive::polymorphic_text_iarchive
|
||||
)
|
||||
|
||||
|
||||
@@ -18,21 +18,20 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/archive/text_oarchive.hpp>
|
||||
#include <boost/archive/detail/polymorphic_oarchive_impl.hpp>
|
||||
#include <boost/archive/detail/polymorphic_oarchive_dispatch.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
typedef detail::polymorphic_oarchive_impl<
|
||||
text_oarchive_impl<text_oarchive>
|
||||
typedef detail::polymorphic_oarchive_dispatch<
|
||||
text_oarchive_impl<naked_text_oarchive>
|
||||
> polymorphic_text_oarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
|
||||
boost::archive::polymorphic_text_oarchive
|
||||
)
|
||||
|
||||
|
||||
@@ -22,21 +22,20 @@
|
||||
#else
|
||||
|
||||
#include <boost/archive/text_wiarchive.hpp>
|
||||
#include <boost/archive/detail/polymorphic_iarchive_impl.hpp>
|
||||
#include <boost/archive/detail/polymorphic_iarchive_dispatch.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
typedef detail::polymorphic_iarchive_impl<
|
||||
text_wiarchive_impl<text_wiarchive>
|
||||
typedef detail::polymorphic_iarchive_dispatch<
|
||||
text_wiarchive_impl<naked_text_wiarchive>
|
||||
> polymorphic_text_wiarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
|
||||
boost::archive::polymorphic_text_wiarchive
|
||||
)
|
||||
|
||||
|
||||
@@ -22,21 +22,20 @@
|
||||
#else
|
||||
|
||||
#include <boost/archive/text_woarchive.hpp>
|
||||
#include <boost/archive/detail/polymorphic_oarchive_impl.hpp>
|
||||
#include <boost/archive/detail/polymorphic_oarchive_dispatch.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
typedef detail::polymorphic_oarchive_impl<
|
||||
text_woarchive_impl<text_woarchive>
|
||||
typedef detail::polymorphic_oarchive_dispatch<
|
||||
text_woarchive_impl<naked_text_woarchive>
|
||||
> polymorphic_text_woarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
|
||||
boost::archive::polymorphic_text_woarchive
|
||||
)
|
||||
|
||||
|
||||
@@ -18,21 +18,26 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/archive/xml_iarchive.hpp>
|
||||
#include <boost/archive/detail/polymorphic_iarchive_impl.hpp>
|
||||
#include <boost/archive/detail/polymorphic_iarchive_dispatch.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
typedef detail::polymorphic_iarchive_impl<
|
||||
xml_iarchive_impl<xml_iarchive>
|
||||
> polymorphic_xml_iarchive;
|
||||
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(){}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
|
||||
boost::archive::polymorphic_xml_iarchive
|
||||
)
|
||||
|
||||
|
||||
@@ -18,21 +18,20 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/archive/xml_oarchive.hpp>
|
||||
#include <boost/archive/detail/polymorphic_oarchive_impl.hpp>
|
||||
#include <boost/archive/detail/polymorphic_oarchive_dispatch.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
typedef detail::polymorphic_oarchive_impl<
|
||||
xml_oarchive_impl<xml_oarchive>
|
||||
typedef detail::polymorphic_oarchive_dispatch<
|
||||
xml_oarchive_impl<naked_xml_oarchive>
|
||||
> polymorphic_xml_oarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
|
||||
boost::archive::polymorphic_xml_oarchive
|
||||
)
|
||||
|
||||
|
||||
@@ -22,21 +22,20 @@
|
||||
#else
|
||||
|
||||
#include <boost/archive/xml_wiarchive.hpp>
|
||||
#include <boost/archive/detail/polymorphic_iarchive_impl.hpp>
|
||||
#include <boost/archive/detail/polymorphic_iarchive_dispatch.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
typedef detail::polymorphic_iarchive_impl<
|
||||
xml_wiarchive_impl<xml_wiarchive>
|
||||
typedef detail::polymorphic_iarchive_dispatch<
|
||||
xml_wiarchive_impl<naked_xml_wiarchive>
|
||||
> polymorphic_xml_wiarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
|
||||
boost::archive::polymorphic_xml_wiarchive
|
||||
)
|
||||
|
||||
|
||||
@@ -22,21 +22,20 @@
|
||||
#else
|
||||
|
||||
#include <boost/archive/xml_woarchive.hpp>
|
||||
#include <boost/archive/detail/polymorphic_oarchive_impl.hpp>
|
||||
#include <boost/archive/detail/polymorphic_oarchive_dispatch.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
typedef detail::polymorphic_oarchive_impl<
|
||||
xml_woarchive_impl<xml_woarchive>
|
||||
typedef detail::polymorphic_oarchive_dispatch<
|
||||
xml_woarchive_impl<naked_xml_woarchive>
|
||||
> polymorphic_xml_woarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(
|
||||
boost::archive::polymorphic_xml_woarchive
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
#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
|
||||
@@ -21,6 +21,7 @@
|
||||
#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
|
||||
|
||||
@@ -73,14 +74,38 @@ protected:
|
||||
~text_iarchive_impl(){};
|
||||
};
|
||||
|
||||
// do not derive from this class. If you want to extend this functionality
|
||||
// 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.
|
||||
class text_iarchive :
|
||||
public text_iarchive_impl<text_iarchive>
|
||||
|
||||
// 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(std::istream & is, unsigned int flags = 0) :
|
||||
text_iarchive_impl<text_iarchive>(is, flags)
|
||||
{}
|
||||
@@ -90,9 +115,8 @@ public:
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::text_iarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_iarchive)
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
|
||||
@@ -88,12 +88,13 @@ public:
|
||||
~text_oarchive(){}
|
||||
};
|
||||
|
||||
typedef text_oarchive naked_text_oarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::text_oarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_oarchive)
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
|
||||
@@ -72,11 +72,36 @@ protected:
|
||||
~text_wiarchive_impl(){};
|
||||
};
|
||||
|
||||
// do not derive from this class. If you want to extend this functionality
|
||||
// via inhertance, derived from text_wiarchive_impl instead. This will
|
||||
// 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 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 text_wiarchive_impl<text_wiarchive>,
|
||||
public detail::shared_ptr_helper
|
||||
{
|
||||
public:
|
||||
text_wiarchive(std::wistream & is, unsigned int flags = 0) :
|
||||
@@ -88,9 +113,8 @@ public:
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::text_wiarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_wiarchive)
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
|
||||
@@ -114,12 +114,13 @@ public:
|
||||
~text_woarchive(){}
|
||||
};
|
||||
|
||||
typedef text_woarchive naked_text_woarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::text_woarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_woarchive)
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
|
||||
@@ -83,14 +83,36 @@ protected:
|
||||
~xml_iarchive_impl();
|
||||
};
|
||||
|
||||
// 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
|
||||
// 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 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 xml_iarchive_impl<xml_iarchive>,
|
||||
public detail::shared_ptr_helper
|
||||
{
|
||||
public:
|
||||
xml_iarchive(std::istream & is, unsigned int flags = 0) :
|
||||
@@ -102,9 +124,8 @@ public:
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::xml_iarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_iarchive)
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
|
||||
@@ -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,12 +101,13 @@ public:
|
||||
~xml_oarchive(){}
|
||||
};
|
||||
|
||||
typedef xml_oarchive naked_xml_oarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::xml_oarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_oarchive)
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
|
||||
@@ -87,14 +87,36 @@ protected:
|
||||
~xml_wiarchive_impl();
|
||||
};
|
||||
|
||||
// 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
|
||||
// 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 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 xml_wiarchive_impl<xml_wiarchive>,
|
||||
public detail::shared_ptr_helper
|
||||
{
|
||||
public:
|
||||
xml_wiarchive(std::wistream & is, unsigned int flags = 0) :
|
||||
@@ -106,9 +128,8 @@ public:
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::xml_wiarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_wiarchive)
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
|
||||
@@ -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,12 +113,13 @@ public:
|
||||
~xml_woarchive(){}
|
||||
};
|
||||
|
||||
typedef xml_woarchive naked_xml_woarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::xml_woarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_woarchive)
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
#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
|
||||
@@ -37,114 +37,45 @@
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
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)
|
||||
);
|
||||
}
|
||||
};
|
||||
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; }
|
||||
|
||||
// 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;
|
||||
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());
|
||||
}
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
// 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
|
||||
|
||||
// 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))
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560))
|
||||
template<class Base, class Derived>
|
||||
const Base &
|
||||
base_object(const Derived & d)
|
||||
|
||||
@@ -31,6 +31,7 @@ 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 {
|
||||
@@ -68,6 +69,15 @@ 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
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#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,6 +31,7 @@
|
||||
#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 {
|
||||
@@ -101,7 +102,7 @@ template<class Container>
|
||||
class reserve_imp
|
||||
{
|
||||
public:
|
||||
void operator()(Container &s, unsigned int count) const {
|
||||
void operator()(Container &s, std::size_t count) const {
|
||||
s.reserve(count);
|
||||
}
|
||||
};
|
||||
@@ -110,7 +111,7 @@ template<class Container>
|
||||
class no_reserve_imp
|
||||
{
|
||||
public:
|
||||
void operator()(Container & /* s */, unsigned int /* count */) const{}
|
||||
void operator()(Container & /* s */, std::size_t /* count */) const{}
|
||||
};
|
||||
|
||||
template<class Archive, class Container, class InputFunction, class R>
|
||||
@@ -118,16 +119,18 @@ inline void load_collection(Archive & ar, Container &s)
|
||||
{
|
||||
s.clear();
|
||||
// retrieve number of elements
|
||||
unsigned int count;
|
||||
unsigned int item_version(0);
|
||||
collection_size_type count;
|
||||
unsigned int item_version;
|
||||
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(count-- > 0){
|
||||
while(c-- > 0){
|
||||
ifunc(ar, s, item_version);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#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 {
|
||||
@@ -35,7 +36,7 @@ template<class Archive, class Container>
|
||||
inline void save_collection(Archive & ar, const Container &s)
|
||||
{
|
||||
// record number of elements
|
||||
unsigned int count = s.size();
|
||||
collection_size_type const count(s.size());
|
||||
ar << BOOST_SERIALIZATION_NVP(count);
|
||||
// make sure the target type is registered so we can retrieve
|
||||
// the version when we load
|
||||
@@ -46,7 +47,8 @@ inline void save_collection(Archive & ar, const Container &s)
|
||||
ar << BOOST_SERIALIZATION_NVP(item_version);
|
||||
}
|
||||
BOOST_DEDUCED_TYPENAME Container::const_iterator it = s.begin();
|
||||
while(count-- > 0){
|
||||
std::size_t c=count;
|
||||
while(c-- > 0){
|
||||
// note borland emits a no-op without the explicit namespace
|
||||
boost::serialization::save_construct_data_adl(
|
||||
ar,
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
// (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
|
||||
@@ -0,0 +1,79 @@
|
||||
#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
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
// 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.
|
||||
@@ -23,226 +24,165 @@
|
||||
#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/known_archive_types.hpp>
|
||||
#include <boost/serialization/force_include.hpp>
|
||||
#include <boost/archive/detail/dynamically_initialized.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>
|
||||
BOOST_DLLEXPORT const basic_pointer_oserializer &
|
||||
instantiate_pointer_oserializer(Archive * ar, T *) BOOST_USED;
|
||||
class pointer_iserializer;
|
||||
template<class Archive, class T>
|
||||
class pointer_oserializer;
|
||||
|
||||
namespace export_impl
|
||||
template <class Archive, class Serializable>
|
||||
struct export_impl
|
||||
{
|
||||
struct nothing{
|
||||
static void instantiate(){}
|
||||
};
|
||||
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
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 basic_pointer_iserializer &
|
||||
enable_load(mpl::true_){
|
||||
return pointer_iserializer<Archive, Serializable>::get_instance();
|
||||
}
|
||||
static const export_generator instance;
|
||||
|
||||
static const basic_pointer_oserializer &
|
||||
enable_save(mpl::true_){
|
||||
return pointer_oserializer<Archive, Serializable>::get_instance();
|
||||
}
|
||||
|
||||
inline static void enable_load(mpl::false_) {}
|
||||
inline static void enable_save(mpl::false_) {}
|
||||
};
|
||||
|
||||
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 BOOST_DEDUCED_TYPENAME boost::serialization::type_info_implementation<T>::type eti_type;
|
||||
static void export_register(const char *key){
|
||||
struct guid_initializer
|
||||
{
|
||||
typedef 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 instance;
|
||||
guid_initializer(const char *key = 0) BOOST_USED ;
|
||||
|
||||
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 ;
|
||||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
guid_initializer<T>::guid_initializer(const char *key){
|
||||
BOOST_DLLEXPORT 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);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
const guid_initializer<T> guid_initializer<T>::instance;
|
||||
// On many platforms, naming a specialization of this template is
|
||||
// enough to cause its argument to be instantiated.
|
||||
template <void(*)()>
|
||||
struct instantiate_function {};
|
||||
|
||||
// only gcc seems to be able to explicitly instantiate a static instance.
|
||||
// but all can instantiate a function that refers to a static 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;
|
||||
|
||||
// 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;
|
||||
}
|
||||
};
|
||||
# endif
|
||||
};
|
||||
|
||||
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
|
||||
);
|
||||
}
|
||||
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>
|
||||
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();
|
||||
export_impl<Archive,Serializable>::enable_load(
|
||||
mpl::and_<concrete, BOOST_DEDUCED_TYPENAME Archive::is_loading>());
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
#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 &); \
|
||||
} } } \
|
||||
/**/
|
||||
#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); \
|
||||
}
|
||||
|
||||
#endif
|
||||
// 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
|
||||
|
||||
// check for unnecessary export. T isn't polymorphic so there is no
|
||||
// need to export it.
|
||||
@@ -253,28 +193,15 @@ export_archives_invoke(T &, ASeq &){
|
||||
); \
|
||||
/**/
|
||||
|
||||
// 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_ARCHIVE_LIST( \
|
||||
T, \
|
||||
BOOST_PP_STRINGIZE(T), \
|
||||
boost::archive::detail::known_archive_types::type \
|
||||
) \
|
||||
#define BOOST_CLASS_EXPORT(T) \
|
||||
BOOST_CLASS_EXPORT_GUID( \
|
||||
T, \
|
||||
BOOST_PP_STRINGIZE(T) \
|
||||
) \
|
||||
/**/
|
||||
|
||||
#endif // BOOST_SERIALIZATION_EXPORT_HPP
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
# endif
|
||||
#elif ! defined(_WIN32) && ! defined(_WIN64)
|
||||
# if defined(__MWERKS__)
|
||||
# // define BOOST_USED __attribute__ ((used))
|
||||
# define BOOST_DLLEXPORT __declspec(dllexport)
|
||||
# elif defined(__GNUC__) && (__GNUC__ >= 3)
|
||||
# define BOOST_USED __attribute__ ((used))
|
||||
# elif defined(__INTEL_COMPILER) && (BOOST_INTEL_CXX_VERSION >= 800)
|
||||
|
||||
@@ -23,16 +23,13 @@
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
template<class T>
|
||||
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
|
||||
};
|
||||
struct is_abstract
|
||||
#ifdef BOOST_NO_IS_ABSTRACT
|
||||
: mpl::false_
|
||||
#else
|
||||
: boost::is_abstract<T>
|
||||
#endif
|
||||
{};
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
@@ -41,12 +38,8 @@ namespace serialization {
|
||||
namespace boost { \
|
||||
namespace serialization { \
|
||||
template<> \
|
||||
struct is_abstract< T > { \
|
||||
typedef mpl::bool_<true> type; \
|
||||
BOOST_STATIC_CONSTANT(bool, value = true); \
|
||||
}; \
|
||||
} \
|
||||
} \
|
||||
struct is_abstract< T > : mpl::true_ {}; \
|
||||
}} \
|
||||
/**/
|
||||
|
||||
#endif //BOOST_SERIALIZATION_IS_ABSTRACT_CLASS_HPP
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#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 {
|
||||
@@ -40,7 +41,7 @@ namespace serialization {
|
||||
template<class T>
|
||||
struct nvp :
|
||||
public std::pair<const char *, T *>,
|
||||
public traits<nvp<T>, object_serializable, track_never>
|
||||
public wrapper_traits<nvp<T> >
|
||||
{
|
||||
explicit nvp(const char * name, T & t) :
|
||||
// note: redundant cast works around borland issue
|
||||
|
||||
@@ -24,18 +24,11 @@
|
||||
|
||||
#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
|
||||
@@ -48,31 +41,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)
|
||||
@@ -93,85 +86,6 @@
|
||||
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
|
||||
|
||||
@@ -202,14 +116,17 @@ 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::checked_deleter<T> > *
|
||||
boost_132::detail::sp_counted_base_impl<T *, boost::archive::detail::null_deleter > *
|
||||
>(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
|
||||
get_helper<Archive, boost_132::serialization::detail::shared_ptr_helper>(ar).append(sp);
|
||||
ar.append(sp);
|
||||
r = sp.get();
|
||||
}
|
||||
else
|
||||
@@ -217,7 +134,7 @@ inline void load(
|
||||
{
|
||||
ar >> boost::serialization::make_nvp("px", r);
|
||||
}
|
||||
get_helper<Archive, detail::shared_ptr_helper >(ar).reset(t,r);
|
||||
ar.reset(t,r);
|
||||
}
|
||||
|
||||
template<class Archive, class T>
|
||||
|
||||
@@ -47,25 +47,6 @@ 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
|
||||
@@ -111,7 +92,8 @@ 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
|
||||
@@ -227,7 +209,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(T, K) \
|
||||
BOOST_CLASS_EXPORT_GUID_1(T, K) \
|
||||
/**/
|
||||
|
||||
#define BOOST_SHARED_POINTER_EXPORT(T) \
|
||||
|
||||
@@ -49,9 +49,9 @@ inline void load(
|
||||
// retrieve number of elements
|
||||
t.clear();
|
||||
// retrieve number of elements
|
||||
unsigned int count;
|
||||
collection_size_type count;
|
||||
ar >> BOOST_SERIALIZATION_NVP(count);
|
||||
if(0 == count)
|
||||
if(std::size_t(0) == count)
|
||||
return;
|
||||
unsigned int v;
|
||||
if(3 < ar.get_library_version()){
|
||||
@@ -62,7 +62,8 @@ inline void load(
|
||||
t.push_front(u.reference());
|
||||
BOOST_DEDUCED_TYPENAME BOOST_STD_EXTENSION_NAMESPACE::slist<U, Allocator>::iterator last;
|
||||
last = t.begin();
|
||||
while(--count > 0){
|
||||
std::size_t c = count;
|
||||
while(--c > 0){
|
||||
boost::serialization::detail::stack_construct<Archive, U>
|
||||
u(ar, file_version);
|
||||
ar >> boost::serialization::make_nvp("item", u.reference());
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#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 {
|
||||
@@ -65,7 +64,7 @@ struct tracking_level {
|
||||
// is never
|
||||
mpl::int_<track_never>,
|
||||
// otherwise its selective
|
||||
mpl::int_<track_selectivly>
|
||||
mpl::int_<track_selectively>
|
||||
> > >::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_selectivly = 1,
|
||||
track_selectively = 1,
|
||||
// always track this type
|
||||
track_always = 2
|
||||
};
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#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>
|
||||
|
||||
@@ -45,7 +46,8 @@ template<
|
||||
int Level,
|
||||
int Tracking,
|
||||
unsigned int Version = 0,
|
||||
class ETII = extended_type_info_impl< T >
|
||||
class ETII = extended_type_info_impl< T >,
|
||||
class Wrapper = mpl::false_
|
||||
>
|
||||
struct traits : public basic_traits {
|
||||
BOOST_STATIC_ASSERT(Version == 0 || Level >= object_class_info);
|
||||
@@ -54,6 +56,7 @@ 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
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
#ifndef BOOST_SERIALIZATION_VALARAY_HPP
|
||||
#define BOOST_SERIALIZATION_VALARAY_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
|
||||
// vector.hpp: serialization for stl vector templates
|
||||
|
||||
// (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.
|
||||
|
||||
#include <valarray>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
#include <boost/serialization/detail/get_data.hpp>
|
||||
|
||||
// function specializations must be defined in the appropriate
|
||||
// namespace - boost::serialization
|
||||
#if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
|
||||
#define STD _STLP_STD
|
||||
#else
|
||||
#define STD std
|
||||
#endif
|
||||
|
||||
namespace boost { namespace serialization {
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// valarray<T>
|
||||
|
||||
template<class Archive, class U>
|
||||
void save( Archive & ar, const STD::valarray<U> &t, const unsigned int file_version )
|
||||
{
|
||||
const collection_size_type count(t.size());
|
||||
ar << BOOST_SERIALIZATION_NVP(count);
|
||||
if (count)
|
||||
ar << make_array(detail::get_data(t), t.size());
|
||||
}
|
||||
|
||||
|
||||
template<class Archive, class U>
|
||||
void load( Archive & ar, STD::valarray<U> &t, const unsigned int file_version )
|
||||
{
|
||||
collection_size_type count;
|
||||
ar >> BOOST_SERIALIZATION_NVP(count);
|
||||
t.resize(count);
|
||||
if (count)
|
||||
ar >> make_array(detail::get_data(t), t.size());
|
||||
}
|
||||
|
||||
// split non-intrusive serialization function member into separate
|
||||
// non intrusive save/load member functions
|
||||
template<class Archive, class U>
|
||||
inline void serialize( Archive & ar, STD::valarray<U> & t, const unsigned int file_version)
|
||||
{
|
||||
boost::serialization::split_free(ar, t, file_version);
|
||||
}
|
||||
|
||||
} } // end namespace boost::serialization
|
||||
|
||||
#include <boost/serialization/collection_traits.hpp>
|
||||
|
||||
BOOST_SERIALIZATION_COLLECTION_TRAITS(STD::valarray)
|
||||
#undef STD
|
||||
|
||||
#endif // BOOST_SERIALIZATION_VALARAY_HPP
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user