boost-serialization

BOOST_CLASS_EXPORT_* macros are not working like register_type()

人盡茶涼 提交于 2019-12-24 10:20:03
问题 I am getting an unregistered_class exception when I serialize out a derived object to a file and serialize in from that file to a base class pointer when I use the boost export macros. When I replace the macros with the archive register_type() methods, it works. I need to use the macros because the application size and complexity makes the register_type() methods impractical. I am using RHEL 7.4, boost 1.53, and C++11. The classes are in shared libraries. Here is sample code to demonstrate

Why does boost::serialize not work despite everything seeming right? (“unregistered class”)

三世轮回 提交于 2019-12-24 03:35:23
问题 I am wondering about this. I have a C++ program with a number of data structs which derive from a common root and I need to serialize them using Boost. Each one has an inline member function to accept a visitor (so I can visit the structure without a "switch" statement). The objects look like this: In the .h file: // Graphic component. struct GraphicComponent : public Component { ... data members ... void accept(ComponentVisitor &vis) { vis.visitGraphicComponent(*this); } private: //

Boost Serialization - Serialize std::tr1::shared_ptr?

核能气质少年 提交于 2019-12-24 03:06:04
问题 Boost::Serialization has builtin support for boost::shared_ptr<> . Is there a way to use this support for std::tr1::shared_ptr<> too? Is it possible to cast from std::tr1::shared_ptr<> to boost::shared_ptr<> ? 回答1: A casting will not be possible as implementations differ. Also creating an instance of the one shared_ptr type with the value returned from get() on the other shared_ptr type will not work correctly as the reference countings will go to 0 at different points in your code which

Construct object from boost serialization archive

一笑奈何 提交于 2019-12-23 03:30:19
问题 Is it possible to construct objects from directly from the archive? Something like this... // Non-working pseudo code struct Foo { BOOST_SERIALIZATION_SPLIT_MEMBER(); std::vector<int> data; Foo() { // populate "data" by doing calculation data.push_back(1); data.push_back(2); } template<class Archive> Foo( Archive & ar ) { // populate "data" by rading the archive } template<class Archive> void save(Archive & ar, const unsigned int version) const { // Normal serialization of data ar << data; }

c++ network serialization [closed]

两盒软妹~` 提交于 2019-12-22 07:05:53
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I'm looking for a solution for serializing of c++ packets to a network stream. I have seen many posts here refering people to: ACE Google Protocol Buffers Boost::Serialization Qt ::QDataStream My Requirements/ Constraints: The solution must be unaware of LitteEndian/BigEndian. Machine Architecture x86/x64 and

boost serialization 1.5.5 crash when meets Nan and Inf

删除回忆录丶 提交于 2019-12-22 05:37:22
问题 It seems that boost serialization can't restore the value Nan and inf from text-based archives. The the program will terminate unless you handle the archive_exception in this case, any solutions to that ? 回答1: The author of the library has this to say: The simple truth is I never consider this. When it came up the last time I didn't really think about it very much as I was involved in other things and I hoped intereste[d] parties might come to a consensus without my having to bend my over

boost serialization std::unique_ptr support

假如想象 提交于 2019-12-21 04:08:33
问题 Does the boost serialization library support serialization of std::unique_ptr? I tried to compile the code below, but if I include the boost::archive::text_oarchive oa(ofs); oa << g; line, the compiler (btw gcc4.7 with -std=c++11 flag) throws an error /usr/include/boost/serialization/access.hpp:118:9: error: ‘class std::unique_ptr’ has no member named ‘serialize’ #include <iostream> #include <memory> #include <fstream> #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text

Boost serialize child class

江枫思渺然 提交于 2019-12-20 04:56:17
问题 I have base class User which is serializable : class User { public: User(); std::string GetLogin() const; void SetLogin(std::string login); protected: std::string mLogin; friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & mLogin; } }; This class can be inherited by other class like this : class UserA : public User { UserA(); private: friend class boost::serialization::access; template<class Archive> void serialize

Boost serialization : read varying type of data

喜你入骨 提交于 2019-12-20 02:11:34
问题 I have a C++ / CLI project that uses boost serialization to serialize three different classes. I would like to know if it is possible to parse the first line of the boost serialization archive in order to know what class was serialized in this archive, and then create an object of the appropriate class and deserialize the archive into the object. That line would contain an ID (maybe a int or value of an enum class) to identify which class was serialized. 回答1: The file format is already

Serialization example of boost/archive/binary_woarchive.hpp and/or boost/archive/binary_wiarchive.hpp?

半世苍凉 提交于 2019-12-20 01:46:18
问题 I'm trying to find a good example of how to use these binary wide character versions of boost's serialization stuff. I pieced together some code to try and get it working, but unfortunately I get bombarded with linker errors when trying to compile it. Here's my code, in case I'm doing anything obviously wrong: #include <cstdlib> #include <iostream> #include <fstream> #include <string> #include <vector> #include <boost/archive/binary_woarchive.hpp> #include <boost/archive/binary_wiarchive.hpp>