|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57687 - in sandbox/statistics/detail/multi_array: . boost boost/statistics boost/statistics/detail boost/statistics/detail/multi_array boost/statistics/detail/multi_array/serialization libs libs/statistics libs/statistics/detail libs/statistics/detail/multi_array libs/statistics/detail/multi_array/example libs/statistics/detail/multi_array/src
From: erwann.rogard_at_[hidden]
Date: 2009-11-15 12:53:33
Author: e_r
Date: 2009-11-15 12:53:32 EST (Sun, 15 Nov 2009)
New Revision: 57687
URL: http://svn.boost.org/trac/boost/changeset/57687
Log:
a
Added:
sandbox/statistics/detail/multi_array/
sandbox/statistics/detail/multi_array/boost/
sandbox/statistics/detail/multi_array/boost/statistics/
sandbox/statistics/detail/multi_array/boost/statistics/detail/
sandbox/statistics/detail/multi_array/boost/statistics/detail/multi_array/
sandbox/statistics/detail/multi_array/boost/statistics/detail/multi_array/serialization/
sandbox/statistics/detail/multi_array/boost/statistics/detail/multi_array/serialization/load.hpp (contents, props changed)
sandbox/statistics/detail/multi_array/boost/statistics/detail/multi_array/serialization/save.hpp (contents, props changed)
sandbox/statistics/detail/multi_array/boost/statistics/detail/multi_array/serialization/serialize.hpp (contents, props changed)
sandbox/statistics/detail/multi_array/libs/
sandbox/statistics/detail/multi_array/libs/statistics/
sandbox/statistics/detail/multi_array/libs/statistics/detail/
sandbox/statistics/detail/multi_array/libs/statistics/detail/multi_array/
sandbox/statistics/detail/multi_array/libs/statistics/detail/multi_array/example/
sandbox/statistics/detail/multi_array/libs/statistics/detail/multi_array/example/serialize.cpp (contents, props changed)
sandbox/statistics/detail/multi_array/libs/statistics/detail/multi_array/example/serialize.h (contents, props changed)
sandbox/statistics/detail/multi_array/libs/statistics/detail/multi_array/src/
sandbox/statistics/detail/multi_array/libs/statistics/detail/multi_array/src/main.cpp (contents, props changed)
Added: sandbox/statistics/detail/multi_array/boost/statistics/detail/multi_array/serialization/load.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/multi_array/boost/statistics/detail/multi_array/serialization/load.hpp 2009-11-15 12:53:32 EST (Sun, 15 Nov 2009)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////////
+// detail::multi_array::serialization::load.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_MULTI_ARRAY_SERIALIZATION_LOAD_HPP_ER_2009
+#define BOOST_STATISTICS_DETAIL_MULTI_ARRAY_SERIALIZATION_LOAD_HPP_ER_2009
+#include <boost/multi_array.hpp>
+#include <boost/serialization/array.hpp>
+#include <boost/serialization/nvp.hpp>
+//#include <boost/archive/text_iarchive.hpp>
+
+namespace boost{ namespace serialization{
+
+ template<typename T,class Archive>
+ inline void load(
+ Archive & ar,
+ boost::multi_array<T,2> & t,
+ const unsigned int file_version
+ )
+ {
+ typedef boost::multi_array<T,2> multi_array_;
+ typedef typename multi_array_::size_type size_;
+
+ size_ n0;
+ ar >> BOOST_SERIALIZATION_NVP(n0);
+ size_ n1;
+ ar >> BOOST_SERIALIZATION_NVP(n1);
+
+ t.resize(boost::extents[n0][n1]);
+ ar >> make_array(t.data(), t.num_elements());
+ }
+}}
+
+#endif
\ No newline at end of file
Added: sandbox/statistics/detail/multi_array/boost/statistics/detail/multi_array/serialization/save.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/multi_array/boost/statistics/detail/multi_array/serialization/save.hpp 2009-11-15 12:53:32 EST (Sun, 15 Nov 2009)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////////
+// detail::multi_array::serialization::save.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_MULTI_ARRAY_SERIALIZATION_SAVE_HPP_ER_2009
+#define BOOST_STATISTICS_DETAIL_MULTI_ARRAY_SERIALIZATION_SAVE_HPP_ER_2009
+#include <boost/multi_array.hpp>
+#include <boost/serialization/array.hpp>
+#include <boost/serialization/nvp.hpp>
+//#include <boost/archive/text_oarchive.hpp>
+
+namespace boost{ namespace serialization{
+
+ template<typename T,typename Archive>
+ inline void save(
+ Archive & ar,
+ const boost::multi_array<T,2> & t,
+ const unsigned int file_version
+ )
+ {
+ typedef boost::multi_array<T,2> multi_array_;
+ typedef typename multi_array_::size_type size_;
+
+ size_ n0 = (t.shape()[0]);
+ ar << BOOST_SERIALIZATION_NVP(n0);
+ size_ n1 = (t.shape()[1]);
+ ar << BOOST_SERIALIZATION_NVP(n1);
+ ar << boost::serialization::make_array(t.data(), t.num_elements());
+ }
+
+}
+}
+
+#endif
\ No newline at end of file
Added: sandbox/statistics/detail/multi_array/boost/statistics/detail/multi_array/serialization/serialize.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/multi_array/boost/statistics/detail/multi_array/serialization/serialize.hpp 2009-11-15 12:53:32 EST (Sun, 15 Nov 2009)
@@ -0,0 +1,29 @@
+//////////////////////////////////////////////////////////////////////////////
+// detail::multi_array::serialization::serialize.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_MULTI_ARRAY_SERIALIZATION_SERIALIZE_HPP_ER_2009
+#define BOOST_STATISTICS_DETAIL_MULTI_ARRAY_SERIALIZATION_SERIALIZE_HPP_ER_2009
+#include <boost/statistics/detail/multi_array/serialization/save.hpp>
+#include <boost/statistics/detail/multi_array/serialization/load.hpp>
+#include <boost/serialization/split_free.hpp>
+
+namespace boost{ namespace serialization{
+
+ template<typename T,class Archive>
+ inline void serialize(
+ Archive & ar,
+ const boost::multi_array<T,2>& t,
+ const unsigned int file_version
+ )
+ {
+ split_free(ar, t, file_version);
+ }
+
+}}
+
+#endif
Added: sandbox/statistics/detail/multi_array/libs/statistics/detail/multi_array/example/serialize.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/multi_array/libs/statistics/detail/multi_array/example/serialize.cpp 2009-11-15 12:53:32 EST (Sun, 15 Nov 2009)
@@ -0,0 +1,76 @@
+//////////////////////////////////////////////////////////////////////////////
+// multi_array::example::serialize.cpp //
+// //
+// (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) //
+//////////////////////////////////////////////////////////////////////////////
+#include <vector>
+#include <string>
+#include <fstream>
+#include <boost/multi_array.hpp>
+#include <boost/archive/text_oarchive.hpp>
+#include <boost/archive/text_iarchive.hpp>
+#include <boost/statistics/detail/multi_array/serialization/serialize.hpp>
+//#include <boost/serialization/vector.hpp>
+#include <libs/statistics/detail/multi_array/example/serialize.h>
+
+void example_multi_array_serialize(std::ostream& os)
+{
+
+ os << "multi_array_serialize ->" << std::endl;
+
+ namespace ma = boost::detail::multi_array;
+
+ typedef std::string str_;
+ typedef std::ofstream ofs_;
+ typedef std::ifstream ifs_;
+ typedef boost::archive::text_oarchive oa_;
+ typedef boost::archive::text_iarchive ia_;
+ typedef double val_;
+ typedef boost::multi_array<val_, 2> array_;
+ typedef std::vector<array_> vec_array_;
+ typedef boost::array<ma::multi_array_base::index,2> extents_;
+ const unsigned n0 = 2;
+ const unsigned n1 = 2;
+ const str_ path = "./multi_array_serialization";
+ {
+ ofs_ ofs(path.c_str());
+ oa_ oa(ofs);
+ extents_ extents = {{n0,n1}};
+ array_ a(extents);
+ for(unsigned i = 0; i<n0; i++)
+ {
+ for(unsigned j = 0; j<n1; j++)
+ {
+ a[i][j] = i * n1 + j;
+ }
+ }
+ boost::serialization::save(oa,a,0);
+
+ // Neither of these compiles:
+ // boost::serialization::serialize(oa,a,0);
+ // oa << a;
+ }
+ {
+ ifs_ ifs(path.c_str());
+ ia_ ia(ifs);
+ array_ a;
+ // Neither of these compiles:
+ // boost::serialization::serialize(ia,a,0);
+ // ia >> a;
+ boost::serialization::load(ia,a,0);
+ for(unsigned i = 0; i<n0; i++)
+ {
+ for(unsigned j = 0; j<n1; j++)
+ {
+ BOOST_ASSERT(a[i][j] == i * n1 + j);
+ os << a[i][j] << ' ';
+ }
+ }
+ }
+ os << "<-" << std::endl;
+
+}
+
Added: sandbox/statistics/detail/multi_array/libs/statistics/detail/multi_array/example/serialize.h
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/multi_array/libs/statistics/detail/multi_array/example/serialize.h 2009-11-15 12:53:32 EST (Sun, 15 Nov 2009)
@@ -0,0 +1,17 @@
+//////////////////////////////////////////////////////////////////////////////
+// multi_array::example::serialize.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_MULTI_ARRAY_SERIALIZATION_SERIALIZE_HPP_ER_2009
+#define BOOST_STATISTICS_DETAIL_MULTI_ARRAY_SERIALIZATION_SERIALIZE_HPP_ER_2009
+#include <ostream>
+
+void example_multi_array_serialize(std::ostream& os);
+
+#endif
+
+
Added: sandbox/statistics/detail/multi_array/libs/statistics/detail/multi_array/src/main.cpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/multi_array/libs/statistics/detail/multi_array/src/main.cpp 2009-11-15 12:53:32 EST (Sun, 15 Nov 2009)
@@ -0,0 +1,10 @@
+#include <iostream>
+#include <libs/statistics/detail/multi_array/example/serialize.h>
+
+int main()
+{
+
+ example_multi_array_serialize(std::cout);
+
+ return 0;
+}
\ No newline at end of file
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