I want to know how can i serialize with boost::serialization a two dimensions boost::multiarray.
how should i do that, the thing is that i am working in a network linux home
and i have to find a way to be make that change in my own proyect not
modificating the boost/multiarray.hpp. You will have to excuse my english i
am from cuba.
i have this code but i don't know how to call it inside a class were i
already have a serialize methods for other parameters of the class, i also
want to make an xml output file.
#ifndef BOOST_MULTI_ARRAY_S11N_HPP
#define BOOST_MULTI_ARRAY_S11N_HPP
//For serialization
#include <iomanip>
#include <iostream>
#include <fstream>
#include
On Jun 12, 2007, at 4:54 PM, Alejandro Rubinos Carbajal wrote:
I want to know how can i serialize with boost::serialization a two dimensions boost::multiarray.
You will need to implement serialization support in boost::multiarray
Matthias
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On Tue, Jun 12, 2007 at 11:53:35AM -0400, Alejandro Rubinos Carbajal wrote:
how should i do that, the thing is that i am working in a network linux home and i have to find a way to be make that change in my own proyect not modificating the boost/multiarray.hpp. You will have to excuse my english i am from cuba.
You can do non-instrusive serialization support. Here is what I did for
boost::bitset that I keep in a header file in my hobby project.
To do something similar for boost/multiarray, you would implement these same
three functions with the second parameter changed to match the multiarray,
and change the body so that all the relevant bits are saved.
namespace boost { namespace serialization {
template
i have this code but i don't know how to call it inside a class were i already have a serialize methods for other parameters of the class, i also want to make an xml output file.
#ifndef BOOST_MULTI_ARRAY_S11N_HPP #define BOOST_MULTI_ARRAY_S11N_HPP
//For serialization #include <iomanip> #include <iostream> #include <fstream>
#include
#include #include #include #include
//#include //For multi_array #include
namespace boost { namespace serialization { //----------------------------------------------------------------------------- template< class Archive, class T > void save( Archive & ar, const multi_array
& t, const unsigned int /* version */ ) { unsigned int rows = t.shape()[0]; unsigned int cols = t.shape()[1]; ar & rows & cols; for ( unsigned int i=0; i template< class Archive, class T > void load( Archive & ar, multi_array
& t, const unsigned int /* version */ ) { unsigned int rows, cols; ar & rows & cols; t.resize( boost::extents[rows][cols] ); for ( unsigned int i=0; i template
inline void serialize( Archive & ar, multi_array & t, const unsigned int file_version ) { split_free(ar, t, file_version); } On 6/12/07, Matthias Troyer
wrote: On Jun 12, 2007, at 4:54 PM, Alejandro Rubinos Carbajal wrote:
I want to know how can i serialize with boost::serialization a two dimensions boost::multiarray.
You will need to implement serialization support in boost::multiarray
Matthias
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- ---------------------------------------------------------------------------- "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim." – Edsger W. Dijkstra ----------------------------------------------------------------------------
Here is an example of what i need to do
class x
{
friend class boost::serialization::access;
template <class Archive >
void serialize(Archive & ar, cons unsigned int version) //this is the
serialization method that i use for all
// the non-multiarray attributes.
template <class Archive >
void load(Archive ar, Multi_array(int,2), const int version)
void save(Archive ar, Multi_array(int,2), const int version)
void serialize(Archive ar, Multi_array(int,2), const int version)//this one
for the multiarray objects
private:
int a;
string b;
Multi_array(int,2) c;
Multi_array(int,2) d;
public:
///*
Class Methods and constructor
*////
template<class Archive>
void Management::serialize(Archive &ar, const unsigned int version)
{
ar & BOOST_SERIALIZATION_NVP(a);
ar & BOOST_SERIALIZATION_NVP(b);
//Now i don't nkonw what to do every thig that i try causes an error
}
}
On 6/12/07, Jeffrey Brent McBeth
On Tue, Jun 12, 2007 at 11:53:35AM -0400, Alejandro Rubinos Carbajal wrote:
how should i do that, the thing is that i am working in a network linux home and i have to find a way to be make that change in my own proyect not modificating the boost/multiarray.hpp. You will have to excuse my english i am from cuba.
You can do non-instrusive serialization support. Here is what I did for boost::bitset that I keep in a header file in my hobby project.
To do something similar for boost/multiarray, you would implement these same three functions with the second parameter changed to match the multiarray, and change the body so that all the relevant bits are saved.
namespace boost { namespace serialization { template
void save(Archive &ar, const std::bitset<Nb> &bs, const unsigned int version) { unsigned long i( bs.to_ulong()); ar << i; } template
void load(Archive &ar, std::bitset<Nb> &bs, const unsigned int version) { unsigned long i; ar >> i; bs = i; } template
void serialize(Archive &ar, std::bitset<Nb> &bs, const unsigned int version) { boost::serialization::split_free(ar, bs, version); } } } i have this code but i don't know how to call it inside a class were i already have a serialize methods for other parameters of the class, i
also
want to make an xml output file.
#ifndef BOOST_MULTI_ARRAY_S11N_HPP #define BOOST_MULTI_ARRAY_S11N_HPP
//For serialization #include <iomanip> #include <iostream> #include <fstream>
#include
#include #include #include #include
//#include //For multi_array #include
namespace boost { namespace serialization {
//-----------------------------------------------------------------------------
template< class Archive, class T > void save( Archive & ar, const multi_array
& t, const unsigned int /* version */ ) { unsigned int rows = t.shape()[0]; unsigned int cols = t.shape()[1]; ar & rows & cols; for ( unsigned int i=0; i template< class Archive, class T > void load( Archive & ar, multi_array
& t, const unsigned int /* version */ ) { unsigned int rows, cols; ar & rows & cols; t.resize( boost::extents[rows][cols] ); for ( unsigned int i=0; i template
inline void serialize( Archive & ar, multi_array & t, const unsigned int file_version ) { split_free(ar, t, file_version); } On 6/12/07, Matthias Troyer
wrote: On Jun 12, 2007, at 4:54 PM, Alejandro Rubinos Carbajal wrote:
I want to know how can i serialize with boost::serialization a two dimensions boost::multiarray.
You will need to implement serialization support in boost::multiarray
Matthias
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
--
---------------------------------------------------------------------------- "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim." – Edsger W. Dijkstra
----------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
I did take a look a year or so ago when the issue came up in a project, but we did not need it in the end. It seemed to me finally that an intrusive serialization is best, and you would need to modify boost/multiarray.hpp. Matthias On 12 Jun 2007, at 17:53, Alejandro Rubinos Carbajal wrote:
how should i do that, the thing is that i am working in a network linux home and i have to find a way to be make that change in my own proyect not modificating the boost/multiarray.hpp. You will have to excuse my english i am from cuba.
i have this code but i don't know how to call it inside a class were i already have a serialize methods for other parameters of the class, i also want to make an xml output file.
#ifndef BOOST_MULTI_ARRAY_S11N_HPP
#define BOOST_MULTI_ARRAY_S11N_HPP
//For serialization #include #include #include
#include #include
#include #include
#include //#include
//For multi_array #include
namespace boost { namespace serialization { //-------------------------------------------------------------------- --------- template< class Archive, class T >
void save( Archive & ar, const multi_array& t, const unsigned int /* version */ ) { unsigned int rows = t.shape()[0]; unsigned int cols = t.shape()[1]; ar & rows & cols;
for ( unsigned int i=0; i for ( unsigned int j=0; j ar & t[i][j]; } } }
template< class Archive, class T > void load( Archive & ar, multi_array& t,
const unsigned int /* version */ ) { unsigned int rows, cols; ar & rows & cols; t.resize( boost::extents[rows][cols] ); for ( unsigned int i=0; i for ( unsigned int j=0; j ar & t[i][j]; } } }
template inline void serialize( Archive & ar, multi_array& t, const unsigned int file_version ) {
split_free(ar, t, file_version); }
On 6/12/07, Matthias Troyer
wrote: On Jun 12, 2007, at 4:54 PM, Alejandro Rubinos Carbajal wrote:
I want to know how can i serialize with boost::serialization a two dimensions boost::multiarray.
You will need to implement serialization support in boost::multiarray
Matthias
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Alejandro Rubinos Carbajal
-
Jeffrey Brent McBeth
-
Matthias Troyer