[Boost-bugs] [Boost C++ Libraries] #5368: Item for "Tips and Tricks" list in dokumentation

Subject: [Boost-bugs] [Boost C++ Libraries] #5368: Item for "Tips and Tricks" list in dokumentation
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-03-24 08:55:36

#5368: Item for "Tips and Tricks" list in dokumentation
 Reporter: schorsch_76@… | Owner: ramey
     Type: Patches | Status: new
Milestone: To Be Determined | Component: serialization
  Version: Boost Release Branch | Severity: Optimization
 Keywords: Boost 1.46.1 |
 several static libraries and avoid linking errors?

 == Make Header Archive.h ==
 Make a Header "Archive.h". Include Everything for your serialization here.
 #!div style="font-size: 80%"
 Code highlighting:
 #ifndef __Archive_h__
 #define __Archive_h__

 // STL Archive + stuff
 #include <boost/serialization/export.hpp>
 #include <boost/serialization/base_object.hpp>
 #include <boost/serialization/list.hpp>
 #include <boost/serialization/map.hpp>
 #include <boost/serialization/vector.hpp>
 #include <boost/serialization/shared_ptr.hpp>

 // IMPORTANT: Archive Headers at last
 // include headers that implement a archive in xml format
 #include <boost/archive/archive_exception.hpp>

 #include <boost/archive/xml_oarchive.hpp>
 #include <boost/archive/xml_iarchive.hpp>

 typedef boost::archive::xml_oarchive oarchive;
 typedef boost::archive::xml_iarchive iarchive;

 #endif // __Archive_h__

 == Define your classes as following ==

 #!div style="font-size: 80%"
 Code highlighting:

 #include "Archive.h"

 class Myclass

         double md_data;

     friend class boost::serialization::access;

     // When the class Archive corresponds to an output archive, the
     // & operator is defined similar to <<. Likewise, when the class
     // is a type of input archive the & operator is defined similar to >>.
     template<class Archive>
     void serialize(Archive & ar, const unsigned int version)
                 ar & BOOST_SERIALIZATION_NVP(md_data;);


 == Implementationfile of your class ==
 #!div style="font-size: 80%"
 Code highlighting:



 == Conclusion ==
 Thats the way i made it working in my project with VC10 and boost 1.46.1 .
 My project consists of several static libraries which have dependencies
 under each other. Main dependency is the library which contains the
 serializable classes.

 Hopefully this will help some people :-)

 Best Regards


Ticket URL: <https://svn.boost.org/trac/boost/ticket/5368>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:06 UTC