boost-serialization

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

流过昼夜 提交于 2019-12-18 04:21:50
问题 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

Does Boost.Serialization serialize differently on different platforms?

≯℡__Kan透↙ 提交于 2019-12-18 03:58:36
问题 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

Boost serialization end of file

﹥>﹥吖頭↗ 提交于 2019-12-14 03:43:31
问题 I serialize multiple objects into a binary archive with Boost. When reading back those objects from a binary_iarchive , is there a way to know how many objects are in the archive or simply a way to detect the end of the archive ? The only way I found is to use a try-catch to detect the stream exception. Thanks in advance. 回答1: I can think of a number of approaches: Serialize STL containers to/from your archive (see documentation). The archive will automatically keep track of how many objects

Low bandwidth performance using boost::asio::ip::tcp::iostream

三世轮回 提交于 2019-12-13 17:34:40
问题 I have written a small test program that uses boost::asio::ip::tcp::iostream to transmit about 38 MiB of data: #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_oarchive.hpp> #include <boost/asio.hpp> #include <boost/serialization/export.hpp> #include <boost/serialization/shared_ptr.hpp> #include <boost/serialization/vector.hpp> #include <chrono> #include <iostream> #include <sstream> #include <string> #include <thread> using namespace std; class Message { public:

I'm getting a error when I declare a class as a member of other class. error : a class-key must be used when declaring a friend

假装没事ソ 提交于 2019-12-13 02:38:58
问题 I am a C++ rookie and I was experimenting with boost serialization and I wanted to see if it works when a class is declared as a member of another class. But when I compile my code I get loads of errors. I tried declaring baseds as a struct but no change in errors. My code : #include <iostream> #include <fstream> #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_oarchive.hpp> class baseds{}; class superior{}; class baseds { private: friend class boost::serialization:

boost serialization: save_construct_data not called

萝らか妹 提交于 2019-12-12 17:09:25
问题 I'm using boost to serialize object without a default constructor, however I get a weird issue : save_construct_data is not being called ! Bellow a sample program that reproduce this problem: main.cpp #include <vector> #include <iostream> #include "Test.h" #include <fstream> #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/serialization/serialization.hpp> int main() { using T = float; walid::Test<T> instance ( 2, {2.3f, -0.5f} ) ; std:

Boost: Serializing/De-serializing a custom C++ object passed over ZeroMQ pull socket

时光总嘲笑我的痴心妄想 提交于 2019-12-12 16:39:04
问题 Description: I have a C++ class named GenericMessage which simply holds an id and data as its members (See code snippet 1 below - GenericMessage.hxx). My intention is to serialize an instance of this class and send it via a ZeroMQ socket which implements the push pattern. The serialization and sending task has been implemented in class ZMQHandler (see sendToBE function) which is placed in a header file name ZMQHandler.hxx shown in the code snippet 2 below. This class is instantiated by TestFE

boost:serialization reconstruction (loading)

懵懂的女人 提交于 2019-12-12 12:23:10
问题 I'm using boost:serialization to save data structures into a file. The actual data is a pointer vector of classes and subclasses. However the constructor of the class which is serialized takes as parameter another instantiated class Agent which is an object that controls communication with a simulation API (webots). I see that in boost::serialization examples, the serializable objects need an empty constructor class() {}; to be used for the reconstruction. However this is impractical in my

Boost Polygon Serialization: Ring

自作多情 提交于 2019-12-12 11:33:33
问题 According to this related question (Boost Polygon Serialization). I am trying to serialize polygons with Boost. The problem I have now is that I am trying to compile an example using polygons of custom X, Y, points, but the compiler throws this error at compile time: error: 'class boost::geometry::model::ring<boost::geometry::model::d2::point_xy<double> >' has no member named 'serialize' Like there is no defined any function to serialize a ring. Since a Ring extends from std::vector, and as

Polymorphic Serialization w/ Boost

拜拜、爱过 提交于 2019-12-12 08:56:49
问题 I'm trying to (de)serialize a polymorphic vector, but have different issues with different attempts. The entire order of events are: Serialize a Polymorphic Vector on Server Side Send the serialized string over the network De-serialize to a new Polymorphic Vector on Client Side Edit Data in Vector (includes adding, editing and deleting) on Client Side Serialize the edited Polymorphic Vector on Client Side Send the new serialized string over the network De-serialize the new Polymorphic Vector