|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57498 - in sandbox/statistics/detail/fusion: boost/statistics/detail/fusion/map/serialization libs/statistics/detail/fusion/example libs/statistics/detail/fusion/src
From: erwann.rogard_at_[hidden]
Date: 2009-11-08 19:43:04
Author: e_r
Date: 2009-11-08 19:43:03 EST (Sun, 08 Nov 2009)
New Revision: 57498
URL: http://svn.boost.org/trac/boost/changeset/57498
Log:
m/a
Added:
sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/map/serialization/
sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/map/serialization/include.hpp (contents, props changed)
sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/map/serialization/loader.hpp (contents, props changed)
sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/map/serialization/saver.hpp (contents, props changed)
sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/example/serialize.cpp (contents, props changed)
sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/example/serialize.h (contents, props changed)
Text files modified:
sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/src/main.cpp | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
Added: sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/map/serialization/include.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/map/serialization/include.hpp 2009-11-08 19:43:03 EST (Sun, 08 Nov 2009)
@@ -0,0 +1,15 @@
+//////////////////////////////////////////////////////////////////////////////
+// detail::fusion::map::serialization::include.hpp //
+// //
+// (C) Copyright 2009 Erwann Rogard //
+// 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) //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_STATISTICS_DETAIL_FUSION_MAP_SERIALIZATION_INCLUDE_HPP_ER_2009
+#define BOOST_STATISTICS_DETAIL_FUSION_MAP_SERIALIZATION_INCLUDE_HPP_ER_2009
+
+#include <boost/statistics/detail/fusion/map/serialization/loader.hpp>
+#include <boost/statistics/detail/fusion/map/serialization/saver.hpp>
+
+#endif
\ No newline at end of file
Added: sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/map/serialization/loader.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/map/serialization/loader.hpp 2009-11-08 19:43:03 EST (Sun, 08 Nov 2009)
@@ -0,0 +1,56 @@
+//////////////////////////////////////////////////////////////////////////////
+// detail::fusion::map::serialization::loader.hpp //
+// //
+// (C) Copyright 2009 Erwann Rogard //
+// 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) //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_STATISTICS_DETAIL_FUSION_MAP_SERIALIZATION_LOADER_HPP_ER_2009
+#define BOOST_STATISTICS_DETAIL_FUSION_MAP_SERIALIZATION_LOADER_HPP_ER_2009
+#include <boost/fusion/support/pair.hpp>
+#include <boost/fusion/include/pair.hpp>
+#include <boost/fusion/algorithm/iteration/for_each.hpp>
+#include <boost/fusion/include/for_each.hpp>
+
+namespace boost{
+namespace statistics{
+namespace detail{
+namespace fusion{
+namespace map{
+
+// Implementation is suggested here
+// http://www.boost.org/doc/libs/1_40_0/libs/fusion/doc/html/fusion/quick_start.html
+// under AssociativeContainer
+template<typename Ia>
+struct loader
+{
+
+ loader(Ia& ar):ar_(ar){}
+ loader(const loader& that):ar_(that.ar_){}
+
+ template <typename Pair>
+ void operator()(Pair& data) const
+ {
+ (this->ar_ >> data.second);
+ }
+
+ private:
+ Ia& ar_;
+};
+
+template <typename Stuff,typename Ia>
+void load(Stuff & stuff, Ia& ar)
+{
+ typedef loader<Ia> loader_;
+ boost::fusion::for_each(stuff, loader_(ar));
+}
+
+
+}// map
+}// fusion
+}// detail
+}// statistics
+}// boost
+
+#endif
\ No newline at end of file
Added: sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/map/serialization/saver.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/map/serialization/saver.hpp 2009-11-08 19:43:03 EST (Sun, 08 Nov 2009)
@@ -0,0 +1,56 @@
+//////////////////////////////////////////////////////////////////////////////
+// detail::fusion::map::serialization::saver.hpp //
+// //
+// (C) Copyright 2009 Erwann Rogard //
+// 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) //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_STATISTICS_DETAIL_FUSION_MAP_SERIALIZATION_SAVER_HPP_ER_2009
+#define BOOST_STATISTICS_DETAIL_FUSION_MAP_SERIALIZATION_SAVER_HPP_ER_2009
+#include <boost/fusion/support/pair.hpp>
+#include <boost/fusion/include/pair.hpp>
+#include <boost/fusion/algorithm/iteration/for_each.hpp>
+#include <boost/fusion/include/for_each.hpp>
+
+namespace boost{
+namespace statistics{
+namespace detail{
+namespace fusion{
+namespace map{
+
+// Implementation is suggested here
+// http://www.boost.org/doc/libs/1_40_0/libs/fusion/doc/html/fusion/quick_start.html
+// under AssociativeContainer
+template<typename Oa>
+struct saver
+{
+
+ saver(Oa& ar):ar_(ar){}
+ saver(const saver& that):ar_(that.ar_){}
+
+ template <typename Pair>
+ void operator()(Pair const& data) const
+ {
+ this->ar_ << data.second;
+ }
+
+ private:
+ Oa& ar_;
+};
+
+template <typename Stuff,typename Oa>
+void save(Stuff const& stuff,Oa& ar)
+{
+ typedef saver<Oa> saver_;
+ boost::fusion::for_each(stuff, saver_(ar));
+}
+
+
+}// map
+}// fusion
+}// detail
+}// statistics
+}// boost
+
+#endif
\ No newline at end of file
Added: sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/example/serialize.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/example/serialize.cpp 2009-11-08 19:43:03 EST (Sun, 08 Nov 2009)
@@ -0,0 +1,69 @@
+///////////////////////////////////////////////////////////////////////////////
+// statistics::detail::fusion::example::serialize.cpp //
+// //
+// Copyright 2009 Erwann Rogard. 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) //
+///////////////////////////////////////////////////////////////////////////////
+#include <vector>
+#include <fstream>
+#include <string>
+#include <boost/mpl/int.hpp>
+#include <boost/utility/result_of.hpp>
+#include <boost/assert.hpp>
+#include <boost/range.hpp>
+#include <boost/archive/text_oarchive.hpp>
+#include <boost/archive/text_iarchive.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/fusion/include/at_key.hpp>
+#include <boost/fusion/container/map.hpp>
+#include <boost/fusion/include/map.hpp>
+#include <boost/fusion/include/map_fwd.hpp>
+#include <boost/fusion/include/make_map.hpp>
+
+#include <boost/statistics/detail/fusion/map/serialization/include.hpp>
+#include <libs/statistics/detail/fusion/example/serialize.h>
+
+void example_serialize(std::ostream& os){
+
+ os << "example_serialize -> ";
+
+ using namespace boost;
+ namespace stat = boost::statistics::detail;
+ namespace sf = stat::fusion;
+
+ typedef mpl::int_<0> k_0_;
+ typedef mpl::int_<1> k_1_;
+ typedef int d_0_;
+ typedef int d_1_;
+ typedef fusion::pair<k_0_,d_0_> p_0_;
+ typedef fusion::pair<k_1_,d_1_> p_1_;
+ typedef fusion::map<p_0_,p_1_> map_;
+ 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 d_0_ d_0 = 0;
+ const d_1_ d_1 = 1;
+
+ map_ map = boost::fusion::make_map<k_0_,k_1_>(d_0,d_1);
+ {
+ ofs_ ofs(path.c_str());
+ oa_ oa(ofs);
+ sf::map::save(map,oa);
+ }
+ {
+ map_ map;
+ ifs_ ifs(path.c_str());
+ ia_ ia(ifs);
+ sf::map::load(map,ia);
+ BOOST_ASSERT(boost::fusion::at_key<k_0_>(map) == d_0);
+ BOOST_ASSERT(boost::fusion::at_key<k_1_>(map) == d_1);
+ }
+
+ os << "<-" << std::endl;
+
+}
Added: sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/example/serialize.h
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/example/serialize.h 2009-11-08 19:43:03 EST (Sun, 08 Nov 2009)
@@ -0,0 +1,14 @@
+///////////////////////////////////////////////////////////////////////////////
+// statistics::detail::fusion::example::serialize.h //
+// //
+// Copyright 2009 Erwann Rogard. 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 LIBS_STATISTICS_DETAIL_FUSION_EXAMPLE_SERIALIZE_HPP_ER_2009
+#define LIBS_STATISTICS_DETAIL_FUSION_EXAMPLE_SERIALIZE_HPP_ER_2009
+#include <iostream>
+
+void example_serialize(std::ostream&);
+
+#endif
\ No newline at end of file
Modified: sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/src/main.cpp
==============================================================================
--- sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/src/main.cpp (original)
+++ sandbox/statistics/detail/fusion/libs/statistics/detail/fusion/src/main.cpp 2009-11-08 19:43:03 EST (Sun, 08 Nov 2009)
@@ -7,11 +7,12 @@
///////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <libs/statistics/detail/fusion/example/at_key.h>
-#include <boost/statistics/detail/fusion/joint_view/bind.hpp>
+#include <libs/statistics/detail/fusion/example/serialize.h>
int main(){
example_at_key_iterator(std::cout);
+ example_serialize(std::cout);
return 0;
}
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