boost-serialization

Binary serialization/de-serialization in C++ and C#

心不动则不痛 提交于 2019-12-01 17:34:22
问题 I am working on a distributed application which has two components. One is written in standard C++ ( not managed C++ and running on a Linux platform) and the other one is written in C#. Both are communicating via a message bus. I have a situation in which I need to pass objects from C++ to C# application and for this I need to serialize those objects in C++ and de-serialize them in C# (something like marshaling/un-marshaling in .NET). I need to perform this serialization in binary and not in

Boost class serialization, change in member types

我是研究僧i 提交于 2019-12-01 12:36:12
How does one handle switching the type of serialized members while retaining compatability with previous archive? E.g. I want to change float/int to double/size_t . I know I can increment version number but that makes code messy. Is there a different way to handle that? If it makes difference, the members are serialized thru MAKE_NVP . You can use the version parameter to version. The documentation gives this example: http://www.boost.org/doc/libs/1_55_0/libs/serialization/doc/tutorial.html#versioning Note how the version during serialization is specified by the BOOST_CLASS_VERSION macro. Here

How to serialize armadillo's vector

微笑、不失礼 提交于 2019-12-01 09:47:22
How can I serialize arma::Col ? Below are a MWE and the error output. MWE: #include <boost/mpi/environment.hpp> #include <boost/mpi/communicator.hpp> #include <iostream> #include "armadillo" namespace mpi = boost::mpi; struct S { int i; arma::Col<double>::fixed<3> cvector; friend class boost::serialization::access; template<class Archive> void serialize(Archive& ar, const unsigned int version) { ar& i; ar& cvector; } }; int main() { mpi::environment env; mpi::communicator world; S s; if (world.rank() == 0) { s.cvector[0] = 2; s.cvector[1] = 2; world.send(1, 0, s); } else { world.recv(0, 0, s);

Virtual functions and template clash

不打扰是莪最后的温柔 提交于 2019-12-01 06:36:51
I have an abstract base class for a pointAccumulator. This abstract base will be filled out with methods such as a function that returns mean of all the points. An example of these two classes is shown below: class lala { public: virtual someFunctions = 0; virtual bool isEmpty() = 0; }; class lalaLower : public lala { public: lalaLower(){} ~lalaLower(){} someFunctions template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & heights_; } protected: std::deque<double> heights_; }; As you can see in the code I would also like to use boost serialization in to save

Virtual functions and template clash

廉价感情. 提交于 2019-12-01 05:13:55
问题 I have an abstract base class for a pointAccumulator. This abstract base will be filled out with methods such as a function that returns mean of all the points. An example of these two classes is shown below: class lala { public: virtual someFunctions = 0; virtual bool isEmpty() = 0; }; class lalaLower : public lala { public: lalaLower(){} ~lalaLower(){} someFunctions template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & heights_; } protected: std::deque

Boost Serialization Library upgrade

帅比萌擦擦* 提交于 2019-11-30 19:15:23
How do I know that I can safely upgrade Boost Serialization Library on a production system without breaking compatibility with the existing data ? Is there any test that I should perform in order to be sure that all data stored in the binary format by previous version of the library will be successfully read by the new one ? Does Boost Serialization library itself guarantee some sort of compatibility between versions ? Boost.serialization is backward-compatible but is not guaranteed to be forwards compatible . This means: you can create an archive with an older version of boost.serialization

Boost Serialization Library upgrade

佐手、 提交于 2019-11-30 02:50:15
问题 How do I know that I can safely upgrade Boost Serialization Library on a production system without breaking compatibility with the existing data ? Is there any test that I should perform in order to be sure that all data stored in the binary format by previous version of the library will be successfully read by the new one ? Does Boost Serialization library itself guarantee some sort of compatibility between versions ? 回答1: Boost.serialization is backward-compatible but is not guaranteed to

how to use Boost:serialization to save Eigen::Matrix

谁说我不能喝 提交于 2019-11-29 05:10:40
Hello I have a code which implements libeigen2 to calculate eigen vectors. Now I want to use boost::serialization to save the information for retrieving later. From the example tutorial I came up with the following code! class RandomNode { private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & is_leaf_; ar & depth_; ar & num_classes_; ar & num_features_; // Split node members ar & random_feature_indices_; ar & random_feature_weights_; ar & threshold_; ar & leftChild_; ar & rightChild_; } bool is_leaf_; int

Boost serialization with pointers and non-default constructor

扶醉桌前 提交于 2019-11-29 04:33:58
How would you serialize/deserialize this class using boost::serialization? #include <vector> struct Foo { struct Bar { std::vector<int> * data; // Must point to Foo::data Bar( std::vector<int> * d ) : data(d) { } }; std::vector<int> data; std::vector<Bar> elements; Foo() { // do very time consuming calculation to populate "data" and "elements" } }; The constructor in Foo must not be executed when the objected is loaded from the serialized data, but if the object is default constructed the constructor must be evaluated. It is okay to add a default constructor to Bar, but after serialization the

Does Boost.Serialization serialize differently on different platforms?

余生颓废 提交于 2019-11-29 03:45:16
I use Boost.Serialization to serialize a std::map. The code looks like this void Dictionary::serialize(std::string & buffer) { try { std::stringstream ss; boost::archive::binary_oarchive archive(ss); archive << dict_; buffer = ss.str(); } catch (const std::exception & ex) { throw DictionaryException(ex.what()); } } void Dictionary::deserialize(const char * const data, int length) { try { namespace io = boost::iostreams; io::array_source source(data, length); io::stream<io::array_source> in(source); boost::archive::binary_iarchive archive(in); archive >> dict_; } catch (const std::exception &