|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57712 - in sandbox/statistics/detail/fusion: boost/statistics/detail/fusion/serialization libs/statistics/detail/fusion/example
From: erwann.rogard_at_[hidden]
Date: 2009-11-16 16:32:42
Author: e_r
Date: 2009-11-16 16:32:41 EST (Mon, 16 Nov 2009)
New Revision: 57712
URL: http://svn.boost.org/trac/boost/changeset/57712
Log:
m
Text files modified:
sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/serialization/include.hpp | 4 ++--
sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/serialization/loader.hpp | 15 ++++++++-------
sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/serialization/saver.hpp | 14 ++++++++------
sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/example/serialize.cpp | 22 ++++++++++++++--------
4 files changed, 32 insertions(+), 23 deletions(-)
Modified: sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/serialization/include.hpp
==============================================================================
--- sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/serialization/include.hpp (original)
+++ sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/serialization/include.hpp 2009-11-16 16:32:41 EST (Mon, 16 Nov 2009)
@@ -9,7 +9,7 @@
#ifndef BOOST_STATISTICS_DETAIL_FUSION_SERIALIZATION_INCLUDE_HPP_ER_2009
#define BOOST_STATISTICS_DETAIL_FUSION_SERIALIZATION_INCLUDE_HPP_ER_2009
-#include <boost/statistics/detail/fusion/serialization/saver.hpp>
-#include <boost/statistics/detail/fusion/serialization/loader.hpp>
+#include <boost/statistics/detail/fusion/serialization/map.hpp>
+#include <boost/statistics/detail/fusion/serialization/vector.hpp>
#endif
\ No newline at end of file
Modified: sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/serialization/loader.hpp
==============================================================================
--- sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/serialization/loader.hpp (original)
+++ sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/serialization/loader.hpp 2009-11-16 16:32:41 EST (Mon, 16 Nov 2009)
@@ -34,11 +34,11 @@
// TODO overload with any other non sequence fusion data structure
- template <typename F,typename S>
- void operator()(boost::fusion::pair<F,S> & data) const
- {
- (*this)(data.second);
- }
+ //template <typename F,typename S>
+ //void operator()(boost::fusion::pair<F,S> & data) const
+ //{
+ // (*this)(data.second);
+ //}
template <typename S>
typename boost::enable_if<
@@ -60,8 +60,9 @@
>::type
operator()(T& serializable_item) const
{
- // TODO assert serialazable concept
-
+ // Note : tag_of< fusion::pair<F,S> > == non_fusion_tag
+ // and operator>>(IStream& is, pair<First, Second>& p) is defined in
+ // fusion
(this->ar_ >> serializable_item);
}
Modified: sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/serialization/saver.hpp
==============================================================================
--- sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/serialization/saver.hpp (original)
+++ sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/serialization/saver.hpp 2009-11-16 16:32:41 EST (Mon, 16 Nov 2009)
@@ -34,11 +34,11 @@
// TODO overload with any other non sequence fusion data structure
- template <typename F,typename S>
- void operator()(const boost::fusion::pair<F,S>& data)const
- {
- (*this)(data.second);
- }
+ // template <typename F,typename S>
+ // void operator()(const boost::fusion::pair<F,S>& data)const
+ // {
+ // (*this)(data.second);
+ // }
template <typename S>
typename boost::enable_if<
@@ -60,7 +60,9 @@
>::type
operator()(const T& serializable_item)const
{
- // TODO assert serialazable concept
+ // Note : tag_of< fusion::pair<F,S> > == non_fusion_tag
+ // and operator<<(OStream& is, pair<First, Second>& p) is defined in
+ // fusion
this->ar_ << serializable_item;
}
Modified: sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/example/serialize.cpp
==============================================================================
--- sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/example/serialize.cpp (original)
+++ sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/example/serialize.cpp 2009-11-16 16:32:41 EST (Mon, 16 Nov 2009)
@@ -8,6 +8,7 @@
#include <vector>
#include <fstream>
#include <string>
+#include <boost/mpl/assert.hpp>
#include <boost/mpl/int.hpp>
#include <boost/utility/result_of.hpp>
#include <boost/assert.hpp>
@@ -22,6 +23,10 @@
#include <boost/fusion/include/make_vector.hpp>
#include <boost/statistics/detail/fusion/serialization/include.hpp>
+//#include <boost/statistics/detail/fusion/serialization/save.hpp>
+//#include <boost/statistics/detail/fusion/serialization/load.hpp>
+//#include <boost/statistics/detail/fusion/serialization/map.hpp>
+//#include <boost/statistics/detail/fusion/serialization/vector.hpp>
#include <libs/statistics/detail/fusion/example/serialize.h>
@@ -39,20 +44,21 @@
typedef int d0_;
typedef int d1_;
typedef int d2_;
+ typedef boost::fusion::pair<k0_,d0_> pair_;
typedef boost::fusion::result_of::make_map<k0_,k1_,d0_,d1_>::type map01_;
typedef boost::fusion::result_of::make_map<k2_,d2_>::type map2_;
- typedef boost::fusion::result_of::make_vector<map01_,map2_>::type vec_map01_map2_;
+ typedef boost::fusion::vector2<map01_,map2_> vec_map01_map2_;
typedef boost::archive::text_iarchive ia_;
typedef boost::archive::text_oarchive oa_;
typedef std::ifstream ifs_;
typedef std::ofstream ofs_;
typedef std::string str_;
- const str_ path = "./serialize";
- const d0_ d0 = 0;
+ const str_ path = "./fusion_serialization";
+ const d0_ d0 = 2;
const d1_ d1 = 1;
- const d2_ d2 = 2;
-
+ const d2_ d2 = 0;
+
map01_ map01(
boost::fusion::make_pair<k0_>(d0),
boost::fusion::make_pair<k1_>(d1)
@@ -64,14 +70,14 @@
{
ofs_ ofs(path.c_str());
oa_ oa(ofs);
- sf::serialization::make_saver(oa)(vec_map01_map2);
+ oa << vec_map01_map2;
}
{
vec_map01_map2_ vec;
ifs_ ifs(path.c_str());
ia_ ia(ifs);
- sf::serialization::make_loader(ia)(vec);
+ ia >> vec;
BOOST_ASSERT(
boost::fusion::at_key<k0_>(
boost::fusion::at_c<0>(vec)
@@ -89,6 +95,6 @@
);
}
- os << "<-" << std::endl;
+ os << "<-" << std::endl;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk